---restore content starts---
20135125 Chen Zhiwei
Original works reproduced please indicate the source
"Linux kernel Analysis" MOOC course http://mooc.study.163.com/course/USTC-1000029000 "
Experimental requirements:
Mykernel Experimental Guidance (how the operating system works)
Run and analyze a streamlined operating system kernel to understand how the operating system works
Open the shell with a virtual machine in the lab building
- CD linuxkernel/linux-3.9.4
- Qemu-kernel Arch/x86/boot/bzimage
Then CD Mykernel you can see the contents of the Qemu window output code MYMAIN.C and myinterrupt.c
Use your own Linux system environment to build the process see Mykernel, which can also find a simple time slice rotation multi-channel program kernel code
Experimental process:
1. Open the shell using the virtual machine in the lab building and enter
cd LinuxKernel/linux-3.9.4
qemu -kernel arch/x86/boot/bzImage
2. Observe the program that the kernel is running:
3. View the files included in the Mykernel:
4. Run mymain.c and view the kernel boot code:
5. Run myinterrupt.c and look at the time interrupt function code:
Experimental Analysis:
This is the kernel code of the startup function, C language, the loop part is executed 100,000 times each, output a statement.
void __init My_start_kernel (void)
{
int i = 0;
while (1)
{
i++;
if (i%100000 = = 0)/* Here are 10,000 times per machine system operating speed can be self-adjusting */
PRINTK (kern_notice "My_start_kernel here%d \ n", i);
}
}
This code is called when the time is interrupted and a statement is output each time it is called.
void My_timer_handler (void)
{
PRINTK (kern_notice "\n>>>>>>>>>>>>>>>>>my_timer_handler here <<<<<<<<<<<<<<<<<<\n\n ");
}
Here we can see more simple than before, every time the output is called PRINTK, only need to interrupt when the interruption of processing can be
Then I added some of my own annotations to the code on GitHub, see:
Finally, here are some tips that I felt necessary to know in the class, see:
Experiment Inspiration:
In this experiment I learned about three very important registers, EBP, ESP, and EIP, and in class we can know that the thread we define is used to save the EIP and esp. For TPCB, I learned that he was used to represent the process, that is, to initialize the stack. Now I know a lot more about the process and principle of time interruption than before. The CPU generates a time interrupt every time it is over a point.
---restore content ends---
Linux kernel Analysis-complete a simple time slice rotation multi-channel program kernel code