The role of process control in process management

Source: Internet
Author: User
Tags terminates

 Process Control is the most important function in process management.

It is used to create a new process, terminate an already completed process, or terminate a process that is unable to execute due to an event, and also be responsible for state transitions in process execution.

One, create process 1. event that caused the creation of the process in a multi-channel program environment, Only (AS) process (time) talents are executed in the system. So. To enable the program to execute. You must create a process for it. Causes a process to create a typical event that also has a process. Can have the following four categories: 1) User login In a time-sharing system, when a user types a login command at the terminal, assuming it is a legitimate user, the system will establish a process for the terminal and insert it into the ready queue. 2) Job schedule In a batch system, when the job scheduler is dispatched to a job according to a certain algorithm, it loads the job into memory, assigns it the necessary resources, and immediately creates a process for it and then inserts it into the ready queue.

3) service When a request is made by a user program in execution. The system will create a process specifically to provide the services that the user needs. For example, the user program requires file printing. The operating system creates a printing process for it so that not only can the print process execute concurrently with that user process, but it also makes it easier to calculate the time it takes to complete the print job. 4) App request

2. Process creation Process once the operating system discovers an event that requires the creation of a new process, it invokes the process creation primitive creat () creates a new process as described in the following steps. 1) apply blank PCB. obtain a unique numeric identifier for the new process request. and request a blank PCB from the PCB collection. 2) Allocate resources for the new process. allocates the necessary memory space for the program and data of the new process and the user stack.

Obviously. At this point the operating system must know the size of the memory required for the new process.

3 "initializes the process control block. The initialization of the PCB contains: ① initializes the identity information, fills the system-assigned identifier and the parent process identifier into the new PCB. ② initializes the processor state information. Point the program counter to the program's entry address so that the stack pointer points to the top of the stack. ③ initializes the processor control information to set the status of the process to ready or smart-ready state. For the priority level. It is generally set to the lowest priority unless the user presents a high-priority requirement in an explicit manner.

4) Insert the new process into the ready queue . Assume that the process-ready queue can accommodate new processes. The new process is inserted into the ready queue. ii. Termination of the Process 1. event that caused the process to terminate 1) normal end in any computer system, there should be an indication that the process has been completed. For example, in a batch system, a hold instruction or a terminating system call is usually arranged at the end of the program.

When the program executes to the hold command, an interrupt is generated. To notify the OS that this process is complete. 2) Abnormal end during process execution, the process is forced to terminate because of certain errors and failures.

This kind of unusual event is very numerous, common is: cross-border error. Protection is wrong. Illegal instruction, privileged command error, execution timeout, wait timeout, arithmetic operation wrong. I/O failure. 3) External intervention external intervention does not mean that an exception occurs during the execution of the process, but rather that the process terminates execution at the request of the outside world. These interventions are: operator or operating system intervention, parent process request. The parent process terminates.

2. The termination process of the process assumes that the system has occurred after an event of the above request to terminate the process. The OS invokes the process to terminate the primitive, and terminates the specified process as described in the following procedure. 1) based on the identifier of the terminated process. Retrieves the process's PCB from the PCB collection and reads the process status from it. 2) If the terminated process is in a running state, the process should be terminated immediately. The collocated dispatch flag is true. Used to indicate that the process should be dispatched again after it has been terminated. 3) If the process also has a descendant process. The entire descendant process should also be terminated. In case they become an uncontrolled process.

4) all resources owned by the process that will be terminated. or return it to its parent process. or return it to the system. The 5) removes the terminated process (its PCB) from the queue (or list) in which it is located. Wait for other programs to collect information. Third, blocking wake-up Span style= "FONT-FAMILY:SIMSUN; font-size:18px; Color: #ff0000 ">1. Events causing process congestion and wakeup 1) Request system service When the running process requests the operating system to provide services, for some reason the operating system does not immediately meet the requirements of the process. The process can only be turned into a blocking state to wait, and once the requirements are met, the process is awakened.

2 "start some action When a process initiates an action, assume that the process must continue to run after the operation has completed. You must first block the process to wait for the operation to complete and wake the process after the operation is complete. 3) new data has not arrived for the process of mutual cooperation, it is assumed that one of the processes needs to obtain the data talent that is provided by a (co-operative) process to process the data, so that the required data has not yet arrived, and the process only has (waits) to jam until the data arrives. The process is awakened. 4) no new work to do systems tend to set up some system processes with a specific function, and each time such a process completes its task, it blocks itself to wait for a new task to arrive. The process is awakened when a new task arrives. 2. Process blocking process The process that is running, when it finds one of these events, is unable to continue running, so it blocks itself by calling block primitives. It can be seen that the process blockage is an active behavior of the process itself.

After entering the block process, because the process is still running, you should stop running immediately, change the current state in the process control block from run to jam, and insert the PCB into the blocking queue. Assuming that the system has multiple blocked queues blocked by different events, the process should be plugged into a blocked (wait) queue with the same event. At last. The scheduler makes another dispatch and assigns the processor to a ready process. and to switch, that is, to retain the processor state of the blocked process (in the PCB). Then set the CPU environment on the processor state in the PCB of the new process.

3. Process wake-up process when the event that is expected by the blocked process is present. If the I/O is complete or the expected data has arrived, wake-up Primitive wakeup () is invoked by the process (for example, a process that has exhausted and freed the I/O device) to wake the process waiting for the event. the process of waking up the primitive is to first remove the blocked process from the blocking queue waiting for the event and change the current state of its PCB from blocked to ready. The PCB is then inserted into the ready queue.

The role of process control in process management

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.