summaryrefslogtreecommitdiff
path: root/thread.h
diff options
context:
space:
mode:
authorMalcolm Beattie <mbeattie@sable.ox.ac.uk>1997-10-15 09:09:24 +0000
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>1997-10-15 09:09:24 +0000
commit605e5515a799a08f29f3263d09d5215322548dc9 (patch)
treea2de87e35475866b58db5cf605f0cf956adc1902 /thread.h
parent33f46ff65e5d2230d8bd00503ede2b051af73672 (diff)
downloadperl-605e5515a799a08f29f3263d09d5215322548dc9.tar.gz
Started rewriting thread state machine.
p4raw-id: //depot/perl@125
Diffstat (limited to 'thread.h')
-rw-r--r--thread.h26
1 files changed, 14 insertions, 12 deletions
diff --git a/thread.h b/thread.h
index f379f6bf3d..4bea061548 100644
--- a/thread.h
+++ b/thread.h
@@ -159,9 +159,9 @@ struct thread {
perl_thread Tself;
SV * Toursv;
- perl_mutex *Tthreadstart_mutexp;
HV * Tcvcache;
U32 flags;
+ perl_mutex mutex;
U32 tid;
struct thread *next, *prev; /* Circular linked list of threads */
@@ -176,20 +176,23 @@ struct thread {
typedef struct thread *Thread;
/* Values and macros for thr->flags */
-#define THRf_STATE_MASK 3
-#define THRf_NORMAL 0
-#define THRf_DETACHED 1
-#define THRf_JOINED 2
-#define THRf_DEAD 3
+#define THRf_STATE_MASK 7
+#define THRf_R_JOINABLE 0
+#define THRf_R_JOINED 1
+#define THRf_R_DETACHED 2
+#define THRf_ZOMBIE 3
+#define THRf_DEAD 4
-#define THRf_DIE_FATAL 4
+#define THRf_DIE_FATAL 8
-#define ThrSTATE(t) (t->flags & THRf_STATE_MASK)
+#define ThrSTATE(t) ((t)->flags)
#define ThrSETSTATE(t, s) STMT_START { \
- (t)->flags &= ~THRf_STATE_MASK; \
+ MUTEX_LOCK(&(t)->mutex); \
+ (t)->flags &= ~THRf_STATE_MASK; \
(t)->flags |= (s); \
- DEBUG_L(fprintf(stderr, "thread 0x%lx set to state %d\n", \
- (unsigned long)(t), (s))); \
+ MUTEX_UNLOCK(&(t)->mutex); \
+ DEBUG_L(PerlIO_printf(PerlIO_stderr(), \
+ "thread %p set to state %d\n", (t), (s))); \
} STMT_END
typedef struct condpair {
@@ -300,6 +303,5 @@ typedef struct condpair {
#define top_env (thr->Ttop_env)
#define runlevel (thr->Trunlevel)
-#define threadstart_mutexp (thr->Tthreadstart_mutexp)
#define cvcache (thr->Tcvcache)
#endif /* USE_THREADS */