PatchworkOS  da8a090
A non-POSIX operating system.
Loading...
Searching...
No Matches
sched.h File Reference
#include <kernel/defs.h>
#include <kernel/sched/wait.h>
#include <kernel/sync/lock.h>
#include <kernel/utils/rbtree.h>
#include <sys/list.h>
#include <sys/proc.h>
Include dependency graph for sched.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  sched_client_t
 Per-thread scheduler context. More...
 
struct  sched_t
 Per-CPU scheduler. More...
 

Macros

#define SCHED_FIXED_POINT   (63LL)
 The bits used for the fractional part of a virtual clock or lag value.
 
#define SCHED_FIXED_ZERO   ((int128_t)0)
 Fixed-point zero.
 
#define SCHED_EPSILON   (10LL)
 The minimum difference between two virtual clock or lag values to consider then unequal.
 
#define SCHED_FIXED_TO(x)   (((int128_t)(x)) << SCHED_FIXED_POINT)
 Convert a regular integer to fixed-point representation.
 
#define SCHED_FIXED_FROM(x)   ((int64_t)((int128_t)(x) >> SCHED_FIXED_POINT))
 Convert a fixed-point value to a regular integer.
 
#define SCHED_WEIGHT_MAX   (PRIORITY_MAX + SCHED_WEIGHT_BASE)
 The maximum weight a thread can have.
 
#define SCHED_WEIGHT_BASE   1
 Base weight added to all threads.
 

Typedefs

typedef struct process process_t
 
typedef struct thread thread_t
 
typedef struct sched sched_t
 
typedef int128_t vclock_t
 Virtual clock type.
 
typedef int128_t lag_t
 

Functions

void sched_client_init (sched_client_t *client)
 Initialize the scheduler context for a thread.
 
void sched_init (sched_t *sched)
 Initialize the scheduler for a CPU.
 
_NORETURN void sched_start (thread_t *bootThread)
 Starts the scheduler by jumping to the boot thread.
 
void sched_submit (thread_t *thread)
 Submits a thread to the scheduler.
 
void sched_do (interrupt_frame_t *frame, cpu_t *self)
 Perform a scheduling operation.
 
bool sched_is_idle (cpu_t *cpu)
 Checks if the CPU is currently idle.
 
thread_tsched_thread (void)
 Retrieves the currently running thread.
 
process_tsched_process (void)
 Retrieves the process of the currently running thread.
 
thread_tsched_thread_unsafe (void)
 Retrieves the currently running thread without disabling interrupts.
 
process_tsched_process_unsafe (void)
 Retrieves the process of the currently running thread without disabling interrupts.
 
uint64_t sched_nanosleep (clock_t timeout)
 Sleeps the current thread for a specified duration in nanoseconds.
 
void sched_yield (void)
 Yield the current thread's time slice to allow other threads to run.
 
_NORETURN void sched_process_exit (int32_t status)
 Terminates the currently executing process and all it's threads.
 
_NORETURN void sched_thread_exit (void)
 Terminates the currently executing thread.
 
_NORETURN void sched_idle_loop (void)
 The idle loop for the scheduler.
 

Typedef Documentation

◆ process_t

typedef struct process process_t

Definition at line 11 of file sched.h.

◆ thread_t

typedef struct thread thread_t

Definition at line 12 of file sched.h.

◆ sched_t

typedef struct sched sched_t

Definition at line 14 of file sched.h.