a029f0de5d
Signed-off-by: Chloe M <chloe@mensia.org>
56 lines
1.3 KiB
C
56 lines
1.3 KiB
C
/*
|
|
* Copyright (c) 2026, Chloe M.
|
|
* Provided under the BSD-3 clause.
|
|
*
|
|
* Description: Scheduler management
|
|
* Author: Chloe M.
|
|
*/
|
|
|
|
#ifndef _KE_SCHED_H_
|
|
#define _KE_SCHED_H_ 1
|
|
|
|
#include <ps/thread.h>
|
|
#include <ke/spinlock.h>
|
|
#include <ptdef.h>
|
|
#include <queue.h>
|
|
|
|
/* Minimum scheduler quantum in microseconds */
|
|
#define SCHED_MIN_QUANTUM 900
|
|
|
|
/*
|
|
* Represents a scheduler queue that threads can be pulled
|
|
* from and added to.
|
|
*
|
|
* @ThreadQueue: Represents the actual queue that holds threads
|
|
* @QueueEntries: Represents the number of entries in the queue
|
|
* @Lock: Lock protecting this queue
|
|
*/
|
|
typedef struct {
|
|
TAILQ_HEAD(, _THREAD) ThreadQueue;
|
|
USIZE QueueEntries;
|
|
SPINLOCK Lock;
|
|
} SCHED_QUEUE;
|
|
|
|
/* Macro used to initialize the scheduler queue */
|
|
#define SCHED_QUEUE_INIT(SQ_P) \
|
|
TAILQ_INIT(&(SQ_P)->ThreadQueue); \
|
|
(SQ_P)->QueueEntries = 0; \
|
|
KeSpinLockInit(&(SQ_P)->Lock, "sched");
|
|
|
|
/*
|
|
* Enqueue a thread to a scheduler queue
|
|
*
|
|
* @Queue: Scheduler queue to add to
|
|
* @Thread: Thread to enqueue
|
|
*/
|
|
VOID KeSchedEnqueue(SCHED_QUEUE *Queue, THREAD *Thread);
|
|
|
|
/*
|
|
* Dequeue a thread from a scheduler queue
|
|
*
|
|
* @Queue: Scheduler queue to dequeue from
|
|
*/
|
|
THREAD *KeSchedDequeue(SCHED_QUEUE *Queue);
|
|
|
|
#endif /* !_KE_SCHED_H_ */
|