26 asm volatile(
"rdtsc" :
"=a"(lo),
"=d"(hi));
35 struct x86_regs *r = curcpu()->arch.irq_regs;
82 asm volatile(
"sti; hlt; cli;");
93 uintptr_t stack = curcpu()->arch.idle_stack;
120 uintptr_t stack = curcpu()->arch.idle_stack;
130 extern void x86_preempt(
void);
138 extern void x86_sleep(
void);
void arch_cpu_kick(struct cpu *cpu)
Makes another CPU enter the kernel now, with an inter-processor interrupt: to run a thread that just ...
void arch_yield(void)
Puts the current thread at the end of the ready list, and runs the next ready thread.
void arch_idle(void)
Makes this CPU idle, on its idle stack, until an interrupt makes a thread ready.
static uint64_t timer_period
static void __arch_idle(void)
Runs the idle loop, on the CPU's idle stack.
void arch_sleep(void)
Puts the current thread to sleep.
static void __arch_cur_thread_kill(void)
Frees the running thread, from the CPU's idle stack, and idles.
void arch_cur_thread_kill(void)
Ends the current thread.
void arch_sched_init(void)
Starts the timer tick on every CPU, and the clock where it needs to be started.
static uint64_t timer_ticks
void x86_goto(uintptr_t eip, uintptr_t ebp, uintptr_t esp)
static void x86_sched_handler(void *arg)
Handles the tick, on every CPU: it charges the running process, asks for a thread switch,...
void x86_clock_ticks(uint32_t period_ns)
Says how often the timer ticks, from now on: with neither TSC nor HPET, the ticks are the clock.
void x86_clock_init(void)
Chooses the clock's counter and calibrates it, at boot, before the timer ticks.
void x86_clock_tick(void)
Counts a tick of the timer, and moves the clock's base on to now.
void x86_kernel_stack_set(uintptr_t sp)
Sets the kernel stack that interrupts from user mode switch to, on the running CPU: the thread that i...
struct cpu cpus[CPUS_MAX]
void kfree(void *)
Frees an object that kmalloc() gave.
void kernel_unlock(void)
Lets go of the kernel lock, for the next CPU waiting for it.
int kernel_lock_held(void)
Says whether this CPU holds the kernel lock.
void x86_irq_tick_switch(void)
Asks for a thread switch once the current interrupt is done: the tick calls it.
void sched_cpu_tick(uint32_t period, int user)
Charges a timer tick to the process that was running on this CPU.
void kernel_idle(void)
Gives up the CPU when the current thread can't run anymore (it sleeps, or it exited): the next ready ...
void sched_timer_tick(uint32_t period, int user)
Runs the boot CPU's timer tick.
unsigned long long int uint64_t
The registers an interrupt or exception saved, on the kernel stack, as cpu.S's stubs push them: the g...
int thread_kill(struct thread *thread)
Releases what a thread holds (its poll() registrations, its CPU state and kernel stack) and makes it ...
void time_resync(void)
Sets the wall clock from the real time clock again, if they are 2 seconds or more apart.
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...