108 Process Scheduling

To run multiple processes alternately, the operating system must be scheduled for these processes, the scheduling is not carried out immediately, but need to follow certain rules , thus there is a scheduling algorithm process.

First, the FCFS scheduling algorithm

First-come, first-served (FCFS) scheduling algorithm is a simple scheduling algorithm, the algorithm for job scheduling can also be used for process scheduling. FCFS algorithm is more conducive to a long job (process), to the detriment of short job (process). It can be seen that the algorithm is suitable for CPU busy type work, to the detriment of heavy I / O type of job (process).

Second, the short operating priority scheduling algorithm

Short job (the process) scheduling algorithm and (SJ / PF) refers to short or short process priority job scheduling algorithm, the scheduling algorithm is used for both operations, it can also be used to schedule processes. But its work for long; not guarantee the urgency of the job (process) to be in time; the length of the job is only to be estimated.

Third, the round-robin method

Round-robin (Round Robin, RR) method basic idea is to have each process in the ready queue waiting time and enjoy the service proportional to the time. In the round-robin method, the processing time of the CPU time slice needs to be divided into a fixed size, e.g., several tens of milliseconds to hundreds of milliseconds. If a process run out of time slice prescribed system after being selected schedule, but not required to complete the task, it is the release of their self-occupied CPU and discharged at the end of the ready queue, waiting for the next scheduling. At the same time, the process scheduler went Scheduling a process currently in the queue ready.

Clearly, round-robin scheduling can only be used to allocate some resources can be preempted . These resources can be preempted at any time be deprived, and they can be reassigned to another process. A CPU is to seize resources. However, printers and other resources can not be preempted. Because the job scheduling assignment to all the system hardware resources, in addition to the CPU, which comprises a non-preemptive resources, it does not use rotation job scheduling method.

In the rotation method, the length of the time slice selected is important . First, select the length of the time slice will directly affect the response time and system overhead. If the chip length is too short, the scheduler increases the number of processors preemption. This will make the process context switches also greatly increased, thereby increasing the system overhead. Conversely, if the time slice selected length is too long, for example, to ensure that a time slice execution time required for the longest queue in the ready process can be executed, into the round-robin method a first come first served. Chip length is selected to determine the system response time requirements of the ready queue and the maximum number allowed in accordance with processes.

In the round robin, adding to the process ready queue there are three kinds of situations:

  1. The first is to divide its time slice is used up, but the process has not been completed, return to the end of the ready queue waiting for the next scheduled execution to continue.
  2. The second case is given to the time slice of the process did not run out, just because the request I / O or due process of mutual exclusion and synchronization relationship is blocked. After unblocking return to the ready queue.
  3. The third case is that the new process is created to enter the ready queue.

If the difference between these treatment processes, giving different priorities and time slice from a visual point of view, the system can further improve service quality and efficiency. For example, we may be the ready queue in accordance with the process of arriving at the reasons for blocking the ready queue and the type of process is blocked into different ready queues, each arranged according to the principle of FCFS, process among different priority queues enjoy, but at the same the same priority queue. In this way, when a process after the completion of the implementation of its time slice, or wake up from sleep and being created, enter different ready queue.

Fourth, multi-level feedback queue

As a variety of process scheduling algorithm described earlier have certain limitations. Such as short process priority scheduling algorithm, only to take care of the short process while ignoring the long process, but did not specify if the length of the process, the short process priority-based preemptive scheduling algorithm and the length of the process will not be used.

The multi-level feedback queue scheduling algorithm is not necessary to know in advance the time required to perform a variety of processes, but also to meet the needs of various types of processes, so it is now being recognized as a better process scheduling algorithm. In systems that employ multiple feedback queue scheduling algorithm, the scheduling algorithm implementation process is as follows.

  1. A plurality of ready queues to be provided, and given different priority for each queue. The first has the highest priority, followed by a second queue of queues, each queue priority remaining decreased by one. The algorithm gives each queue process execution time slice size can vary, the higher the priority queue, the execution time specified for each sheet the less process. For example, the second queue time slices than a first time slice twice as long as the queue, ......, i + 1-th time slot queue than the queue i-th time slice twice as long.
  2. When a new process into the memory, first put it at the end of the first queue, waiting in line according to the principle of FCFS scheduling. When it came time to perform the process, as it can be completed within the time slice, you can prepare evacuation system; if it is not completed at the end of a time slice, the process scheduler then transferred to a second end of the queue, and then Likewise waiting to be scheduled according to the principle of FCFS performed; if it is running in a second time slot queue is not yet completed, then turn it into a third queue, ......, and so on, when a long job (process) from after a queue of n sequentially down queue, the queue will be taken at the n-th time run round-robin.
  3. Only when the first queue is empty, the process scheduler dispatches a second run queue; only if the first 1 ~ (i-1) when the queue was empty, the scheduler will process the i-th run queue. If the processor is the i-th process in the queue for a service, but also a new process into the high priority queue (first to (any queue i-1)), the new process at this time will preempt running the processor processes, i.e., the process by the scheduler is running back into the end of the queue i, allocated to the processor to process the new arriving high priority.

Guess you like

Origin www.cnblogs.com/XuChengNotes/p/11506301.html