Context of computer operating systems and processes --- process of switching

problem

  • Look like a process of
  • After the operating system page fault is how to load data into memory disk, the process is kind of how

Procedures and processes

     Program is a static concept, but the process is more like running a task process , an example of the final surface can have a good understanding, a program can be loaded multiple processes.1297993-20191105094030675-50570240.png

The concept of process

1297993-20191105201804292-1918016637.png

Processes and context switching

1297993-20191125165443809-1682347259.png

    It can be seen when the two switching processes (shell and hello program) will occur from kernel mode to user mode.

1297993-20191125170002827-1078934757.png

    The above image is very important, a good understanding! The above is related to the process we are talking about the context in two parts, and system information for the system context, and associated with the user is the user-level context, for example, our process for java, java for the operating system is a process, it has a process identification information, the identification information of the process is a system context, and we write the code block is allocated in the user program, we use code generation "objects" and assign the user stack and user data blocks.

1297993-20200109100049114-1600213009.png

    Or in java process, for example, if there is a java process operating system, its process space you can say so.

User mode and kernel mode

    We now know that the operating system or to be in two states, or to execute user code, or to execute kernel code.

1297993-20200109100822563-632139033.png

To distinguish between these two modes the processor, there is a flag for distinguishing the two states.

Loading and running processes

1297993-20200109141733814-2102210576.png

    The figure is a step loader, which step3, note creation process is not only time to write, to implement copy on write through read-only (equivalent to load data from a database file into memory, and then modify the generated dirty pages, then dirty pages brush principle to return the data back to the file, but at times not brush back to the file) occurs when the write protection is wrong, this time really the implementation of alternative, something new will replace the old process to process things, step4 not will will have a missing page from disk to copy content such as code and data, but modified shell (old process) page tables and other things, making the page table points to the hello (new process) page frame, this time, will the missing pages loading data into the memory until the main function.

execve function is executed

Execve function can perform the task is to prepare the work before the process, before the implementation of execve main method of execution is required to grasp important, part of the course will be in the back of the operating system.

1297993-20200115100724779-1628573498.png

Stack structure tasks

We see the diagram on the right, the main function of the second parameter is an array put the process name, for example, in the above example "Hello"

1297993-20200115103913887-621685509.png

to sum up

  • fork command is used to generate a child process, execute the pointing process preparation before the real business processes after the implementation of the relevant code from the main function entry.

Reference material

  • Yuan Chunfeng teacher courses

Guess you like

Origin www.cnblogs.com/Benjious/p/12195508.html
Recommended