mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-02 07:28:21 +00:00
scheduler: fix issue with threads being lost
This commit is contained in:
@@ -114,6 +114,7 @@ void semaphore_signal(semaphore_t *sem) {
|
|||||||
// wake SOMEONE up. this will *try* to wake up a thread
|
// wake SOMEONE up. this will *try* to wake up a thread
|
||||||
// it could wake up none though, as a thread could have been interrupted by a signal
|
// it could wake up none though, as a thread could have been interrupted by a signal
|
||||||
thread = get(sem);
|
thread = get(sem);
|
||||||
|
// TODO this is broken
|
||||||
// XXX the current method doesn't respect thread priorities
|
// XXX the current method doesn't respect thread priorities
|
||||||
if (thread) {
|
if (thread) {
|
||||||
sched_wakeup(thread, 0);
|
sched_wakeup(thread, 0);
|
||||||
|
|||||||
@@ -546,7 +546,11 @@ static void yield(context_t *context, void *) {
|
|||||||
|
|
||||||
if (sleeping && (thread->shouldexit || gotsignal) && (thread->flags & SCHED_THREAD_FLAGS_INTERRUPTIBLE)) {
|
if (sleeping && (thread->shouldexit || gotsignal) && (thread->flags & SCHED_THREAD_FLAGS_INTERRUPTIBLE)) {
|
||||||
sleeping = false;
|
sleeping = false;
|
||||||
|
|
||||||
|
if (next)
|
||||||
|
runqueueinsert(next);
|
||||||
next = NULL;
|
next = NULL;
|
||||||
|
|
||||||
thread->flags &= ~(SCHED_THREAD_FLAGS_SLEEP | SCHED_THREAD_FLAGS_INTERRUPTIBLE);
|
thread->flags &= ~(SCHED_THREAD_FLAGS_SLEEP | SCHED_THREAD_FLAGS_INTERRUPTIBLE);
|
||||||
thread->wakeupreason = SCHED_WAKEUP_REASON_INTERRUPTED;
|
thread->wakeupreason = SCHED_WAKEUP_REASON_INTERRUPTED;
|
||||||
spinlock_release(&thread->sleeplock);
|
spinlock_release(&thread->sleeplock);
|
||||||
|
|||||||
Reference in New Issue
Block a user