|
AquilaOS documentation
How it works, and its code
|
x86: the scheduler's architecture side: the tick, the idle loop, and a thread that sleeps, yields or ends. More...
#include <core/arch.h>#include <core/platform.h>#include <core/time.h>#include <mm/mm.h>#include <sys/proc.h>#include <sys/sched.h>#include <sys/lock.h>#include "sys.h"#include <platform/misc.h>Go to the source code of this file.
Functions | |
| uint64_t | arch_cycles (void) |
| Reads a counter that changes as fast as the CPU runs, which the kernel uses as a source of randomness. | |
| static void | x86_sched_handler (void *arg) |
| Handles the tick, on every CPU: it charges the running process, asks for a thread switch, and on the boot CPU, also moves the clock on and runs the scheduler's timers. | |
| void | arch_sched_init (void) |
| Starts the timer tick on every CPU, and the clock where it needs to be started. | |
| static void | __arch_idle (void) |
| The idle loop, on the CPU's idle stack. | |
| void | arch_idle (void) |
| Makes this CPU idle, on its idle stack, until an interrupt makes a thread ready. | |
| static void | __arch_cur_thread_kill (void) |
| Ends the current thread, from the CPU's idle stack, then idles. | |
| void | arch_cur_thread_kill (void) |
| Ends the current thread. | |
| void | arch_yield (void) |
| Puts the current thread at the end of the ready list, and runs the next ready thread. | |
| void | arch_sleep (void) |
| Puts the current thread to sleep. | |
Variables | |
| static uint32_t | timer_period = 0 |
| static uint64_t | timer_ticks = 0 |
x86: the scheduler's architecture side: the tick, the idle loop, and a thread that sleeps, yields or ends.
Definition in file sched.c.
|
static |
Ends the current thread, from the CPU's idle stack, then idles.
Definition at line 99 of file sched.c.
References __arch_cur_thread_kill(), curthread, kernel_idle(), kfree(), NULL, thread_kill(), and ZOMBIE.
|
static |
The idle loop, on the CPU's idle stack.
It lets go of the kernel lock; an interrupt takes it, and lets go of it again if it comes back here.
Definition at line 76 of file sched.c.
References __arch_idle(), kernel_lock_held(), and kernel_unlock().
| void arch_cur_thread_kill | ( | void | ) |
Ends the current thread.
Its kernel stack is freed with it, so this switches to the CPU's idle stack first. It doesn't return.
Definition at line 118 of file sched.c.
References __arch_cur_thread_kill(), arch_cur_thread_kill(), and x86_goto().
| uint64_t arch_cycles | ( | void | ) |
Reads a counter that changes as fast as the CPU runs, which the kernel uses as a source of randomness.
Definition at line 23 of file sched.c.
References arch_cycles().
| void arch_idle | ( | void | ) |
Makes this CPU idle, on its idle stack, until an interrupt makes a thread ready.
It doesn't return.
Definition at line 87 of file sched.c.
References __arch_idle(), arch_idle(), curthread, NULL, VMA, x86_goto(), and x86_kernel_stack_set().
| void arch_sched_init | ( | void | ) |
Starts the timer tick on every CPU, and the clock where it needs to be started.
Definition at line 60 of file sched.c.
References arch_cpu_kick(), arch_sched_init(), cpus, cpus_count, platform_timer_setup(), timer_period, x86_clock_init(), x86_clock_ticks(), and x86_sched_handler().
| void arch_sleep | ( | void | ) |
Puts the current thread to sleep.
It stops here, and the next ready thread runs, or the CPU idles; it returns once the thread is woken up and chosen to run again.
Definition at line 136 of file sched.c.
References arch_sleep().
| void arch_yield | ( | void | ) |
Puts the current thread at the end of the ready list, and runs the next ready thread.
Definition at line 128 of file sched.c.
References arch_yield().
|
static |
Handles the tick, on every CPU: it charges the running process, asks for a thread switch, and on the boot CPU, also moves the clock on and runs the scheduler's timers.
Definition at line 33 of file sched.c.
References x86_regs::cs, sched_cpu_tick(), sched_timer_tick(), time_resync(), timer_period, timer_ticks, x86_clock_tick(), x86_irq_tick_switch(), and x86_sched_handler().
Referenced by arch_sched_init(), and x86_sched_handler().