threads: reschedule conditionally in thread*Yield
@@ -1144,23 +1144,37 @@ void proc_threadBroadcast(thread_t **queue)
void proc_threadWakeupYield(thread_t **queue)
{
hal_spinlockSet(&threads_common.spinlock);
- if (*queue != NULL && *queue != (void *)(-1))
+ if (*queue != NULL && *queue != (void *)(-1)) {
_proc_threadWakeup(queue);
- else
- (*queue) = (void *)(-1);
hal_cpuReschedule(&threads_common.spinlock);
+ }
+ else {
+ (*queue) = (void *)(-1);
+ hal_spinlockClear(&threads_common.spinlock);
+ }
return;
}
void proc_threadBroadcastYield(thread_t **queue)
{
+ int yield = 0;
+
hal_spinlockSet(&threads_common.spinlock);
- if (*queue != (void *)-1) {
+ if (*queue != (void *)-1 && *queue != NULL) {
+ yield = 1;
while (*queue != NULL)
_proc_threadWakeup(queue);
}
+ else {
+ *queue = (void *)(-1);
+ }
+
+ if (yield)
hal_cpuReschedule(&threads_common.spinlock);
+ else
+ hal_spinlockClear(&threads_common.spinlock);
+
return;
}
