diff options
Diffstat (limited to 'kernel/sys')
-rw-r--r-- | kernel/sys/core.c | 4 | ||||
-rw-r--r-- | kernel/sys/schedule.c | 22 |
2 files changed, 17 insertions, 9 deletions
diff --git a/kernel/sys/core.c b/kernel/sys/core.c index 4812b00..c06ed4b 100644 --- a/kernel/sys/core.c +++ b/kernel/sys/core.c @@ -10,6 +10,7 @@ #include <sys/core.h> #include <sys/power.h> #include <sys/schedule.h> +#include <tests/test.h> #include <usr/main.h> #include <util/mutex.h> #include <util/status.h> @@ -39,5 +40,6 @@ void sysinit(void) // Start Scheduler init_scheduler(); - add_thread(main, 0, 0); + add_thread(test_entry, 0, 2); + //add_thread(main, 0, 0); } diff --git a/kernel/sys/schedule.c b/kernel/sys/schedule.c index 9b6d46e..3157c5d 100644 --- a/kernel/sys/schedule.c +++ b/kernel/sys/schedule.c @@ -418,12 +418,12 @@ void sched_semaphore_yield(void* s) push_thread_to_queue(rt->value, THREAD_SWAIT, priority); } -void sched_mutex_resurrect(void* m) +unsigned long sched_mutex_resurrect(void* m) { // Find any mutex to resurrect struct Entry* prev = find_mutex_wait_next(m); if (prev == 0) - return; + return 0; struct Entry* entry = prev->next; struct Thread* thread = entry->value; // Resurrect the thread @@ -431,7 +431,7 @@ void sched_mutex_resurrect(void* m) // Remove from wait queue entry = remove_next_from_queue(prev); if (entry == 0) - return; + return 1; // Add to ready queue push_thread_to_queue(entry->value, THREAD_READY, ((struct Thread*)entry->value)->priority); // Demote current thread @@ -445,15 +445,19 @@ void sched_mutex_resurrect(void* m) ((struct Thread*)tentry->value)->old_priority = 0xFF; prepend_thread_to_queue(tentry->value, THREAD_READY, op); } + return 1; } -void sched_semaphore_resurrect(void* s, unsigned long count) +unsigned long sched_semaphore_resurrect(void* s, unsigned long count) { - while (count--) { + unsigned long cnt = count; + while (cnt) { // Find any signal/ semaphore to resurrect struct Entry* prev = find_signal_wait_next(s); - if (prev == 0) - return; + if (prev == 0 && count == cnt) + return 0; + else if (prev == 0) + return 1; struct Entry* entry = prev->next; struct Thread* thread = entry->value; // Resurrect the thread @@ -461,8 +465,10 @@ void sched_semaphore_resurrect(void* s, unsigned long count) // Remove from wait queue entry = remove_next_from_queue(prev); if (entry == 0) - return; + return 1; // Add to ready queue push_thread_to_queue(entry->value, THREAD_READY, ((struct Thread*)entry->value)->priority); + cnt--; } + return 1; } |