Process status and switching (learning notes)

Source: Internet
Author: User

Time:

Location: Base

-------------------------------------------------------------------------------

I. Three basic states of a process

The three basic statuses of a process include readiness, execution, and blocking.

1. Readiness

After the process is allocated with all necessary resources except the CPU, it can be immediately executed as long as the CPU is obtained. This is the ready state. There may be many processes in the ready state in a system. They are arranged in a queue to form a ready queue.

2. Execution status

As mentioned above, a process can be executed once the CPU is obtained, and the process being executed is in the ready state. A single processor only has one process in the execution state, and a multi-processor can have multiple.

3. Blocking status

When a running process is temporarily unable to continue execution due to an event, the processor is suspended, that is, the execution of the process is blocked and the status is blocked, both the waiting status and the blocking status are supported. Events that force a process to change from execution status to blocking status usually include I/O requests and Request Buffer space. There may also be many blocked processes, which can also be arranged into one queue, or multiple queues can be arranged according to the reason for blocking.

-------------------------------------------------------------------------------

2. switch between the three basic states of a process: 2.1 ready-to-Execute

A ready process. When a process scheduler selects a ready process based on a selected policy, the process can be executed after it is assigned a processor, and the status changes to the running status. [Ready status -- (process scheduling) -- execution status ].

2.2 run-the current process in progress. If the execution is paused because the time slice allocated to it is used up, the process is switched back from the execution status to the ready state. [Execution status -- (time slice used up) -- ready status]

2.3 execute-block the current process that is being executed normally. If a wait event (I/O request is waiting for the information transmission of external devices, request buffering, and access critical resources to wait for resources) if the process is blocked and cannot be executed, the process is blocked. [Execution status -- (wait for an event) -- blocking status] 2.4 blocking-ready

A process in the blocking status has completed the waiting event. For example, if the input and output are complete and the resource is satisfied, the process in the blocking status is not immediately transferred to the execution status, but switched to the ready state, wait for the system scheduler to schedule the process at the right time and then switch to the execution status. [Blocking status -- (wait for the event to complete) -- ready status]

-------------------------------------------------------------------------------

Iii. pending status

The suspension status is equivalent to a modifier. The readiness status can be divided into the active readiness status and the static readiness status, and the blocking status can be divided into active blocking and static blocking.

3.1 cause of suspension

1. End user requests.

When an end user finds a suspicious problem while running the program, he or she wants to temporarily shut down his or her program and suspend the running process. At this time, if the process is in the ready state but not executed, the program will not be scheduled for the time being, so that you can check the execution status and modify the program.

2. Requests from the parent process

Sometimes the parent process also wants to suspend a child process and wait for the child process to calm down to check and modify the child process or coordinate the activities of the Child process.

3. Load Adjustment needs

When the real-time system has a heavy workload and may affect the control of real-time tasks

4. Operating System Requirements

-------------------------------------------------------------------------------

IV. Creation status and termination status 4.1 creation status

Two steps for creating a process:

1. Create a PCB for a new process and fill in necessary management information (such as process ID)

2. Transfer the process to the ready status and insert it into the ready queue.

Because the necessary resources or other information such as the primary memory resources are not allocated, the process only has its own PCB, but has not yet entered the primary memory, therefore, a process cannot be called to run. The state of the process in this stage is the creation state. After a process in the creation status obtains the required resources and the PCB Initialization is completed, it can be transferred to the ready state. When the current system performance and memory capacity are both allowed, the process in the creation status will be converted to the active ready state. If the current system resources are insufficient, you cannot allocate the required resources to the process in the creation status. At this time, the process changes to the static ready state.

4.2 termination status

Process Termination steps:

1. Wait for the operating system to handle the aftermath

2. Clear the PCB and return the PCB to the operating system.

Process termination conditions:. process reaches the natural end point B. an error occurred while running the process C. the process is terminated by the operating system. D. the process is terminated by another process with the termination right.

The process stops running after it enters the terminated state, so that we know that only the processes that are being executed will change to the terminated state, and the processes in the terminated state will be transferred to the stopped state, the operating system still keeps a record, which stores status codes and timing statistics for other processes to collect. After other processes extract the information about terminated processes, the operating system deletes the process.

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.