In the previous article, a process was introduced, and the process of stack changes when calling subroutines was analyzed. This article describes the process of multi-process execution, when a process needs to stop to wait for a certain condition or the CPU to allocate the time slice run out need to switch to another process, when the switch first generates an interrupt, then the CPU will perform the corresponding interrupt processing operation, An important operation, for example, is to protect the stack of the current process and the value of the CPU register, and resume the last state when the CPU is dispatched again.
Follow the steps on Mykernel to install the program, perform Qemu-kernel arch/x86/boot/bzimage see such as:
The following procedures are executed:
Executes a process a i++ operation, when i%100000 prints the value of I, when the clock interrupt occurs when the interrupt processing My_timer_handler is performed. We found that the printed I value is always increasing, that is, after the interrupt processing execution after the CPU continues to dispatch to a, I maintain the last time the completion of the dispatch value, this is how to do it, is to interrupt processing , below we pass the program simulation of the process.
"Linux kernel Analysis" MOOC course complete a simple time slice rotation multi-channel program kernel code