X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FThreads.c;h=4f9560c36c10f5ec12163ad8af9dd9d7edafedd6;hb=0a5613f40b0e32cf59966e6b56b807cdbe80aa7b;hp=1d871a58562e479b87d6219ccda52ad47f2c3541;hpb=dd56e9ab4544e83d27532a8d9058140bfe81825c;p=ghc-hetmet.git diff --git a/rts/Threads.c b/rts/Threads.c index 1d871a5..4f9560c 100644 --- a/rts/Threads.c +++ b/rts/Threads.c @@ -8,10 +8,8 @@ #include "PosixSource.h" #include "Rts.h" -#include "SchedAPI.h" -#include "Storage.h" + #include "Threads.h" -#include "RtsFlags.h" #include "STM.h" #include "Schedule.h" #include "Trace.h" @@ -65,7 +63,7 @@ createThread(Capability *cap, nat size) } size = round_to_mblocks(size); - tso = (StgTSO *)allocateLocal(cap, size); + tso = (StgTSO *)allocate(cap, size); stack_size = size - TSO_STRUCT_SIZEW; TICK_ALLOC_TSO(stack_size, 0); @@ -77,7 +75,8 @@ createThread(Capability *cap, nat size) tso->why_blocked = NotBlocked; tso->blocked_exceptions = END_TSO_QUEUE; - tso->flags = TSO_DIRTY; + tso->flags = 0; + tso->dirty = 1; tso->saved_errno = 0; tso->bound = NULL; @@ -103,15 +102,13 @@ createThread(Capability *cap, nat size) */ ACQUIRE_LOCK(&sched_mutex); tso->id = next_thread_id++; // while we have the mutex - tso->global_link = g0s0->threads; - g0s0->threads = tso; + tso->global_link = g0->threads; + g0->threads = tso; RELEASE_LOCK(&sched_mutex); - postEvent (cap, EVENT_CREATE_THREAD, tso->id, 0); + // ToDo: report the stack size in the event? + traceEventCreateThread(cap, tso); - debugTrace(DEBUG_sched, - "created thread %ld, stack size = %lx words", - (long)tso->id, (long)tso->stack_size); return tso; } @@ -257,10 +254,7 @@ unblockOne_ (Capability *cap, StgTSO *tso, cap->context_switch = 1; #endif - postEvent (cap, EVENT_THREAD_WAKEUP, tso->id, tso->cap->no); - - debugTrace(DEBUG_sched, "waking up thread %ld on cap %d", - (long)tso->id, tso->cap->no); + traceEventThreadWakeup (cap, tso, tso->cap->no); return next; } @@ -358,6 +352,7 @@ printThreadBlockage(StgTSO *tso) } } + void printThreadStatus(StgTSO *t) { @@ -379,7 +374,7 @@ printThreadStatus(StgTSO *t) default: printThreadBlockage(t); } - if (t->flags & TSO_DIRTY) { + if (t->dirty) { debugBelch(" (TSO_DIRTY)"); } else if (t->flags & TSO_LINK_DIRTY) { debugBelch(" (TSO_LINK_DIRTY)"); @@ -392,24 +387,10 @@ void printAllThreads(void) { StgTSO *t, *next; - nat i, s; + nat i, g; Capability *cap; -# if defined(GRAN) - char time_string[TIME_STR_LEN], node_str[NODE_STR_LEN]; - ullong_format_string(TIME_ON_PROC(CurrentProc), - time_string, rtsFalse/*no commas!*/); - - debugBelch("all threads at [%s]:\n", time_string); -# elif defined(PARALLEL_HASKELL) - char time_string[TIME_STR_LEN], node_str[NODE_STR_LEN]; - ullong_format_string(CURRENT_TIME, - time_string, rtsFalse/*no commas!*/); - - debugBelch("all threads at [%s]:\n", time_string); -# else debugBelch("all threads:\n"); -# endif for (i = 0; i < n_capabilities; i++) { cap = &capabilities[i]; @@ -420,8 +401,8 @@ printAllThreads(void) } debugBelch("other threads:\n"); - for (s = 0; s < total_steps; s++) { - for (t = all_steps[s].threads; t != END_TSO_QUEUE; t = next) { + for (g = 0; g < RtsFlags.GcFlags.generations; g++) { + for (t = generations[g].threads; t != END_TSO_QUEUE; t = next) { if (t->why_blocked != NotBlocked) { printThreadStatus(t); }