334#define SCHED_FIXED_POINT (63LL)
339#define SCHED_FIXED_ZERO ((int128_t)0)
344#define SCHED_EPSILON (10LL)
349#define SCHED_FIXED_TO(x) (((int128_t)(x)) << SCHED_FIXED_POINT)
354#define SCHED_FIXED_FROM(x) ((int64_t)((int128_t)(x) >> SCHED_FIXED_POINT))
359#define SCHED_WEIGHT_MAX (PRIORITY_MAX + SCHED_WEIGHT_BASE)
366#define SCHED_WEIGHT_BASE 1
374typedef struct sched_client
483#define SCHED_SCOPE() \
485 __attribute__((cleanup(sched_scope_cleanup))) int* CONCAT(i, __COUNTER__) = 0
#define PERCPU
Attribute specifying that the variable is an offset into the GS segment register.
void sched_disable(void)
Disables preemption on the current CPU.
void sched_client_init(sched_client_t *client)
Initialize the scheduler context for a thread.
static void sched_scope_cleanup(int *_)
void sched_enable(void)
Enables preemption on the current CPU.
sched_t PERCPU _pcpu_sched
The per CPU scheduler.
int128_t vclock_t
Virtual clock type.
_NORETURN void sched_start(thread_t *bootThread)
Starts the scheduler by jumping to the boot thread.
void sched_yield(void)
Yield the current thread's time slice to allow other threads to run.
_NORETURN void sched_exits(const char *status)
Terminates the currently executing process and all it's threads.
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.
void sched_do(interrupt_frame_t *frame)
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.
_Atomic(uint64_t) preemptCount
If greater than zero, preemption is disabled.
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.