diff --git a/BasiliskII/src/Unix/timer_unix.cpp b/BasiliskII/src/Unix/timer_unix.cpp index 684edec6..cac3d585 100644 --- a/BasiliskII/src/Unix/timer_unix.cpp +++ b/BasiliskII/src/Unix/timer_unix.cpp @@ -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 }