projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Buggy optimizations caused function-call return to share the function's entry point
[ghc-hetmet.git]
/
rts
/
Task.c
diff --git
a/rts/Task.c
b/rts/Task.c
index
0ec60f7
..
9397789
100644
(file)
--- a/
rts/Task.c
+++ b/
rts/Task.c
@@
-64,25
+64,16
@@
initTaskManager (void)
}
}
}
}
-
-void
-stopTaskManager (void)
-{
- debugTrace(DEBUG_sched,
- "stopping task manager, %d tasks still running",
- tasksRunning);
- /* nothing to do */
-}
-
-
-void
+nat
freeTaskManager (void)
{
Task *task, *next;
freeTaskManager (void)
{
Task *task, *next;
- debugTrace(DEBUG_sched, "freeing task manager");
+ ASSERT_LOCK_HELD(&sched_mutex);
+
+ debugTrace(DEBUG_sched, "freeing task manager, %d tasks still running",
+ tasksRunning);
- ACQUIRE_LOCK(&sched_mutex);
for (task = all_tasks; task != NULL; task = next) {
next = task->all_link;
if (task->stopped) {
for (task = all_tasks; task != NULL; task = next) {
next = task->all_link;
if (task->stopped) {
@@
-102,7
+93,8
@@
freeTaskManager (void)
#if defined(THREADED_RTS)
freeThreadLocalKey(¤tTaskKey);
#endif
#if defined(THREADED_RTS)
freeThreadLocalKey(¤tTaskKey);
#endif
- RELEASE_LOCK(&sched_mutex);
+
+ return tasksRunning;
}
}
@@
-114,7
+106,8
@@
newTask (void)
#endif
Task *task;
#endif
Task *task;
- task = stgMallocBytes(sizeof(Task), "newTask");
+#define ROUND_TO_CACHE_LINE(x) ((((x)+63) / 64) * 64)
+ task = stgMallocBytes(ROUND_TO_CACHE_LINE(sizeof(Task)), "newTask");
task->cap = NULL;
task->stopped = rtsFalse;
task->cap = NULL;
task->stopped = rtsFalse;
@@
-148,7
+141,6
@@
newTask (void)
all_tasks = task;
taskCount++;
all_tasks = task;
taskCount++;
- workerCount++;
return task;
}
return task;
}
@@
-184,6
+176,7
@@
newBoundTask (void)
void
boundTaskExiting (Task *task)
{
void
boundTaskExiting (Task *task)
{
+ task->tso = NULL;
task->stopped = rtsTrue;
task->cap = NULL;
task->stopped = rtsTrue;
task->cap = NULL;
@@
-217,7
+210,11
@@
discardTask (Task *task)
if (!task->stopped) {
debugTrace(DEBUG_sched, "discarding task %ld", (long)TASK_ID(task));
task->cap = NULL;
if (!task->stopped) {
debugTrace(DEBUG_sched, "discarding task %ld", (long)TASK_ID(task));
task->cap = NULL;
- task->tso = NULL;
+ if (task->tso == NULL) {
+ workerCount--;
+ } else {
+ task->tso = NULL;
+ }
task->stopped = rtsTrue;
tasksRunning--;
task->next = task_free_list;
task->stopped = rtsTrue;
tasksRunning--;
task->next = task_free_list;
@@
-262,6
+259,7
@@
workerTaskStop (Task *task)
taskTimeStamp(task);
task->stopped = rtsTrue;
tasksRunning--;
taskTimeStamp(task);
task->stopped = rtsTrue;
tasksRunning--;
+ workerCount--;
ACQUIRE_LOCK(&sched_mutex);
task->next = task_free_list;
ACQUIRE_LOCK(&sched_mutex);
task->next = task_free_list;