How the computer works
Three Magic Weapon: Store program computer, function call stack, interrupt mechanism.
Stack
Function call Framework
Passing parameters
Save return address
Provides local variable space
Stack-related registers
ESP stacking pointer (stack pointer)
EBP base point pointer (base pointer)
Stack operations
Push;pop
EBP serves as a record of the current function call base-
Other key registers
Interrupt
Call command: 1, the EIP of the next instruction to save the address a at the top of the stack; 2. Set the EIP to point at the beginning of the called Program code
1. Call XXX
2. Enter XXX
PUSHL%EBP
Movl%esp,%ebp
3. Exit XXX
MOVL%ebp,%esp
Pop%EBP
Ret
Summary: How the operating system works
Each program has its own execution flow, when the interrupt occurs, the CPU presses the current EIP into the kernel stack, and then points the EIP to the interrupt handler's entry. Set up a cycle, and then to determine whether or not to dispatch, this is the establishment of a scheduling mechanism, there will be a process of scheduling the switch. Because it is time-slice rotation, it is necessary to set up a time slice to set up a dispatch flag when the time slice is exhausted. The overall is the time slice ran out when set the dispatch flag, and then determine whether the need for scheduling with an infinite loop control, need to dispatch the process of switching.
Li Hai Empty original works reprint please indicate the source "Linux kernel Analysis" MOOC course http://mooc.study.163.com/course/USTC-1000029000
Linux kernel Analysis Job: How the operating system works: Complete a simple time slice rotation multi-channel program kernel code