summaryrefslogtreecommitdiff
path: root/sys/kern/kern_sched.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-06-09 01:51:53 -0400
committerIan Moffett <ian@osmora.org>2025-06-09 01:51:53 -0400
commitb27538ea39d8065eb26f36853fc5d1fa24a126b3 (patch)
tree534f4b5b07f6a5fa76f3dfb631314f9e842ab137 /sys/kern/kern_sched.c
parenta4157b86463951b4eb6f6b9747b306c539dbde3d (diff)
kernel: sched: Skip sleeping threads and get next
If a thread is sleeping, skip it and try the next thread. Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/kern/kern_sched.c')
-rw-r--r--sys/kern/kern_sched.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c
index 8a2a40f..d656f94 100644
--- a/sys/kern/kern_sched.c
+++ b/sys/kern/kern_sched.c
@@ -113,11 +113,18 @@ sched_dequeue_td(void)
continue;
}
- TAILQ_REMOVE(&queue->q, td, link);
- if (ISSET(td->flags, PROC_SLEEP)) {
+ while (ISSET(td->flags, PROC_SLEEP)) {
+ td = TAILQ_NEXT(td, link);
+ if (td == NULL) {
+ break;
+ }
+ }
+
+ if (td == NULL) {
continue;
}
+ TAILQ_REMOVE(&queue->q, td, link);
spinlock_release(&tdq_lock);
return td;
}