X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fincludes%2FTSO.h;h=d096d401cfecf4fe9defee48ff16d03146c0eb0f;hb=28a464a75e14cece5db40f2765a29348273ff2d2;hp=cf51598e0b23892460bbd23c202cb27b37f8ed8e;hpb=5bcba9677f6d097ecad2034b7bd039d125eaabdc;p=ghc-hetmet.git diff --git a/ghc/includes/TSO.h b/ghc/includes/TSO.h index cf51598..d096d40 100644 --- a/ghc/includes/TSO.h +++ b/ghc/includes/TSO.h @@ -1,5 +1,4 @@ /* ----------------------------------------------------------------------------- - * $Id: TSO.h,v 1.36 2004/08/13 13:57:06 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -10,8 +9,6 @@ #ifndef TSO_H #define TSO_H -#if defined(GRAN) || defined(PAR) - #if DEBUG #define TSO_MAGIC 4321 #endif @@ -34,7 +31,16 @@ typedef struct { StgInt localsparks; rtsTime clock; } StgTSOStatBuf; -#endif + +/* + * GRAN: We distinguish between the various classes of threads in + * the system. + */ +typedef enum { + AdvisoryPriority, + MandatoryPriority, + RevalPriority +} StgThreadPriority; /* * PROFILING info in a TSO @@ -46,60 +52,55 @@ typedef struct { /* * PAR info in a TSO */ -#ifdef PAR typedef StgTSOStatBuf StgTSOParInfo; -#else -#ifdef SUPPORTS_EMPTY_STRUCTS -typedef struct { - /* empty */ -} StgTSOParInfo; -#endif -#endif /* * DIST info in a TSO */ -#ifdef DIST typedef struct { StgThreadPriority priority; StgInt revalTid; /* ToDo: merge both into 1 word */ StgInt revalSlot; } StgTSODistInfo; -#else -#ifdef SUPPORTS_EMPTY_STRUCTS -typedef struct { - /* empty */ -} StgTSODistInfo; -#endif -#endif /* * GRAN info in a TSO */ -#ifdef GRAN typedef StgTSOStatBuf StgTSOGranInfo; -#else -#ifdef SUPPORTS_EMPTY_STRUCTS -typedef struct { - /* empty */ -} StgTSOGranInfo; -#endif -#endif /* - * TICKY_TICKY info in a TSO + * There is no TICKY info in a TSO at this time. */ -#ifdef SUPPORTS_EMPTY_STRUCTS -typedef struct { - /* empty */ -} StgTSOTickyInfo; -#endif /* * Thread IDs are 32 bits. */ 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 + +/* + * TSO_LOCKED is set when a TSO is locked to a particular Capability. + */ +#define TSO_LOCKED 2 + +#define tsoDirty(tso) ((tso)->flags & TSO_DIRTY) +#define tsoLocked(tso) ((tso)->flags & TSO_LOCKED) + /* * Type returned after running a thread. Values of this type * include HeapOverflow, StackOverflow etc. See Constants.h for the @@ -107,18 +108,8 @@ typedef StgWord32 StgThreadID; */ typedef unsigned int StgThreadReturnCode; -/* - * We distinguish between the various classes of threads in the system. - */ - -typedef enum { - AdvisoryPriority, - MandatoryPriority, - RevalPriority -} StgThreadPriority; - -#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; @@ -129,11 +120,11 @@ typedef struct { typedef union { StgClosure *closure; struct StgTSO_ *tso; - int fd; -#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 - unsigned int target; + StgWord target; } StgTSOBlockInfo; /* @@ -150,42 +141,45 @@ typedef union { * 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 - MAYBE_EMPTY_STRUCT(StgTSOTickyInfo,ticky) + /* TICKY-specific stuff would go here. */ #endif #ifdef PROFILING - StgTSOProfInfo prof; + StgTSOProfInfo prof; +#endif +#ifdef PAR + StgTSOParInfo par; +#endif +#ifdef GRAN + StgTSOGranInfo gran; +#endif +#ifdef DIST + StgTSODistInfo dist; #endif - MAYBE_EMPTY_STRUCT(StgTSOParInfo,par); - MAYBE_EMPTY_STRUCT(StgTSOGranInfo,gran); - MAYBE_EMPTY_STRUCT(StgTSODistInfo,dist); - - /* 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; /* ----------------------------------------------------------------------------- @@ -210,6 +204,8 @@ typedef struct 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 @@ -266,7 +262,11 @@ extern StgTSO dummy_tso; /* 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 */