2019-2020-1 20199306 "Linux kernel principle and Analysis" in the third week of work

2019-2020-1 Student ID "Linux kernel principle and Analysis" in the third week of work

Complete a simple round-robin multi-channel kernel code

Experimental Procedure

Mykernel run in the laboratory building environment

  • View mykernel related source code

  • View mymain.c

(Start the operating system code of FIG cycles)

  • View myinterrupt.c

Modify the kernel

  • Make use recompile

  • Then enter it again: qemu -kernel arch / x86 / boot / bzImage to boot the kernel

Code Analysis

  • The main role of the three programs

    • mypcb.h: process control block PCB structure is defined.

    • mymain.c: initialize each process and starts the process 0.

    • myinterrupt.c: clock interrupt handling and process scheduling algorithm.

  • System Analysis

    • Here my_timer_handler core function will be called periodically, every call to 1000, will go to modify global variables my_need_sched value is 1, the notification process is being executed execution scheduler my_schedule.

In my_schedule function, complete the switching process.

The process of switching two cases, one case to the next process had not been scheduled, another case is scheduled over the next process, its status can be known by the state of the next process.

Compilation process switch is still implemented by inline code, it is nothing more than save the old process eip and stack, and the value of the stack eip new process into the corresponding register.

Experimental summary

  • By this lecture and experimental learning, I know two core functions of the operating system is the process of scheduling and interrupt mechanism

Process scheduling process refers to the system of competition in the ready state is determined by the processor to coordinate the process scheduler. Scheduling strategy is determined in accordance with the process of ordering a batch, out of a process from the ready queue and give it the right to use the processor.

Interrupt mechanism refers to the operating system, linux kernel to manage all hardware devices connected to the computer, which is working within its copies. And you want to manage these devices, they must first be able to exchange news and job.

  • The computer has three magic weapons: stored program computer, the function call stack, interrupt.

  • There are two swords operating system: interrupt context, process context switch.

Since the CPU only one set of registers, at the same time can only handle a process (for the time being only consider single-core CPU), so in theory can only perform a single task order, but based on the three magic weapons and two swords, the operating system is multitasking operation .

Guess you like

Origin www.cnblogs.com/Huyiming/p/11600632.html