22#include <aquila/stat.h>
219 return r < 0 ? r : 0;
336 if (!list_empty(&
ready))
350 curcpu()->kicked = 0;
352 if (curcpu()->
idle && !list_empty(&
ready))
409 if (list_empty(&
ready))
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_idle(void)
Makes this CPU idle, on its idle stack, until an interrupt makes a thread ready.
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.
void arch_thread_switch(struct thread *thread)
Switches to a thread that has run before: its address space, its kernel stack, then where it stopped.
void arch_thread_spawn(struct thread *thread)
Runs a thread for the first time: switches to its address space and kernel stack, and starts it.
void callout_run(uint64_t now)
Calls the timer's callouts that are due, from the timer interrupt.
struct cpu cpus[CPUS_MAX]
#define list_entry(node, type, member)
int proc_init(struct proc *proc)
Gives a new process (init) its ID and its descriptor table.
int session_new(struct proc *proc)
Makes a new session, with a new process group, both led by a process and with its ID,...
void random_add(uint32_t value)
Stirs a value into the pool, which goes into the next key.
void sched_init_spawn(struct proc *init)
Starts the scheduler with the first process, init, and runs it.
void sched_idle_wakeup(void)
Runs a ready thread now if an interrupt made one ready while this CPU was idle, rather than at the ne...
void sched_cpu_tick(uint32_t period, int user)
Charges a timer tick to the process that was running on this CPU.
void sched_alarm_get(struct proc *proc, uint64_t *value, uint64_t *interval)
Reads what is left of a process's real time timer.
void sched_thread_killed(void)
Ends the current thread, which was killed while it ran on this CPU (thread->killed).
int sched_wait(struct waitq *waitq, uint64_t until)
Puts the current thread to sleep on a wait queue until it is woken up, a signal ends the sleep,...
void sched_timer_cancel(struct thread *thread)
Takes a thread off the list of threads waiting with a deadline, when it no longer waits (it was woken...
void sched_alarm(struct proc *proc, uint64_t value, uint64_t interval, uint64_t *old_value, uint64_t *old_interval)
Sets a process's real time timer, which setitimer() and alarm() use: the process gets SIGALRM once va...
int sched_sleep(uint64_t until)
Puts the current thread to sleep until a time comes, for nanosleep().
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 schedule(void)
Switches to the next ready thread.
void sched_timer_tick(uint32_t period, int user)
Runs the boot CPU's timer tick.
struct cpu * sched_thread_cpu(struct thread *thread)
Finds the CPU that is running a thread, if it's another CPU than this one.
void sched_thread_kick(struct thread *thread)
Makes a thread that runs on another CPU enter the kernel now, rather than at its next tick: a signal ...
void sched_thread_ready(struct thread *thread)
Puts a thread at the end of the ready list, to run in its turn.
void sched_thread_spawn(struct thread *thread)
Starts running a thread for the first time.
void sched_thread_wake(struct thread *thread)
Makes a thread that was sleeping ready to run.
int signal_proc_send(struct proc *proc, int signal)
Sends a signal to a process.
unsigned long long int uint64_t
A processor, and what runs on it.
A list: its first and last nodes, and how many there are.
struct waitq thread_join
threads waiting in thread_join() sleep here
struct vnode * cwd
its current directory (a reference), or NULL for the root
struct list_node alarm_link
uint64_t alarm_at
its real time timer (ITIMER_REAL): SIGALRM when arch_rtime_ns() reaches alarm_at, then every alarm_in...
mode_t mask
its file mode creation mask (umask)
struct queue threads
its threads
struct list_node run_link
it's on the ready list (sched.c) while it's ready to run, or on the wait queue it sleeps on (waitq); ...
struct list_node timer_link
it's on the timer's list while it waits with a deadline
uint64_t sleep_until
when it waits with a deadline (sched_wait()): the deadline, in arch_rtime_ns() time
int urgent
it runs before the others once woken, as soon as the interrupt that woke it returns (sched_thread_wak...
int spawned
whether it has run yet
struct proc * owner
its process
size_t ref
how many references there are to it
static struct list alarms
static void sched_cpu_wake(void)
Wakes up an idle CPU to run a thread that just became ready.
uint64_t arch_rtime_ns(void)
Reads the monotonic clock, which starts at boot.
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...
void thread_wakeup(struct thread *thread)
Wakes up one thread, if it is sleeping on a wait queue.
void waitq_wakeup(struct waitq *waitq)
Wakes up every thread sleeping on a wait queue, and every thread polling it.
int waitq_sleep(struct waitq *waitq)
Puts the current thread to sleep on a wait queue until it is woken up.