ptos: sched: Add thread enqueue/dequeue helpers

Signed-off-by: Chloe M <chloe@mensia.org>
This commit is contained in:
2026-07-14 03:07:37 -04:00
parent bc08e8232e
commit e6ac3d0b30
2 changed files with 58 additions and 1 deletions
+38
View File
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2026, Chloe M.
* Provided under the BSD-3 clause.
*
* Description: Scheduler management
* Author: Chloe M.
*/
#include <ke/sched.h>
VOID
KeSchedEnqueue(SCHED_QUEUE *Queue, THREAD *Thread)
{
if (Queue == NULL || Thread == NULL) {
return;
}
KeSpinLockAcquire(&Queue->Lock, true);
TAILQ_INSERT_TAIL(&Queue->ThreadQueue, Thread, ThreadLink);
KeSpinLockRelease(&Queue->Lock);
}
THREAD *
KeSchedDequeue(SCHED_QUEUE *Queue)
{
THREAD *Thread;
KeSpinLockAcquire(&Queue->Lock, true);
if (TAILQ_EMPTY(&Queue->ThreadQueue)) {
KeSpinLockRelease(&Queue->Lock);
return NULL;
}
Thread = TAILQ_FIRST(&Queue->ThreadQueue);
TAILQ_REMOVE(&Queue->ThreadQueue, Thread, ThreadLink);
KeSpinLockRelease(&Queue->Lock);
return Thread;
}