Upload
owen-stokes
View
219
Download
0
Embed Size (px)
DESCRIPTION
Kernel Execution: Boot System Boot Initialize System Idle Task (pid 0) Creates Init, which creates all other threads ksoftirq Init (pid 1) migration The kernel only runs deterministically at boot time. Otherwise, the kernel is entirely event driven. Power On Bootloader loads kernel Initial kernel never returns 3CSE 522S – Advanced Operating Systems Kernel threads are scheduled as any other process. Kernel entry point: start_kernel() in /init/main.c
Citation preview
CSE 522S – Advanced Operating Systems 1
How & When The Kernel Runs
David Ferry, Chris GillDepartment of Computer Science and Engineering
Washington University, St. Louis [email protected]
CSE 522S – Advanced Operating Systems 2
Traditional View of Process Execution
However, the kernel is not traditional!
Creation
Ready Running
Waiting
TerminateBlocked
Preempted
Scheduled
Unblocked
CSE 522S – Advanced Operating Systems 3
Kernel Execution: Boot
SystemBoot
InitializeSystem
Idle Task(pid 0)
Creates Init, whichcreates all other threads
ksoftirqInit
(pid 1) migration
The kernel only runs deterministically at boot time. Otherwise, the kernel is entirely event driven.
Power On
Bootloaderloads kernel
Initial kernelnever returns
Kernel threads are scheduled as any other process.
Kernel entry point:start_kernel() in /init/main.c
CSE 522S – Advanced Operating Systems 4
Kernel Execution: ThreadsKernel threads perform background operations, e.g.
– [ksoftirq] does delayed interrupt handling– [migrate] does inter-processor load balancing– [kworker] handles misc. tasks
Kernel threads are almost just like user threads:– are scheduled– can be preempted– runs in kernel context– has no process memory space
CSE 522S – Advanced Operating Systems 5
Kernel Execution: Event Driven
Runs insyscall
context
InterruptHandler
Runs ininterruptcontext
Software/hardwareInterrupt arrives Returns control
Hardwareinterrupt
Softwareinterrupt
Returns control
• Interrupt context is unpreemptible• Syscall context is preemptible (though may disable preemption)• Return path may return control to kernel, userspace, or call schedule()
Kernelpreemption
CSE 522S – Advanced Operating Systems 6
System Calls
• The syscall interface is a single integer1. User loads syscall number into register2. May load syscall arguments into other registers3. Executes syscall trap (software exception)4. Trap is caught by the kernel5. Puts arguments on kernel stack (asmlinkage)6. Kernel looks up syscall number in the interrupt
vector7. Jumps to syscall routine specified in interrupt table
CSE 522S – Advanced Operating Systems 7
System Calls on ARM
• The syscall interface is a single integer1. User loads syscall number into register R72. May load syscall arguments into R0-R63. Executes SWI instruction(software exception)4. Trap is caught by the kernel5. Control jumps to function vector_swi() in
arch/arm/kernel/entry-common.S6. Control eventually jumps to a C function inside the
kernel
CSE 522S – Advanced Operating Systems 8
Class Notes
• Please do studios in groups of 2 or 3• Meet in Urbauer 115 next time