Operating System-Process (1)

Source: Internet
Author: User

Operating System-Process (1)
This article describes one of the core concepts of the Operating System: Process, the main content: What is the State of the Termination Process) 1. What is process 1.1 Basic Information Process is an instance of the execution program, which is an abstract action of the running program, including all program counters (PCS) of the currently running program ), registers and variables: the commands and data required for running the program. If the program is a recipe, the process is the process of cooking. The process instance running on my current system (windows 10). If a program runs multiple times at the same time, the operating system will create multiple processes (independent of each other ), for the operating system, multiple processes are running the same program. Google Chrome is an example (multiple instances do not affect each other, but consume memory resources ..) 1.2 Why does the operating system introduce the concept of Why Process? Isolation is mentioned above, but isolation is not the primary driving force for process introduction. The primary driving force for introducing processes is to increase the system response time. The CPU can only do one thing at a time, and only one process can run on the CPU. But why do we feel that the computer has many things at the same time? We typed in the Word over and received an email notification in the lower right corner. Word is a process (of course, multiple processes are opened) mail is a process operation using its own scheduling policy to switch the CPU between Word and Email, because switching is fast, users feel that the CPU is working on a lot of tasks at the same time, thus increasing the system response. The user feels that the, B, and c processes run only one a, B, and c at the same time during the execution of the 1.3 process scheduling. The following is an example: A father prepared to cook a cake for his son. He had a recipe for making a cake. He was cooking a cake according to the recipe. Then his son came in and said to him, "Dad, I want to drink milk ". The father stopped his cake, poured milk to his son, heated it in the microwave oven, and finally gave the milk to his son. Finally, the father returned to the original place where the cake was made and continued to complete the cake. Cake recipe: it is A program, what to do first, and then what to make the cake process: it is the process of process A giving his son hot milk: It is process B, this Father: CPU son suddenly want to drink milk: the interrupted CPU switches between process A and process B based on the existing situation (policy. My father poured milk and continued to make the cake. The progress here is that the CPU first saves the status of the current process before switching between processes. When switching to this process again, it runs from the previously saved status (the overhead of process switching can also be seen ). 2. Process Creation (Creation) 2.1 Process Creation Time create a process (boot) at system startup ). At this time, all processes created are required to run the system. Some processes are used to interact with the UI, and some are background processes. For example, the Email receiving process is created by the existing process by calling the Create Call of the system. For example, in a web system, you can create another excel process to import data to excel. This function is used when a user initiates a request. For example, when a user clicks the mouse, when entering the command, the corresponding process will be created to respond to the user's request. 2.2 The Three creation processes mentioned above will be created in the same way: an existing process skips a system call to complete process creation. Unix: Fork Windows: CreateProcess this system call will inform the operating system to create a process. The process that initiates a system call is the parent process, and the created process is the child process. The Parent and Child processes are independent of each other, and their address space is completely different. 2.3 process Hierarchy is described above. The new process is completed by sending the call of the creation process like OS. The created process is now called child process. This child process may send a request to the OS again to create a child process ..... And so on, there will be a process inheritance chain. The above process that becomes a chain will exist as a process group in unix. However, in Windows, these processes are completely independent. The inheritance relationship is not very important in the process. 3. termination of a process will be terminated after it is created. The process will be terminated under the following conditions. It is relatively easy to understand: normal termination: after a process completes its own tasks, it tells the Operating System (System Call) to terminate the process when an error occurs. When a process discovers an error, for example, the resource does not exist or the running program has a bug. For example, it is divided by 0. Killed by other processes. For example, in windows, you can use the task manager to Kill system processes. In some operating systems, when a process is terminated, the processes created by the system will also be killed. 4. State of the Process 4.1 there are three states after the process is created: Running (Running) Blocked (Blocked) Ready (Ready) blocked refers to the process waiting for external stimulation (not related to CPU), such as the Console program, which is always waiting for user input. Ready indicates that a process can run without waiting for any resources, but the CPU is occupied by other processes, and there is no CPU resource. Status switch Running-"Blocked: The process requires other external resources during Running. Blocked-Ready: the resources required by the process are met by Ready-Running: determined by the CPU's Scheduler. The CPU can use Running-Ready: determined by the CPU's Scheduler, CPU is allocated to other processes for use (for example, in the above example, Dad stops the cake being made to give his son hot milk, and the cake is in ready state at this time)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.