X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FThreads.c;h=a9d4a721d37372729cfb7dcca08445938e834cd4;hb=7aac567ca3c3daae7c738230b1d1b2bdda816b96;hp=d7b5f4168e7cdc91e9ef78b0b2ed8b8fab013f93;hpb=150cc9e2e4657cc58bd7ec4c15e5cb72f2e1c0f6;p=ghc-hetmet.git diff --git a/rts/Threads.c b/rts/Threads.c index d7b5f41..a9d4a72 100644 --- a/rts/Threads.c +++ b/rts/Threads.c @@ -119,7 +119,7 @@ createThread(Capability *cap, nat size) /* put a stop frame on the stack */ tso->sp -= sizeofW(StgStopFrame); SET_HDR((StgClosure*)tso->sp,(StgInfoTable *)&stg_stop_thread_info,CCS_SYSTEM); - tso->link = END_TSO_QUEUE; + tso->_link = END_TSO_QUEUE; // ToDo: check this #if defined(GRAN) @@ -145,8 +145,8 @@ createThread(Capability *cap, nat size) */ ACQUIRE_LOCK(&sched_mutex); tso->id = next_thread_id++; // while we have the mutex - tso->global_link = all_threads; - all_threads = tso; + tso->global_link = g0s0->threads; + g0s0->threads = tso; RELEASE_LOCK(&sched_mutex); #if defined(DIST) @@ -292,17 +292,17 @@ rts_getThreadId(StgPtr tso) -------------------------------------------------------------------------- */ void -removeThreadFromQueue (StgTSO **queue, StgTSO *tso) +removeThreadFromQueue (Capability *cap, StgTSO **queue, StgTSO *tso) { StgTSO *t, *prev; prev = NULL; - for (t = *queue; t != END_TSO_QUEUE; prev = t, t = t->link) { + for (t = *queue; t != END_TSO_QUEUE; prev = t, t = t->_link) { if (t == tso) { if (prev) { - prev->link = t->link; + setTSOLink(cap,prev,t->_link); } else { - *queue = t->link; + *queue = t->_link; } return; } @@ -311,17 +311,18 @@ removeThreadFromQueue (StgTSO **queue, StgTSO *tso) } void -removeThreadFromDeQueue (StgTSO **head, StgTSO **tail, StgTSO *tso) +removeThreadFromDeQueue (Capability *cap, + StgTSO **head, StgTSO **tail, StgTSO *tso) { StgTSO *t, *prev; prev = NULL; - for (t = *head; t != END_TSO_QUEUE; prev = t, t = t->link) { + for (t = *head; t != END_TSO_QUEUE; prev = t, t = t->_link) { if (t == tso) { if (prev) { - prev->link = t->link; + setTSOLink(cap,prev,t->_link); } else { - *head = t->link; + *head = t->_link; } if (*tail == tso) { if (prev) { @@ -337,9 +338,9 @@ removeThreadFromDeQueue (StgTSO **head, StgTSO **tail, StgTSO *tso) } void -removeThreadFromMVarQueue (StgMVar *mvar, StgTSO *tso) +removeThreadFromMVarQueue (Capability *cap, StgMVar *mvar, StgTSO *tso) { - removeThreadFromDeQueue (&mvar->head, &mvar->tail, tso); + removeThreadFromDeQueue (cap, &mvar->head, &mvar->tail, tso); } /* ---------------------------------------------------------------------------- @@ -489,8 +490,8 @@ unblockOne_ (Capability *cap, StgTSO *tso, ASSERT(tso->why_blocked != NotBlocked); tso->why_blocked = NotBlocked; - next = tso->link; - tso->link = END_TSO_QUEUE; + next = tso->_link; + tso->_link = END_TSO_QUEUE; #if defined(THREADED_RTS) if (tso->cap == cap || (!tsoLocked(tso) && @@ -509,7 +510,7 @@ unblockOne_ (Capability *cap, StgTSO *tso, context_switch = 1; } else { // we'll try to wake it up on the Capability it was last on. - wakeupThreadOnCapability_lock(tso->cap, tso); + wakeupThreadOnCapability(cap, tso->cap, tso); } #else appendToRunQueue(cap,tso); @@ -697,7 +698,7 @@ printThreadBlockage(StgTSO *tso) break; #if defined(mingw32_HOST_OS) case BlockedOnDoProc: - debugBelch("is blocked on proc (request: %ld)", tso->block_info.async_result->reqID); + debugBelch("is blocked on proc (request: %u)", tso->block_info.async_result->reqID); break; #endif case BlockedOnDelay: @@ -770,7 +771,7 @@ void printAllThreads(void) { StgTSO *t, *next; - nat i; + nat i, s; Capability *cap; # if defined(GRAN) @@ -792,21 +793,23 @@ printAllThreads(void) for (i = 0; i < n_capabilities; i++) { cap = &capabilities[i]; debugBelch("threads on capability %d:\n", cap->no); - for (t = cap->run_queue_hd; t != END_TSO_QUEUE; t = t->link) { + for (t = cap->run_queue_hd; t != END_TSO_QUEUE; t = t->_link) { printThreadStatus(t); } } debugBelch("other threads:\n"); - for (t = all_threads; t != END_TSO_QUEUE; t = next) { + for (s = 0; s < total_steps; s++) { + for (t = all_steps[s].threads; t != END_TSO_QUEUE; t = next) { if (t->why_blocked != NotBlocked) { printThreadStatus(t); } if (t->what_next == ThreadRelocated) { - next = t->link; + next = t->_link; } else { next = t->global_link; } + } } } @@ -815,7 +818,7 @@ void printThreadQueue(StgTSO *t) { nat i = 0; - for (; t != END_TSO_QUEUE; t = t->link) { + for (; t != END_TSO_QUEUE; t = t->_link) { printThreadStatus(t); i++; }