How does a computer work?
Stored program computer working model, the most basic logical structure of computer system;
The function call stack, the high-level language to run the foundation, only the machine language and the assembly language when the stack mechanism for the computer is not so important, but with the high-level language and functions, the stack becomes the basic function of the computer;
Enter
--PUSHL%EBP
--MOVL%ESP,%EBP
Leave
--MOVL%ebp,%esp
--POPL%EBP
function parameter passing mechanism and local variable storage
Interrupt, multi-channel program operating system base point, no interrupt mechanism program can only run from the beginning to the end of the possibility to start running other programs.
♦ Stack-related registers
–ESP, stacking pointer (stack pointer)
–EBP, Base point pointer (base pointer)
♦ Stack Operations
–push
Stack top address reduced by 4 bytes (32 bits)
–pop
Add 4 bytes to the top address of the stack
♦EBP is used in C to record the current function call base
♦ Other key registers
–CS:EIP: Always point to the next instruction address
• Sequential execution: Always point to the next instruction in consecutive addresses
• Jump/Branch: When executing such an instruction, the value of the CS:EIP is
Modified as required by the program
call: Pushes the value of the current CS:EIP into the top of the stack, Cs:eip points to the
The entry address of the calling function
ret: Eject the value from the top of the stack that was originally saved here, and put the CS:EIP
Into the CS:EIP
The following are the experimental contents:
The Qemu window can see that the my_start_kernel is executing while the My_timer_handler clock interrupt handler is executed periodically.
Kernel header file;
Before executing the MY_START_KERNEL,83 line is hardware initialization, 83 rows and later the operating system.
It's easier to print "My_start_kernel here" 100,000 times per cycle
The same is the initialization of hardware;
Each time the clock interrupt is called once PRINTK, output a ">>>>>>>>my_timer_handler here<<<<<<<<", Interrupt processing action
Wang Xue Cheng
Original works reproduced please indicate the source
"Linux kernel Analysis" MOOC course http://mooc.study.163.com/course/USTC-1000029000
Linux kernel and analysis How does the second week operating system work?