mirror of https://github.com/PCSX2/pcsx2.git
w32pthreads: bugfix for minor race condition on exiting threads. Tech details: the testcancel flag was being incremented after the thread had already canceled, leaving the flag "dangling".
PCSX2: attempt at fixing what appears to be a belated thread affinity issue during the cpuspeed detect. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2363 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
bb319266fc
commit
84c7436d34
|
@ -83,8 +83,7 @@ DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
|
|||
(void) pthread_win32_thread_detach_np ();
|
||||
result = pthread_win32_process_detach_np ();
|
||||
|
||||
if( ptw32_testcancel_enable != 0 )
|
||||
assert(0);
|
||||
assert(ptw32_testcancel_enable == 0);
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -46,15 +46,26 @@ static void
|
|||
_cleanup_testcancel_optimization( void* specific )
|
||||
{
|
||||
ptw32_thread_t * sp = (ptw32_thread_t*)specific; //(ptw32_thread_t *)pthread_getspecific (ptw32_selfThreadKey);
|
||||
if( (sp != NULL) &&
|
||||
(sp->cancelType == PTHREAD_CANCEL_DEFERRED) &&
|
||||
(sp->state >= PThreadStateCancelPending)
|
||||
)
|
||||
if( (sp != NULL) )
|
||||
{
|
||||
assert( ptw32_testcancel_enable > 0 );
|
||||
pthread_mutex_lock (&sp->cancelLock);
|
||||
if( (sp->cancelType == PTHREAD_CANCEL_DEFERRED) && (sp->state == PThreadStateCancelPending) )
|
||||
{
|
||||
int result = _InterlockedDecrement( &ptw32_testcancel_enable );
|
||||
assert( result >= 0 );
|
||||
sp->state = PThreadStateCanceling;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We need to prevent other threads, which may try to cancel this thread
|
||||
// in parallel to it's cancellation here, from incrementing the cancel_enable flag.
|
||||
// (and without clobbering the StateException, if that's already been set)
|
||||
|
||||
if( ptw32_testcancel_enable > 0 )
|
||||
(void) _InterlockedDecrement( &ptw32_testcancel_enable );
|
||||
if( sp->state < PThreadStateCanceling )
|
||||
sp->state = PThreadStateCanceling;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock (&sp->cancelLock);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,6 +87,9 @@ SingleCoreAffinity::SingleCoreAffinity()
|
|||
availProcCpus, availSysCpus, i
|
||||
);
|
||||
}
|
||||
|
||||
// Force Windows to timeslice (hoping this fixes some affinity issues)
|
||||
Sleep( 2 );
|
||||
};
|
||||
|
||||
SingleCoreAffinity::~SingleCoreAffinity() throw()
|
||||
|
|
Loading…
Reference in New Issue