Boot: (for details, see boot_process)
entry.S
-> start.c
-> main.c
calls schedule()
schedule():
schedule()
enters an infinite loop and will never return.
From now on the harts will do this forever:
- look for a process to run (for details see scheduling)
- If there is none, wait for an interrupt (
wfi
assembly instruction, CPU sleeps).- A timer interrupt or a device interrupt will wake this up (see interrupts).
- This calls
kernel_mode_interrupt_handler()
- Both interrupt types will quickly do their things and then return to the scheduler which starts its next loop.
- (There is no process the timer interrupt could force to yield)
- This calls
- A timer interrupt or a device interrupt will wake this up (see interrupts).
- If there is a process,
context_switch()
will load the processes context/registers, and return to that context.- A new process starts in
forkret()
(set inalloc_process()
) which will return to user mode and thus start the application. - An existing process returns to its
yield()
call in S-mode.- This process can switch between kernel and user space until a
wait()
or timer interrupt (interrupts) will have the process callyield()
. This switches back to the schedulers context viacontext_switch()
.
- This process can switch between kernel and user space until a
- A new process starts in
- If there is none, wait for an interrupt (
Overview: kernel
Boot: boot_process | init_overview
See also: life_cycle_cpu life_cycle_user_application