Several common operating system process scheduling algorithms

Source: Internet
Author: User

[Loaded from: Http://www.tuicool.com/articles/B3MRRv]

First, first come service and short job (process) priority scheduling algorithm 1. First come first service scheduling algorithm

First come first service (FCFS) scheduling algorithm is the simplest scheduling algorithm, which can be used for both job scheduling and process scheduling. When this algorithm is used in job scheduling, each schedule selects one or more jobs that first enter the queue from the fallback job queue, puts them into memory, assigns them resources, creates processes, and then puts them in the ready queue. When the FCFS algorithm is used in the process scheduling, each schedule is to select a process from the ready queue that is first entered into the queue, assigning the processor to it and putting it into operation. The process has been running until it has completed or an event has been blocked before discarding the processor.

2. Short job (process) Priority scheduling algorithm

Short job (process) Priority scheduling algorithm SJ (P) F, refers to the algorithm for short or short process priority scheduling. They can be used for job scheduling and process scheduling, respectively. The scheduling algorithm for short job first (SJF) is to select one or several jobs with the shortest estimated run time from the fallback queue and transfer them into the memory run. The short process first (SPF) scheduling algorithm chooses a process that estimates the shortest running time from the ready queue, assigns the processor to it, causes it to execute immediately and executes until it is completed, or when an event is blocked to abort the processor and then re-dispatched.

Second, high priority priority scheduling algorithm 1. Types of priority scheduling algorithms

The highest priority priority (FPF) scheduling algorithm is introduced in order to take care of the urgent operation, so that it gets preferential treatment after entering the system. This algorithm is often used in batch processing system, as a job scheduling algorithm, also as a process scheduling algorithm in a variety of operating systems, can also be used in real-time systems. When the algorithm is used for job scheduling, the system will select several of the highest priority jobs from the fallback queue to load the memory. When used for process scheduling, the algorithm is to assign the processor to the ready queue of the highest priority process, at this time, the algorithm can be further divided into the following two kinds.

1) Non-preemptive priority algorithm

In this way, once the system has allocated the processor to the highest priority process in the ready queue, the process continues until it is completed, or the system can reassign the processor to another process that has the highest priority because of an event that causes the process to abandon the processor. This scheduling algorithm is mainly used in batch processing systems, and can also be applied to some real-time systems where real-time requirements are not stringent.

2) preemptive priority scheduling algorithm

In this way, the system also assigns the processor to the process with the highest priority and makes it execute. During its execution, however, as soon as another process with its higher priority arises, the process scheduler immediately stops the execution of the current process (the one that has the highest priority) and re-assigns the processor to the new highest priority process. Therefore, when this scheduling algorithm is used, the priority pi is compared with the priority PJ of the executing process J whenever a new ready process I is present in the system. If PI≤PJ, the original process PJ will continue to execute, but if it is PI>PJ, then immediately stop the execution of PJ, do a process switch, so that I process into execution. Obviously, this preemptive priority scheduling algorithm can better meet the requirements of urgent operation, so it is often used in the demanding real-time system, and in the batch processing and timeshare system with high performance requirements.

2. High response ratio priority scheduling algorithm

In batch processing system, the short job first algorithm is a better algorithm, and its main disadvantage is that the operation of long operation is not guaranteed. If we can introduce the dynamic priority described above for each job, and the priority of the job increases with the wait time to increase at rate A, then the long job waits for a certain period of time, there must be a chance to assign to the processor. The change law of this priority can be described as:

As the sum of waiting time and service time is the response time of the system to the job, the priority is equal to the response than the RP. Accordingly, it can also be expressed as:

It can be seen from the above formula:

(1) If the waiting time of the job is the same, the shorter the service time, the higher the priority, and therefore the algorithm is advantageous to the short job.

(2) When the time required for the service is the same, the priority of the job depends on its waiting time, the longer the waiting time, the higher the priority, so it realizes the first to serve first.

(3) For long jobs, the priority of the job can increase with the waiting time, and when its waiting time is long enough, its priority can be raised to high, thus also can obtain the processor. In short, the algorithm not only takes care of the short work, but also takes into account the order of the arrival of the operation, will not make long work long-term service. Therefore, the algorithm realizes a good tradeoff. Of course, when using this algorithm, the response ratio calculation must be done before each dispatch, which increases the system overhead.

Three, time-slice-based rotation scheduling algorithm 1. Time Slice Rotation method

1) Fundamentals

In the early time-slice rotation, the system queues up all the ready processes on a first-come-first-served basis, allocating the CPU to the team's first process and making it perform a time slice each time it is scheduled. The size of the time slice is from several ms to hundreds of Ms. When the elapsed time slice runs out, the clock interrupt request is made by a timer, which signals the scheduler to stop the execution of the process and sends it to the end of the ready queue, and then assigns the processor to the new team first process in the ready queue, while also allowing it to execute a time slice. This ensures that all processes in the ready queue can receive a time slice of processor execution times within a given time. In other words, the system can respond to requests from all users within a given time.

2. Multilevel Feedback Queue scheduling algorithm

The various algorithms used in the process scheduling have some limitations. such as the short process first scheduling algorithm, only take care of the short process and ignore the long process, and if the length of the process is not indicated, the short process first and process-based preemptive scheduling algorithm will not be used. The multi-level feedback queue scheduling algorithm does not need to know the execution time of various processes in advance, but also can satisfy the needs of various types of processes, so it is now recognized as a good process scheduling algorithm. In the system using multilevel feedback queue scheduling algorithm, the implementation process of scheduling algorithm is described below.

(1) You should set up multiple ready queues and assign different priorities to each queue. The first queue has the highest priority, the second queue is followed, and the priority of the remaining queues is lowered one by one. The algorithm gives each queue the size of the process execution time slices, and in the higher priority queue, the execution time slices for each process are smaller. For example, the time slice of the second queue is one times longer than the time slice of the first queue ..., the time slice of the i+1 queue is one times longer than the time slice of the I queue.

(2) When a new process enters memory, it is first placed at the end of the first queue and queued for dispatch by the FCFS principle. When it is time for the process to execute, it can prepare the evacuation system if it can be completed on the chip, and if it is not completed at the end of a time slice, the scheduler moves the process to the end of the second queue, and then similarly waits for dispatch execution by the FCFS principle, if it is still not completed after running a time slice in the second queue Then put it in the third queue, ..., and so on, when a long job (process) from the first queue down to the nth queue, in the nth queue will be taken by the time slice rotation operation.

(3) The scheduler dispatches the processes in the second queue only when the first queue is idle, and the processes in queue I are scheduled to run only if the 1~ (i-1) queue is empty. If the processor is servicing a process in queue I, and a new process enters a higher priority queue (1~ (i-1)), then the new process will preempt the processor that is running the process, that is, the scheduler puts the running process back to the end of the queue. Assign the processor to the new high priority process.

Several common operating system process scheduling algorithms

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.