mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-01-12 01:30:03 +00:00
improve locks
This commit is contained in:
parent
f853ce6c5b
commit
daa0af4da6
@ -333,16 +333,19 @@ void idle_wait(void)
|
||||
pthread_mutex_unlock(&idle_lock);
|
||||
#else
|
||||
#ifdef IDLE_USES_SEMAPHORE
|
||||
LOCK_IDLE;
|
||||
if (idle_sem_ok < 0)
|
||||
idle_sem_ok = (sem_init(&idle_sem, 0, 0) == 0);
|
||||
if (idle_sem_ok > 0) {
|
||||
LOCK_IDLE;
|
||||
idle_sem_ok++;
|
||||
UNLOCK_IDLE;
|
||||
sem_wait(&idle_sem);
|
||||
return;
|
||||
}
|
||||
UNLOCK_IDLE;
|
||||
#endif
|
||||
|
||||
// Fallback: sleep 10 ms
|
||||
Delay_usec(10000);
|
||||
#endif
|
||||
}
|
||||
@ -358,13 +361,14 @@ void idle_resume(void)
|
||||
pthread_cond_signal(&idle_cond);
|
||||
#else
|
||||
#ifdef IDLE_USES_SEMAPHORE
|
||||
LOCK_IDLE;
|
||||
if (idle_sem_ok > 1) {
|
||||
LOCK_IDLE;
|
||||
idle_sem_ok--;
|
||||
UNLOCK_IDLE;
|
||||
sem_post(&idle_sem);
|
||||
return;
|
||||
}
|
||||
UNLOCK_IDLE;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user