UNIX environment Advanced Programming-process state

Source: Internet
Author: User

three-state model: In a multi-channel program system, the process runs alternately on the processor, and the state is constantly changing. Processes generally have 3 basic states: Run, ready, and blocked. (1) Run: When a process is running on a processing machine, the process is said to be in a running state. The number of processes in this state is less than or equal to the number of processors, and for a single processor system, there is only one process in the running state. When no other process can execute, such as when all processes are in a blocking state, the idle process of the system is usually performed automatically. (2) Ready: When a process obtains all the required resources except the processor, it is said to be in the ready state once the processor is available to run. A ready process can divide queues by multiple priorities. For example, when a process enters a ready state due to time slices, it is queued to a high priority queue when the process is ready by I/O operations. (3) Blocking: Also known as a wait or sleep state, a process is waiting for an event to occur (such as requesting I/O while waiting for I/O to complete, etc.) and temporarily stop running, even if the processor is allocated to the process can not run, it is said that the process is in a blocking state.


five-State model: For a real system, the state of the process and its transformation are more complex. Introduced New StateAnd Termination StateConstitute the five-state model of the process. New State: Corresponds to a state that was not committed when the process was just created, and waits for all necessary information for the system to complete the creation process. The process is not yet running while it is in the process of being created. The work performed by the operating system in the creation State includes assigning and establishing Process control block table entries, establishing resource tables (such as open file tables), allocating resources, loading programs, and establishing address space tables. The process is created in two stages, the first of which creates the necessary management information for a new process, and the second phase lets the process go into a ready state. Due to the new state, the operating system can often defer the submission of the new state process based on the performance of the system and the limitation of main memory capacity. Termination State: The process has finished running, reclaims resources other than the process Control block, and lets other processes gather information from the process control block, such as accounting and passing the exit code to the parent process. Similarly, the termination of a process can be divided into two stages, the first phase waits for the operating system to be disposed of, and the second phase releases main memory.


Due to the continuous creation of the process, the system resources, especially the main memory resources can not meet the requirements of all processes running. At this point, you must suspend some processes, put them on disk swap, temporarily do not participate in scheduling to balance the system load, the process hangs may be a system failure, or a user debug program, it may be necessary to check the problem. Active Readiness: Refers to the process in main memory and can be scheduled state. still ready(Hang Ready): Refers to the process is swapped to the standby state of readiness, is not directly scheduled state, only if there is no active-ready state in main memory process, or the suspend-ready process has a higher priority, the system will suspend the ready state process back to main memory and converted to active ready. Active Blocking: Refers to the process already in main memory, once waiting for the event generated will enter the active ready state. Standstill blocking: Refers to the blocking state of the process when it is swapped to the secondary, and then into a still-ready state once the waiting event is generated.

UNIX environment Advanced Programming-process state

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.