Operating system core principles-3. Process Management (top): Process overview

Source: Internet
Author: User

Process management, memory management, and file management are the three core functions of the operating system, so what is a process? As the name implies, a process is a program in progress, or a process is an executing program. When a program is loaded into memory, it becomes a process. So we can get: Process = Program + Execute. This article will study the process, process model, process status, and defects of the process, and lay a solid foundation for the subsequent learning process scheduling and process communication.

First, the process is what ghosts? 1.1 From work to process

Processes are called jobs before the advent of the Multics operating system, and work is the concept that IBM uses for multi-channel batch program design. For historical reasons, developers of the Multics operating system were reluctant to use the terminology invented by IBM and changed their work to process.

1.2 Multi-channel programming for CPUs

At the beginning of computer development, single operator single control terminal, the CPU utilization is very low. In order to improve CPU utilization, people want to load multiple programs concurrently in the computation to execute concurrently. As a result, these programs, which exist simultaneously in computer memory, are called processes. the advent of the process allows each user to feel themselves in the exclusive CPU. Therefore, it can be said that the process is to implement multi-channel programming on the CPU concept, as shown in.

The process is invented to support multi-channel programming, and the goal of multi-channel programming is to improve the utilization of computer CPUs (or the throughput of the system). For example, if a process has 20% of the time it uses the CPU to compute, and another 80% of the time is used for I/O, the CPU utilization is only 20% for single-channel programming. If you run two of these processes at the same time, even with 2-channel programming, the CPU will be idle only when I/O is in two processes at the same time, so CPU utilization will increase to: 1-0.8*0.8=0.36=>36%. Similarly, if you run more processes at the same time, CPU utilization will gradually increase until a certain point is reached. (PS: The example here ignores the system consumption required for process switching)

II. Process Model 2.1 Three perspectives on process model

(1) Physical view: From the allocation of physical memory, each process occupies a memory space, from this point of view, the process is actually a piece of memory space. Because at any one time, a CPU can only execute one instruction, so there is only one process executing on the CPU at any given time, and exactly which instruction to execute is specified by the physical program counter. Therefore, at the physical level, all processes share a program counter, but the CPU is constantly switching processes .

(2) Logical view: From a logical level, each process can be executed, or temporarily suspended for other processes to execute, and can then be executed. So, the process needs to find a way to keep the state in order to start from the right place the next time it executes. Therefore, each process has its own counter that records where its next instruction is located . (Logically, the program counter can have multiple)

(3) Timing perspective: in terms of time, each process must move forward. After a certain amount of time has elapsed, the process should have done some work. In other words, each time the process returns, it is behind the last return point. The philosopher has the cloud: "A man cannot step into the same river two times."

2.2 How the process model is implemented

(1) Physical basis: the physical basis of the process is the program, the program is running on the computer, so the computer to run the program first to solve the process of storage: allocate memory to the process to make it settle down. Because multiple processes may coexist simultaneously, you need to consider how to let multiple processes share the same physical memory without conflicts. The OS solves this problem through memory management.

(2) Process switching: The process is actually running on the CPU, so how to switch the CPU between multiple processes is also a problem. The OS solves this problem through process scheduling. The so-called process scheduling, is deciding when to let what process to use the CPU.

Iii. hierarchy of processes and status 3.1 hierarchy of processes

A process can create a new process through system calls during execution, the new process is called a child process , and the process that creates the child process is called the parent process .

Child processes can then create sub-processes, so that the descendants of the creation of the so-called process tree formed.

3.2 State Transitions for processes

There are 3 basic process states: execution, blocking, and readiness, as shown in:

So, what are the reasons for the process being hung up and blocked? The first is a process that performs some kind of blocking operation, such as reading and writing to disk, during operation. (because the blocking operation needs to wait for the result before it can continue, the OS will suspend the process and let the other process run) followed by a process that has been executing for too long and, to be fair, the OS hangs it up so that other processes have a chance to execute.

PS: Of course, the 3 typical states described above are not the only classification, in fact, many business OS processes are more than 3, such as the Windows process has 7 states.

Iv. Overview of the process Management 4.1 means required

First of all, what does a person's birth mean to a society? After a person is born, the hospital needs to establish a record, which includes information such as name, gender, weight, parental information, when and where the birth, and then through the record to register the account, ID card and so on. After the formalities, the person is formally present, known as a citizen. Of course, we have to goverment the person can be a variety of management, such as you can not talk, not disorderly parade and so on.

Similar to the process of a social administrator, the OS needs to manage processes to maintain some information about the process, and the structure that the OS uses to maintain process records is the process table or Process Control block (BLOCK,PCB). So what's the record in the process table? In general, the records maintained should include: Register, program counter, status Word, stack pointer, priority, process ID, creation time, elapsed CPU time, various handles currently held, and so on.

4.2 Process of Creation

In general, the steps for the OS creation process are as follows:

In different OS, the method of creating the process is different, for example, Windows is created through the system call completion process, this system call is CreateProcess.

4.3 Dealing with the problem

The biggest problem of human society is the allocation of resources, the biggest problem of process management is the same. Although the process is not self-conscious, our nature pursues fairness. In addition to fairness, we need to consider: efficiency. Thus, fairness and efficiency become the eternal theme in the process management.

4.4 Defects of the process

Assume that there are two good island love action films, are only screened once, and will never show again. Moreover, these two films still show at the same time (dog blood plot ah!) ), also shown in two different small rooms. And you can only do one thing at a time, so you have to give up another. This is also the process, which is a drawback of the process, and if you want to do two or more things at once, the process is not enough. Also, if a process is blocked during execution, such as waiting for input, the entire process will be suspended (paused) and cannot continue execution. This way, even if some of the work in the process does not depend on the input data, it cannot be pushed forward.

Therefore, in order to solve the above two problems, people invented the thread.

  

  Want to know how to funeral, also listen to tell.

Resources

Heng Hengming, "The philosophical principles of the operating system", mechanical industry Press

Zhou Xurong

Source: http://edisonchou.cnblogs.com

The copyright of this article is owned by the author and the blog Park, welcome reprint, but without the consent of the author must retain this paragraph, and in the article page obvious location to give the original link.

Operating system core principles-3. Process Management (top): Process overview

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.