diff options
author | rpj <rpj> | 2011-03-24 23:33:14 +0000 |
---|---|---|
committer | rpj <rpj> | 2011-03-24 23:33:14 +0000 |
commit | db171f2f9435b98f05f33fcbc0dcf0c5cc1cb917 (patch) | |
tree | 9d617a20a9e0ad1fcf415e353057c53e6d77d0f3 /ptw32_threadStart.c | |
parent | e5229a33f8724a90cbb0b56c3ecc1d6691bf54d7 (diff) |
First pass of robust mutexes
Diffstat (limited to 'ptw32_threadStart.c')
-rw-r--r-- | ptw32_threadStart.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/ptw32_threadStart.c b/ptw32_threadStart.c index c485d16..5c354d4 100644 --- a/ptw32_threadStart.c +++ b/ptw32_threadStart.c @@ -69,7 +69,6 @@ ExceptionFilter (EXCEPTION_POINTERS * ep, DWORD * ei) */ pthread_t self = pthread_self (); - (void) pthread_mutex_destroy (&((ptw32_thread_t *)self.p)->cancelLock); ptw32_callUserDestroyRoutines (self); return EXCEPTION_CONTINUE_SEARCH; @@ -139,6 +138,7 @@ ptw32_threadStart (void *vthreadParms) int setjmp_rc; #endif + ptw32_mcs_local_node_t stateLock; void * status = (void *) 0; self = threadParms->tid; @@ -155,19 +155,19 @@ ptw32_threadStart (void *vthreadParms) */ sp->thread = GetCurrentThreadId (); /* - * Here we're using cancelLock as a general-purpose lock + * Here we're using stateLock as a general-purpose lock * to make the new thread wait until the creating thread * has the new handle. */ - if (pthread_mutex_lock (&sp->cancelLock) == 0) - { - (void) pthread_mutex_unlock (&sp->cancelLock); - } -#endif - + ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); pthread_setspecific (ptw32_selfThreadKey, sp); +#else + pthread_setspecific (ptw32_selfThreadKey, sp); + ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock); +#endif sp->state = PThreadStateRunning; + ptw32_mcs_lock_release (&stateLock); #ifdef __CLEANUP_SEH @@ -177,6 +177,7 @@ ptw32_threadStart (void *vthreadParms) * Run the caller's routine; */ status = sp->exitStatus = (*start) (arg); + sp->state = PThreadStateExiting; #ifdef _UWIN if (--pthread_count <= 0) @@ -217,6 +218,7 @@ ptw32_threadStart (void *vthreadParms) * Run the caller's routine; */ status = sp->exitStatus = (*start) (arg); + sp->state = PThreadStateExiting; } else { @@ -250,6 +252,7 @@ ptw32_threadStart (void *vthreadParms) try { status = sp->exitStatus = (*start) (arg); + sp->state = PThreadStateExiting; } catch (ptw32_exception &) { |