From 123cfd17bf8d876a738fe80636c525c25e309991 Mon Sep 17 00:00:00 2001 From: KN Date: Wed, 14 Jan 2026 19:13:56 +0100 Subject: [PATCH] fix(kernel:sched): add fallback to first thread in runqueue --- README.md | 2 +- src/kernel/sched/sched.c | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c53f961eb..8b589af15 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Will this project ever reach its goals? Probably not, but that's not the point. ## Notable Future Plans -- File servers (FUSE, 9P?). +- Implement 9P file servers. <-- Currently being worked on. - Implement user system in user-space using namespaces. - Improve `share()` and `claim()` security by specifying a target PID when sharing. - Overhaul Desktop Window Manager to use the new security system and file servers? diff --git a/src/kernel/sched/sched.c b/src/kernel/sched/sched.c index 7e5f3ee20..dd45cb1c8 100644 --- a/src/kernel/sched/sched.c +++ b/src/kernel/sched/sched.c @@ -327,15 +327,19 @@ static thread_t* sched_first_eligible(sched_t* sched) current = current->children[RBNODE_RIGHT]; } -#ifndef NDEBUG if (!rbtree_is_empty(&sched->runqueue)) { +#ifndef NDEBUG vclock_t vminEligible = CONTAINER_OF_SAFE(rbtree_find_min(sched->runqueue.root), sched_client_t, node)->vminEligible; panic(NULL, "No eligible threads found, vminEligible=%lld vtime=%lld", SCHED_FIXED_FROM(vminEligible), SCHED_FIXED_FROM(sched->vtime)); - } +#else + LOG_WARN("No eligible threads found, falling back to first thread in runqueue\n"); + sched_client_t* first = CONTAINER_OF(rbtree_find_min(sched->runqueue.root), sched_client_t, node); + return CONTAINER_OF(first, thread_t, sched); #endif + } thread_t* victim = sched_steal(); if (victim != NULL)