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.
The concept of process
Processes and context switching
It can be seen when the two switching processes (shell and hello program) will occur from kernel mode to user mode.
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.
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.
To distinguish between these two modes the processor, there is a flag for distinguishing the two states.
Loading and running processes
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.
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"
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