|
PatchworkOS
|
#include <kernel/sched/sched.h>#include <kernel/cpu/cpu.h>#include <kernel/cpu/gdt.h>#include <kernel/cpu/interrupt.h>#include <kernel/cpu/smp.h>#include <kernel/cpu/syscalls.h>#include <kernel/drivers/apic.h>#include <kernel/log/log.h>#include <kernel/log/panic.h>#include <kernel/proc/process.h>#include <kernel/sched/thread.h>#include <kernel/sched/timer.h>#include <kernel/sched/wait.h>#include <kernel/sync/lock.h>#include <assert.h>#include <sys/list.h>#include <sys/math.h>#include <sys/proc.h>Go to the source code of this file.
Functions | |
| static void | sched_queues_init (sched_queues_t *queues) |
| static void | sched_queues_push (sched_queues_t *queues, thread_t *thread) |
| static thread_t * | sched_queues_pop (sched_queues_t *queues, priority_t minPriority) |
| void | sched_thread_ctx_init (sched_thread_ctx_t *ctx) |
| Initializes a thread's scheduling context. | |
| static void | sched_timer_handler (interrupt_frame_t *frame, cpu_t *self) |
| void | sched_cpu_ctx_init (sched_cpu_ctx_t *ctx, cpu_t *self) |
| Initializes a CPU's scheduling context. | |
| void | sched_done_with_boot_thread (void) |
| Specify that the boot thread is no longer needed. | |
| uint64_t | sched_nanosleep (clock_t timeout) |
| Puts the current thread to sleep. | |
| SYSCALL_DEFINE (SYS_NANOSLEEP, uint64_t, clock_t nanoseconds) | |
| bool | sched_is_idle (cpu_t *cpu) |
| Checks if the CPU is idle. | |
| thread_t * | sched_thread (void) |
| Retrieves the currently running thread. | |
| process_t * | sched_process (void) |
| Retrieves the process of the currently running thread. | |
| thread_t * | sched_thread_unsafe (void) |
| Retrieves the currently running thread without disabling interrupts. | |
| process_t * | sched_process_unsafe (void) |
| Retrieves the process of the currently running thread without disabling interrupts. | |
| void | sched_process_exit (uint64_t status) |
| Exits the current process. | |
| SYSCALL_DEFINE (SYS_PROCESS_EXIT, void, uint64_t status) | |
| void | sched_thread_exit (void) |
| Exits the current thread. | |
| SYSCALL_DEFINE (SYS_THREAD_EXIT, void) | |
| static void | sched_update_recent_idle_time (thread_t *thread, bool wasBlocking, clock_t uptime) |
| static void | sched_compute_time_slice (thread_t *thread, thread_t *parent) |
| static void | sched_compute_actual_priority (thread_t *thread) |
| void | sched_yield (void) |
| Yields the CPU to another thread. | |
| SYSCALL_DEFINE (SYS_YIELD, uint64_t) | |
| static bool | sched_should_notify (cpu_t *target, priority_t priority) |
| void | sched_push (thread_t *thread, cpu_t *target) |
| Pushes a thread onto a scheduling queue. | |
| static uint64_t | sched_get_load (sched_cpu_ctx_t *ctx) |
| static cpu_t * | sched_find_least_loaded_cpu (cpu_t *exclude) |
| void | sched_push_new_thread (thread_t *thread, thread_t *parent) |
| Pushes a newly created thread onto the scheduling queue. | |
| static cpu_t * | sched_get_neighbor (cpu_t *self) |
| static void | sched_load_balance (cpu_t *self) |
| void | sched_invoke (interrupt_frame_t *frame, cpu_t *self, schedule_flags_t flags) |
| The main scheduling function. | |
Variables | |
| static wait_queue_t | sleepQueue = WAIT_QUEUE_CREATE(sleepQueue) |
|
static |
Definition at line 258 of file sched.c.
References sched_thread_ctx_t::actualPriority, atomic_load, CONFIG_MAX_PRIORITY_BOOST, CONFIG_MAX_PRIORITY_PENALTY, CONFIG_MAX_RECENT_BLOCK_TIME, LERP_INT, MIN, PRIORITY_MAX, thread_t::process, sched_thread_ctx_t::recentBlockTime, and thread_t::sched.
Referenced by sched_invoke(), sched_push(), and sched_push_new_thread().
Definition at line 239 of file sched.c.
References atomic_load, CONFIG_MAX_TIME_SLICE, CONFIG_MIN_TIME_SLICE, sched_thread_ctx_t::deadline, LERP_INT, NULL, PRIORITY_MAX, PRIORITY_MIN, thread_t::process, thread_t::sched, timer_uptime(), sched_thread_ctx_t::timeSlice, and uptime().
Referenced by sched_invoke(), sched_push(), and sched_push_new_thread().
Definition at line 348 of file sched.c.
References NULL, cpu_t::sched, sched_get_load(), smp_cpu(), smp_cpu_amount(), and UINT64_MAX.
Referenced by sched_push_new_thread().
|
static |
Definition at line 342 of file sched.c.
References sched_cpu_ctx_t::active, sched_cpu_ctx_t::expired, sched_cpu_ctx_t::idleThread, sched_queues_t::length, sched_cpu_ctx_t::lock, LOCK_SCOPE, and sched_cpu_ctx_t::runThread.
Referenced by sched_find_least_loaded_cpu(), and sched_load_balance().
Definition at line 420 of file sched.c.
References cpu_t::id, NULL, smp_cpu(), and smp_cpu_amount().
Referenced by sched_load_balance().
|
static |
Definition at line 431 of file sched.c.
References sched_cpu_ctx_t::active, sched_thread_ctx_t::actualPriority, CONFIG_LOAD_BALANCE_BIAS, sched_cpu_ctx_t::expired, sched_cpu_ctx_t::lock, lock_acquire(), lock_release(), NULL, PRIORITY_MIN, cpu_t::sched, thread_t::sched, sched_get_load(), sched_get_neighbor(), sched_queues_pop(), sched_queues_push(), sched_should_notify(), smp_cpu_amount(), and timer_notify().
Referenced by sched_invoke().
|
inlinestatic |
Definition at line 25 of file sched.c.
References sched_queues_t::bitmap, sched_queues_t::length, list_init(), sched_queues_t::lists, PRIORITY_MAX, and PRIORITY_MIN.
Referenced by sched_cpu_ctx_init().
|
inlinestatic |
Definition at line 44 of file sched.c.
References assert, sched_queues_t::bitmap, CONTAINER_OF, sched_queues_t::length, list_is_empty(), list_pop(), sched_queues_t::lists, NULL, and PRIORITY_MAX.
Referenced by sched_invoke(), and sched_load_balance().
|
inlinestatic |
Definition at line 35 of file sched.c.
References sched_thread_ctx_t::actualPriority, assert, sched_queues_t::bitmap, thread_t::entry, sched_queues_t::length, list_push(), sched_queues_t::lists, PRIORITY_MAX, and thread_t::sched.
Referenced by sched_invoke(), sched_load_balance(), sched_push(), and sched_push_new_thread().
|
static |
Definition at line 291 of file sched.c.
References sched_thread_ctx_t::actualPriority, sched_cpu_ctx_t::idleThread, sched_cpu_ctx_t::runThread, cpu_t::sched, and thread_t::sched.
Referenced by sched_load_balance(), sched_push(), and sched_push_new_thread().
|
static |
Definition at line 78 of file sched.c.
References sched_invoke(), and SCHED_NORMAL.
Referenced by sched_cpu_ctx_init().
|
static |
Definition at line 217 of file sched.c.
References CONFIG_MAX_RECENT_BLOCK_TIME, MIN, sched_thread_ctx_t::prevBlockCheck, sched_thread_ctx_t::recentBlockTime, thread_t::sched, and uptime().
Referenced by sched_invoke(), sched_push(), and sched_push_new_thread().
| SYSCALL_DEFINE | ( | SYS_NANOSLEEP | , |
| uint64_t | , | ||
| clock_t | nanoseconds | ||
| ) |
Definition at line 144 of file sched.c.
References sched_nanosleep().
| SYSCALL_DEFINE | ( | SYS_PROCESS_EXIT | , |
| void | , | ||
| uint64_t | status | ||
| ) |
Definition at line 199 of file sched.c.
References NULL, panic(), and sched_process_exit().
| SYSCALL_DEFINE | ( | SYS_THREAD_EXIT | , |
| void | |||
| ) |
Definition at line 211 of file sched.c.
References NULL, panic(), and sched_thread_exit().
Definition at line 284 of file sched.c.
References sched_yield(), and timer_notify_self().
|
static |
Definition at line 23 of file sched.c.
Referenced by sched_nanosleep().