From 0e6cb270e73977847ba26b132c6b659040aaa342 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Tue, 22 Mar 2022 13:40:21 -0700 Subject: Multiple semaphore increment --- src/sys/schedule.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'src/sys') diff --git a/src/sys/schedule.c b/src/sys/schedule.c index 42a95b0..f54811d 100644 --- a/src/sys/schedule.c +++ b/src/sys/schedule.c @@ -447,20 +447,22 @@ void sched_mutex_resurrect(void* m) } } -void sched_semaphore_resurrect(void* s) +void sched_semaphore_resurrect(void* s, unsigned long count) { - // Find any signal/ semaphore to resurrect - struct Entry* prev = find_signal_wait_next(s); - if (prev == 0) - return; - struct Entry* entry = prev->next; - struct Thread* thread = entry->value; - // Resurrect the thread - thread->mptr = 0; - // Remove from wait queue - entry = remove_next_from_queue(prev); - if (entry == 0) - return; - // Add to ready queue - push_thread_to_queue(entry->value, THREAD_READY, ((struct Thread*)entry->value)->priority); + while (count--) { + // Find any signal/ semaphore to resurrect + struct Entry* prev = find_signal_wait_next(s); + if (prev == 0) + return; + struct Entry* entry = prev->next; + struct Thread* thread = entry->value; + // Resurrect the thread + thread->mptr = 0; + // Remove from wait queue + entry = remove_next_from_queue(prev); + if (entry == 0) + return; + // Add to ready queue + push_thread_to_queue(entry->value, THREAD_READY, ((struct Thread*)entry->value)->priority); + } } -- cgit v1.2.1