Role of process control in Process Management

Source: Internet
Author: User
Zookeeper process control is the most basic function in process management. It is used to create a new process, terminate a completed process, or terminate a process that is unable to run due to an event. It can also be responsible for status conversion during process running. 1. Create a process 1. Events that cause Process CreationIn a multi-program environment, only (as) processes (hours) can run in the system. Therefore, to make the program run, you must create a process for it. A typical event that causes a process to create another process can be divided into the following four categories: 1) after a user logs on to the time-sharing system and enters a logon command on the terminal, if the user is a legal user, the system creates a process for the terminal and inserts it into the ready queue. 2) Job Scheduling in the batch processing system. When the job scheduling program schedules jobs to a job according to a certain algorithm, it loads the job into the memory and allocates necessary resources for it, and immediately create a process for it, and then insert it into the ready queue. 3) provide services when a user program in the running state makes a request, the system will create a process to provide the services required by the user. For example, the user program requires file printing, the operating system will create a printing process for it, which not only allows the printing process to run concurrently with the user process, but also facilitates the time spent to complete the printing task. 4) in the above three cases, application requests are all created by the system kernel for it, and these events are based on the needs of application processes, it creates a new process so that the new process can complete a specific task in a concurrent running mode. 2. process creation processOnce the operating system discovers an event that requires a new process to be created, call the Process Creation primitive creat () to create a new process following the steps below. 1) apply for blank PCB. Apply for a unique digital identifier for the new process and obtain a blank PCB from the PCB collection. 2) Allocate resources to the new process. Allocate necessary memory space for new processes, programs, data, and user stacks. Obviously, the operating system must know the memory size required by the new process. 3) initialize the process control block. The PCB initialization includes: ① initialization ID information. Fill in the identifier assigned by the system and the parent process identifier in the new PCB. ② Initialize the processor status information so that the program counter points to the program's entry address and the stack pointer points to the top of the stack. ③ Initialize the processor control information and set the state of the process to the ready or static ready state. For priority, it is usually set to the lowest priority, unless you explicitly request a higher priority. 4) Insert the new process into the ready queue. If the process ready queue can accept the new process, the new process is inserted into the ready queue. 2. Process Termination 1. Events that cause Process Termination1) In any computer system, there should be an indication that the process has been completed. For example, in a batch processing system, a hold command or a terminated system call is usually arranged at the end of the program. When the program runs the hold command, an interruption will occur, notifying the OS that the process has been completed. 2) The process is terminated due to some errors and faults during the process running. There are many such abnormal events, including out-of-bounds errors, protection errors, illegal commands, privileged commands, running timeout, waiting timeout, arithmetic operation errors, and I/O faults. 3) external intervention does not mean that an abnormal event occurs during the running of the process, but that the process is terminated upon external requests. These interventions include operator or operating system intervention, parent process request, and parent Process Termination. 2. Process TerminationIf the system has an event that requires process termination, the OS calls the Process Termination primitive and terminates the specified process according to the following process. 1) Based on the identifier of the terminated process, the PCB of the process is retrieved from the PCB set to read the Process status. 2) If the terminated process is in the execution status, it should be immediately terminated and the parallel scheduling flag is true. Indicates that the process should be rescheduled after it is terminated. 3) if there are any child processes, all child processes should be terminated to prevent them from being uncontrollable. 4) return all resources owned by the terminated process to its parent process or to the system. 5) Remove the terminated process (its PCB) from the queue (or linked list) and wait for other programs to collect information. Iii. Blocking and Wakeup 1. Events that cause process blocking and Wakeup1) Request System Service when the process being executed requests the operating system to provide the service, the operating system does not immediately meet the requirements of the process for some reason, the process can only be switched to a blocking state to wait. Once the requirement is met, the process is awakened. 2) Start an operation. After a process starts an operation, if the process must continue after the operation is completed, it must first block the process and wait until the operation is completed, after this operation is completed, wake up the process. 3) The new data has not yet reached the process of mutual cooperation. If one process needs to obtain the data provided by another (cooperative) process before it can run to process the data, it means that the required data has not yet arrived, and the process is only blocked (waiting). After the data arrives, the process is awakened. 4) when there is no new job to do, the system usually sets some system processes with a specific function. Every time a process completes a task, it blocks itself to wait for the new task to arrive, when a new task arrives, the process is awakened. 2. Process BlockingThe process being executed. After an event is detected, the process blocks itself by calling the blocking primitive block. It can be seen that process congestion is an active action of the process itself. After entering the block process, because the process is still in the execution status, you should immediately stop the execution, change the current status in the process control block from execution to blocking, and insert the PCB into the blocking queue. If multiple blocking queues are blocked due to different events, the process should be inserted into the blocking (waiting) queue with the same events. Finally, the scheduler will re-schedule the process, allocate the processor to another ready process, and perform the switchover, that is, retain the processor status of the blocked process (in the PCB ), then, set the CPU environment according to the processor status in the PCB of the new process. 3. Process wake-up processWhen an event is expected to occur by a blocked process, such as when I/O is completed or the expected data has arrived, processes that have used up and released the I/O device) Call the wake-up primitive wakeup () and wait for the event process to wake up. The process of wake-up primitive execution is: first remove the blocked process from the blocking queue waiting for the event, and change the current status in its PCB from blocking to ready, then insert the PCB into the ready queue.

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.