/* -----------------------------------------------------------------------------
- * $Id: TSO.h,v 1.38 2004/11/10 02:13:12 wolfgang Exp $
*
* (c) The GHC Team, 1998-1999
*
*/
typedef StgWord32 StgThreadID;
+/*
+ * Flags for the tso->flags field.
+ *
+ * The TSO_DIRTY flag indicates that this TSO's stack should be
+ * scanned during garbage collection. The link field of a TSO is
+ * always scanned, so we don't have to dirty a TSO just for linking
+ * it on a different list.
+ *
+ * TSO_DIRTY is set by
+ * - schedule(), just before running a thread,
+ * - raiseAsync(), because it modifies a thread's stack
+ * - resumeThread(), just before running the thread again
+ * and unset by the garbage collector (only).
+ */
+#define TSO_DIRTY 1
+
+#define tsoDirty(tso) ((tso)->flags & TSO_DIRTY)
+
/*
* Type returned after running a thread. Values of this type
* include HeapOverflow, StackOverflow etc. See Constants.h for the
*/
typedef unsigned int StgThreadReturnCode;
-#if defined(mingw32_TARGET_OS)
-/* results from an async I/O request + it's ID. */
+#if defined(mingw32_HOST_OS)
+/* results from an async I/O request + its request ID. */
typedef struct {
unsigned int reqID;
int len;
typedef union {
StgClosure *closure;
struct StgTSO_ *tso;
- StgInt fd; // StgInt instead of int, so that it's the same size as the ptrs
-#if defined(mingw32_TARGET_OS)
- StgAsyncIOResult* async_result;
+ StgInt fd; /* StgInt instead of int, so that it's the same size as the ptrs */
+#if defined(mingw32_HOST_OS)
+ StgAsyncIOResult *async_result;
#endif
StgWord target;
} StgTSOBlockInfo;
* field.
*/
-/*
- * ToDo: make this structure sensible on a non-32-bit arch.
- */
-
typedef struct StgTSO_ {
- StgHeader header;
-
- struct StgTSO_* link; // Links threads onto blocking queues */
- StgMutClosure * mut_link; // TSO's are mutable of course! */
- struct StgTSO_* global_link; // Links all threads together */
-
- StgWord16 what_next; // Values defined in Constants.h
- StgWord16 why_blocked; // Values defined in Constants.h
- StgTSOBlockInfo block_info;
- struct StgTSO_* blocked_exceptions;
- StgThreadID id;
- int saved_errno;
- struct StgMainThread_* main;
-
+ StgHeader header;
+
+ struct StgTSO_* link; /* Links threads onto blocking queues */
+ struct StgTSO_* global_link; /* Links all threads together */
+
+ StgWord16 what_next; /* Values defined in Constants.h */
+ StgWord16 why_blocked; /* Values defined in Constants.h */
+ StgWord32 flags;
+ StgTSOBlockInfo block_info;
+ struct StgTSO_* blocked_exceptions;
+ StgThreadID id;
+ int saved_errno;
+ struct Task_* bound;
+ struct Capability_* cap;
+ struct StgTRecHeader_ * trec; /* STM transaction record */
+
#ifdef TICKY_TICKY
- // TICKY-specific stuff would go here.
+ /* TICKY-specific stuff would go here. */
#endif
#ifdef PROFILING
- StgTSOProfInfo prof;
+ StgTSOProfInfo prof;
#endif
#ifdef PAR
- StgTSOParInfo par;
+ StgTSOParInfo par;
#endif
#ifdef GRAN
- StgTSOGranInfo gran;
+ StgTSOGranInfo gran;
#endif
#ifdef DIST
- StgTSODistInfo dist;
+ StgTSODistInfo dist;
#endif
- /* The thread stack... */
- StgWord stack_size; /* stack size in *words* */
- StgWord max_stack_size; /* maximum stack size in *words* */
- StgPtr sp;
-
- StgWord stack[FLEXIBLE_ARRAY];
+ /* The thread stack... */
+ StgWord32 stack_size; /* stack size in *words* */
+ StgWord32 max_stack_size; /* maximum stack size in *words* */
+ StgPtr sp;
+
+ StgWord stack[FLEXIBLE_ARRAY];
} StgTSO;
/* -----------------------------------------------------------------------------
BlockedOnBlackHole the BLACKHOLE_BQ the BLACKHOLE_BQ's queue
BlockedOnMVar the MVAR the MVAR's queue
+
+ BlockedOnSTM END_TSO_QUEUE STM wait queue(s)
BlockedOnException the TSO TSO->blocked_exception
/* this is the NIL ptr for a TSO queue (e.g. runnable queue) */
+#if IN_STG_CODE
+#define END_TSO_QUEUE (stg_END_TSO_QUEUE_closure)
+#else
#define END_TSO_QUEUE ((StgTSO *)(void*)&stg_END_TSO_QUEUE_closure)
+#endif
#if defined(PAR) || defined(GRAN)
/* this is the NIL ptr for a blocking queue */