329#define SCHED_FIXED_POINT (63LL)
334#define SCHED_FIXED_ZERO ((int128_t)0)
339#define SCHED_EPSILON (10LL)
344#define SCHED_FIXED_TO(x) (((int128_t)(x)) << SCHED_FIXED_POINT)
349#define SCHED_FIXED_FROM(x) ((int64_t)((int128_t)(x) >> SCHED_FIXED_POINT))
354#define SCHED_WEIGHT_MAX (PRIORITY_MAX + SCHED_WEIGHT_BASE)
361#define SCHED_WEIGHT_BASE 1
369typedef struct sched_client
_NORETURN void sched_process_exit(int32_t status)
Terminates the currently executing process and all it's threads.
void sched_init(sched_t *sched)
Initialize the scheduler for a CPU.
process_t * sched_process(void)
Retrieves the process of the currently running thread.
void sched_client_init(sched_client_t *client)
Initialize the scheduler context for a thread.
int128_t vclock_t
Virtual clock type.
_NORETURN void sched_start(thread_t *bootThread)
Starts the scheduler by jumping to the boot thread.
thread_t * sched_thread(void)
Retrieves the currently running thread.
void sched_yield(void)
Yield the current thread's time slice to allow other threads to run.
thread_t * sched_thread_unsafe(void)
Retrieves the currently running thread without disabling interrupts.
bool sched_is_idle(cpu_t *cpu)
Checks if the CPU is currently idle.
void sched_submit(thread_t *thread)
Submits a thread to the scheduler.
_NORETURN void sched_idle_loop(void)
The idle loop for the scheduler.
uint64_t sched_nanosleep(clock_t timeout)
Sleeps the current thread for a specified duration in nanoseconds.
process_t * sched_process_unsafe(void)
Retrieves the process of the currently running thread without disabling interrupts.
void sched_do(interrupt_frame_t *frame, cpu_t *self)
Perform a scheduling operation.
_NORETURN void sched_thread_exit(void)
Terminates the currently executing thread.
__UINT64_TYPE__ clock_t
A nanosecond time.
A simple ticket lock implementation.
Per-thread scheduler context.
clock_t stop
The real time when the thread previously stopped executing.
vclock_t veligible
The virtual time at which the thread becomes eligible to run (lag >= 0).
vclock_t vminEligible
The minimum virtual eligible time of the subtree in the runqueue.
rbnode_t node
The node in the scheduler's runqueue.
cpu_t * lastCpu
The last CPU the thread was scheduled on, it stoped running at stop time.
int64_t weight
The weight of the thread.
vclock_t vtime
The current virtual time of the CPU.
lock_t lock
The lock protecting the scheduler.
clock_t lastUpdate
The real time when the last vtime update occurred.
thread_t *volatile runThread
The currently running thread on this CPU.
rbtree_t runqueue
Contains all runnable threads, including the currently running thread, sorted by vdeadline.
_Atomic(int64_t) totalWeight
The total weight of all threads in the runqueue, not protected by the lock.
thread_t *volatile idleThread
The idle thread for this CPU.
Thread of execution structure.