1 /* -----------------------------------------------------------------------------
2 * $Id: TSO.h,v 1.5 1999/03/02 19:44:22 sof Exp $
4 * (c) The GHC Team, 1998-1999
6 * The definitions for Thread State Objects.
8 * ---------------------------------------------------------------------------*/
13 #if defined(PROFILING)
15 CostCentreStack *CCCS; /* thread's current CCS */
17 #else /* !PROFILING */
20 #endif /* PROFILING */
52 * We are completely paranoid and make thread IDs 64 bits to avoid
53 * having to worry about overflow. A little calculation shows that
54 * even doing 10^6 forks per second would take 35 million years to
55 * overflow a 64 bit thread ID :-)
58 typedef StgWord32 StgThreadID;
61 * This type is returned to the scheduler by a thread that has
62 * stopped for one reason or another.
66 HeapOverflow, /* might also be StackOverflow */
71 } StgThreadReturnCode;
74 * TSOs live on the heap, and therefore look just like heap objects.
75 * Large TSOs will live in their own "block group" allocated by the
76 * storage manager, and won't be copied during garbage collection.
79 typedef struct StgTSO_ {
82 StgMutClosure * mut_link; /* TSO's are mutable of course! */
83 StgTSOWhatNext whatNext;
84 StgTSOState state; /* necessary? */
86 /* Exception Handlers */
87 StgTSOTickyInfo ticky;
92 /* The thread stack... */
93 StgWord stack_size; /* stack size in *words* */
94 StgWord max_stack_size; /* maximum stack size in *words* */
102 extern DLL_IMPORT_RTS StgTSO *CurrentTSO;
105 /* Workaround for a bug/quirk in gcc on certain architectures.
106 * symptom is that (&tso->stack - &tso->header) /= sizeof(StgTSO)
107 * in other words, gcc pads the structure at the end.
110 extern StgTSO dummy_tso;
112 #define TSO_STRUCT_SIZE \
113 ((int)&(dummy_tso).stack - (int)&(dummy_tso).header)
115 #define TSO_STRUCT_SIZEW (TSO_STRUCT_SIZE / sizeof(W_))