diff options
| author | Austin Seipp <austin@well-typed.com> | 2014-10-21 16:34:07 -0500 |
|---|---|---|
| committer | Austin Seipp <austin@well-typed.com> | 2014-10-21 16:34:07 -0500 |
| commit | 570b3393f926e8fc107be6f4234381b3b636d0de (patch) | |
| tree | 3d34097eaead420b3887338eb0b89da6eb0e6754 | |
| parent | 6aa6ca89cf73a705ddd0cfccf8e89648e1edc6d5 (diff) | |
| download | haskell-570b3393f926e8fc107be6f4234381b3b636d0de.tar.gz | |
[skip ci] rts: Detabify Threads.c
Signed-off-by: Austin Seipp <austin@well-typed.com>
| -rw-r--r-- | rts/Threads.c | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/rts/Threads.c b/rts/Threads.c index 0d0a3fc106..76e844a3f6 100644 --- a/rts/Threads.c +++ b/rts/Threads.c @@ -35,11 +35,11 @@ static StgThreadID next_thread_id = 1; * RESERVED_STACK_WORDS (so we can get back from the stack overflow) * + sizeofW(StgStopFrame) (the stg_stop_thread_info frame) * + 1 (the closure to enter) - * + 1 (stg_ap_v_ret) - * + 1 (spare slot req'd by stg_ap_v_ret) + * + 1 (stg_ap_v_ret) + * + 1 (spare slot req'd by stg_ap_v_ret) * * A thread with this stack will bomb immediately with a stack - * overflow, which will increase its stack size. + * overflow, which will increase its stack size. */ #define MIN_STACK_WORDS (RESERVED_STACK_WORDS + sizeofW(StgStopFrame) + 3) @@ -106,7 +106,7 @@ createThread(Capability *cap, W_ size) tso->saved_errno = 0; tso->bound = NULL; tso->cap = cap; - + tso->stackobj = stack; tso->tot_stack_size = stack->stack_size; @@ -115,7 +115,7 @@ createThread(Capability *cap, W_ size) #ifdef PROFILING tso->prof.cccs = CCS_MAIN; #endif - + // put a stop frame on the stack stack->sp -= sizeofW(StgStopFrame); SET_HDR((StgClosure*)stack->sp, @@ -128,7 +128,7 @@ createThread(Capability *cap, W_ size) tso->global_link = g0->threads; g0->threads = tso; RELEASE_LOCK(&sched_mutex); - + // ToDo: report the stack size in the event? traceEventCreateThread(cap, tso); @@ -143,11 +143,11 @@ createThread(Capability *cap, W_ size) * ------------------------------------------------------------------------ */ int -cmp_thread(StgPtr tso1, StgPtr tso2) -{ - StgThreadID id1 = ((StgTSO *)tso1)->id; +cmp_thread(StgPtr tso1, StgPtr tso2) +{ + StgThreadID id1 = ((StgTSO *)tso1)->id; StgThreadID id2 = ((StgTSO *)tso2)->id; - + if (id1 < id2) return (-1); if (id1 > id2) return 1; return 0; @@ -159,7 +159,7 @@ cmp_thread(StgPtr tso1, StgPtr tso2) * This is used in the implementation of Show for ThreadIds. * ------------------------------------------------------------------------ */ int -rts_getThreadId(StgPtr tso) +rts_getThreadId(StgPtr tso) { return ((StgTSO *)tso)->id; } @@ -176,23 +176,23 @@ removeThreadFromQueue (Capability *cap, StgTSO **queue, StgTSO *tso) prev = NULL; for (t = *queue; t != END_TSO_QUEUE; prev = t, t = t->_link) { - if (t == tso) { - if (prev) { - setTSOLink(cap,prev,t->_link); + if (t == tso) { + if (prev) { + setTSOLink(cap,prev,t->_link); t->_link = END_TSO_QUEUE; return rtsFalse; - } else { - *queue = t->_link; + } else { + *queue = t->_link; t->_link = END_TSO_QUEUE; return rtsTrue; - } - } + } + } } barf("removeThreadFromQueue: not found"); } rtsBool // returns True if we modified head or tail -removeThreadFromDeQueue (Capability *cap, +removeThreadFromDeQueue (Capability *cap, StgTSO **head, StgTSO **tail, StgTSO *tso) { StgTSO *t, *prev; @@ -200,26 +200,26 @@ removeThreadFromDeQueue (Capability *cap, prev = NULL; for (t = *head; t != END_TSO_QUEUE; prev = t, t = t->_link) { - if (t == tso) { - if (prev) { - setTSOLink(cap,prev,t->_link); + if (t == tso) { + if (prev) { + setTSOLink(cap,prev,t->_link); flag = rtsFalse; - } else { - *head = t->_link; + } else { + *head = t->_link; flag = rtsTrue; - } + } t->_link = END_TSO_QUEUE; if (*tail == tso) { - if (prev) { - *tail = prev; - } else { - *tail = END_TSO_QUEUE; - } + if (prev) { + *tail = prev; + } else { + *tail = END_TSO_QUEUE; + } return rtsTrue; - } else { + } else { return flag; } - } + } } barf("removeThreadFromDeQueue: not found"); } @@ -268,7 +268,7 @@ tryWakeupThread (Capability *cap, StgTSO *tso) case BlockedOnMsgThrowTo: { const StgInfoTable *i; - + i = lockClosure(tso->block_info.closure); unlockClosure(tso->block_info.closure, i); if (i != &stg_MSG_NULL_info) { @@ -343,7 +343,7 @@ wakeBlockingQueue(Capability *cap, StgBlockingQueue *bq) ASSERT(bq->header.info == &stg_BLOCKING_QUEUE_DIRTY_info || bq->header.info == &stg_BLOCKING_QUEUE_CLEAN_info ); - for (msg = bq->queue; msg != (MessageBlackHole*)END_TSO_QUEUE; + for (msg = bq->queue; msg != (MessageBlackHole*)END_TSO_QUEUE; msg = msg->link) { i = msg->header.info; if (i != &stg_IND_info) { @@ -377,7 +377,7 @@ checkBlockingQueues (Capability *cap, StgTSO *tso) debugTraceCap(DEBUG_sched, cap, "collision occurred; checking blocking queues for thread %ld", (W_)tso->id); - + for (bq = tso->bq; bq != (StgBlockingQueue*)END_TSO_QUEUE; bq = next) { next = bq->link; @@ -386,14 +386,14 @@ checkBlockingQueues (Capability *cap, StgTSO *tso) // traversing this IND multiple times. continue; } - + p = bq->bh; if (p->header.info != &stg_BLACKHOLE_info || ((StgInd *)p)->indirectee != (StgClosure*)bq) { wakeBlockingQueue(cap,bq); - } + } } } @@ -420,7 +420,7 @@ updateThunk (Capability *cap, StgTSO *tso, StgClosure *thunk, StgClosure *val) updateWithIndirection(cap, thunk, val); return; } - + v = ((StgInd*)thunk)->indirectee; updateWithIndirection(cap, thunk, val); @@ -457,7 +457,7 @@ updateThunk (Capability *cap, StgTSO *tso, StgClosure *thunk, StgClosure *val) * rtsSupportsBoundThreads(): is the RTS built to support bound threads? * used by Control.Concurrent for error checking. * ------------------------------------------------------------------------- */ - + HsBool rtsSupportsBoundThreads(void) { @@ -471,7 +471,7 @@ rtsSupportsBoundThreads(void) /* --------------------------------------------------------------------------- * isThreadBound(tso): check whether tso is bound to an OS thread. * ------------------------------------------------------------------------- */ - + StgBool isThreadBound(StgTSO* tso USED_IF_THREADS) { @@ -558,7 +558,7 @@ threadStackOverflow (Capability *cap, StgTSO *tso) // we squeezed is not enough to run the thread, we'll come back // here (no squeezing will have occurred and thus we'll enlarge the // stack.) - if ((tso->flags & TSO_SQUEEZED) && + if ((tso->flags & TSO_SQUEEZED) && ((W_)(tso->stackobj->sp - tso->stackobj->stack) >= BLOCK_SIZE_W)) { return; } @@ -787,7 +787,7 @@ printThreadBlockage(StgTSO *tso) debugBelch("is blocked on atomic MVar read @ %p", tso->block_info.closure); break; case BlockedOnBlackHole: - debugBelch("is blocked on a black hole %p", + debugBelch("is blocked on a black hole %p", ((StgBlockingQueue*)tso->block_info.bh->bh)); break; case BlockedOnMsgThrowTo: @@ -810,7 +810,7 @@ printThreadBlockage(StgTSO *tso) break; default: barf("printThreadBlockage: strange tso->why_blocked: %d for TSO %d (%d)", - tso->why_blocked, tso->id, tso); + tso->why_blocked, tso->id, tso); } } @@ -824,19 +824,19 @@ printThreadStatus(StgTSO *t) if (label) debugBelch("[\"%s\"] ",(char *)label); } switch (t->what_next) { - case ThreadKilled: - debugBelch("has been killed"); - break; - case ThreadComplete: - debugBelch("has completed"); - break; - default: - printThreadBlockage(t); - } + case ThreadKilled: + debugBelch("has been killed"); + break; + case ThreadComplete: + debugBelch("has completed"); + break; + default: + printThreadBlockage(t); + } if (t->dirty) { debugBelch(" (TSO_DIRTY)"); } - debugBelch("\n"); + debugBelch("\n"); } void @@ -852,7 +852,7 @@ printAllThreads(void) cap = capabilities[i]; debugBelch("threads on capability %d:\n", cap->no); for (t = cap->run_queue_hd; t != END_TSO_QUEUE; t = t->_link) { - printThreadStatus(t); + printThreadStatus(t); } } @@ -860,7 +860,7 @@ printAllThreads(void) 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); + printThreadStatus(t); } next = t->global_link; } @@ -868,13 +868,13 @@ printAllThreads(void) } // useful from gdb -void +void printThreadQueue(StgTSO *t) { nat i = 0; for (; t != END_TSO_QUEUE; t = t->_link) { - printThreadStatus(t); - i++; + printThreadStatus(t); + i++; } debugBelch("%d threads on queue\n", i); } |
