* the THREADED_RTS and (inc. SMP) runtime.
*/
#if defined(THREADED_RTS)
-Mutex sched_mutex = INIT_MUTEX_VAR;
+Mutex sched_mutex;
#endif
#if defined(PARALLEL_HASKELL)
for (; t != END_TSO_QUEUE; t = next) {
next = t->link;
t->link = END_TSO_QUEUE;
- if (t->what_next == ThreadRelocated) {
+ if (t->what_next == ThreadRelocated
+ || t->bound == task) { // don't move my bound thread
prev->link = t;
prev = t;
} else if (i == n_free_caps) {
)
{
#ifdef FORKPROCESS_PRIMOP_SUPPORTED
+ Task *task;
pid_t pid;
StgTSO* t,*next;
- Task *task;
Capability *cap;
IF_DEBUG(scheduler,sched_belch("forking!"));
deleteThreadImmediately(cap,t);
}
- // wipe the main thread list
- while ((task = all_tasks) != NULL) {
- all_tasks = task->all_link;
- discardTask(task);
+ // wipe the task list
+ ACQUIRE_LOCK(&sched_mutex);
+ for (task = all_tasks; task != NULL; task=task->all_link) {
+ if (task != cap->running_task) discardTask(task);
}
-
+ RELEASE_LOCK(&sched_mutex);
+
+#if defined(THREADED_RTS)
+ // wipe our spare workers list.
+ cap->spare_workers = NULL;
+#endif
+
cap = rts_evalStableIO(cap, entry, NULL); // run the action
rts_checkSchedStatus("forkProcess",cap);