333 |
|
pthread_mutex_unlock(&idle_lock); |
334 |
|
#else |
335 |
|
#ifdef IDLE_USES_SEMAPHORE |
336 |
+ |
LOCK_IDLE; |
337 |
|
if (idle_sem_ok < 0) |
338 |
|
idle_sem_ok = (sem_init(&idle_sem, 0, 0) == 0); |
339 |
|
if (idle_sem_ok > 0) { |
339 |
– |
LOCK_IDLE; |
340 |
|
idle_sem_ok++; |
341 |
|
UNLOCK_IDLE; |
342 |
|
sem_wait(&idle_sem); |
343 |
|
return; |
344 |
|
} |
345 |
+ |
UNLOCK_IDLE; |
346 |
|
#endif |
347 |
+ |
|
348 |
+ |
// Fallback: sleep 10 ms |
349 |
|
Delay_usec(10000); |
350 |
|
#endif |
351 |
|
} |
361 |
|
pthread_cond_signal(&idle_cond); |
362 |
|
#else |
363 |
|
#ifdef IDLE_USES_SEMAPHORE |
364 |
+ |
LOCK_IDLE; |
365 |
|
if (idle_sem_ok > 1) { |
362 |
– |
LOCK_IDLE; |
366 |
|
idle_sem_ok--; |
367 |
|
UNLOCK_IDLE; |
368 |
|
sem_post(&idle_sem); |
369 |
|
return; |
370 |
|
} |
371 |
+ |
UNLOCK_IDLE; |
372 |
|
#endif |
373 |
|
#endif |
374 |
|
} |