diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-04-11 11:05:36 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-04-11 11:05:36 +0200 |
| commit | 3b9feeed120af45a2dc346592b328eb0b2e14911 (patch) | |
| tree | 805803a23c6e2e91fc002b8b8f1b2d9f73a1e298 /src/libtools/threads.c | |
| parent | 6d3ca2df80b6df2e9aabb73210f9c09fd0df97a1 (diff) | |
| download | box64-3b9feeed120af45a2dc346592b328eb0b2e14911.tar.gz box64-3b9feeed120af45a2dc346592b328eb0b2e14911.zip | |
Improvement in internal mutex handling on signal, and [DYNAREC] multitasking changes to the JmpTable
Diffstat (limited to 'src/libtools/threads.c')
| -rwxr-xr-x | src/libtools/threads.c | 29 |
1 files changed, 13 insertions, 16 deletions
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; +} |