From 3b9feeed120af45a2dc346592b328eb0b2e14911 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sun, 11 Apr 2021 11:05:36 +0200 Subject: Improvement in internal mutex handling on signal, and [DYNAREC] multitasking changes to the JmpTable --- src/libtools/threads.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'src/libtools/threads.c') diff --git a/src/libtools/threads.c b/src/libtools/threads.c index 82f558f4..5e969807 100755 --- a/src/libtools/threads.c +++ b/src/libtools/threads.c @@ -922,21 +922,6 @@ emu_jmpbuf_t* GetJmpBuf() return ejb; } -static void atfork_child(void) -{ - //unlock all potential mutex, this is a new fork! - pthread_mutex_unlock(&my_context->mutex_once); - pthread_mutex_unlock(&my_context->mutex_once2); - pthread_mutex_unlock(&my_context->mutex_trace); - #ifndef DYNAREC - pthread_mutex_unlock(&my_context->mutex_lock); - #else - pthread_mutex_unlock(&my_context->mutex_dyndump); - #endif - pthread_mutex_unlock(&my_context->mutex_tls); - pthread_mutex_unlock(&my_context->mutex_thread); -} - void init_pthread_helper() { InitCancelThread(); @@ -949,7 +934,6 @@ void init_pthread_helper() unaligned_mutex = kh_init(mutex); #endif #endif - pthread_atfork(NULL, NULL, atfork_child); } void fini_pthread_helper(box64context_t* context) @@ -986,3 +970,16 @@ void fini_pthread_helper(box64context_t* context) pthread_setspecific(thread_key, NULL); } } + +int checkMutex(void* m) +{ + pthread_mutex_t* mutex = (pthread_mutex_t*)m; + int ret = pthread_mutex_trylock(mutex); + if(ret==0) { + pthread_mutex_unlock(mutex); + return 0; + } + if(ret==EDEADLK) + return 1; + return 0; +} -- cgit 1.4.1