proc/threads: avoid spin locking in idle thread if there is no work to do
@@ -1023,6 +1023,8 @@ static void threads_idlethr(void *arg)
process_t *zombie;
for (;;) {
+ /* Don't grab spinlocks unless there is something to clean up */
+ if (threads_common.ghosts != NULL) {
do {
hal_spinlockSet(&threads_common.spinlock);
if ((ghost = threads_common.ghosts) != NULL)
@@ -1033,7 +1035,9 @@ static void threads_idlethr(void *arg)
proc_cleanupGhost(ghost);
}
while (ghost != NULL);
+ }
+ if (threads_common.zombies != NULL) {
do {
hal_spinlockSet(&threads_common.spinlock);
if ((zombie = threads_common.zombies) != NULL && zombie->threads == NULL && zombie->ports == NULL)
@@ -1046,6 +1050,7 @@ static void threads_idlethr(void *arg)
proc_cleanupZombie(zombie);
}
while (zombie != NULL);
+ }
wakeup = proc_nextWakeup();
