Process Scheduling Algorithm Linux Process Scheduling Algorithm and scheduling algorithm linux Process

Source: Internet
Author: User

Process Scheduling Algorithm Linux Process Scheduling Algorithm and scheduling algorithm linux Process

This section describes the process scheduling algorithm of the operating system.

  • There are three types of Operating System Scheduling: 1. Remote Scheduling(Create a new process); 2. Middle-end scheduling(Part of the switching function); 3. Short-range Scheduling(Which process will be executed next time)

This is short-range scheduling, which can be simply described as process scheduling.

When the following situations occur, the short-range scheduler will be called, and then the process will be executed next time.

  • Clock interruption
  • I/O interruption
  • Operating System Call
  • Signals (such as semaphores)

 

  • Process Scheduling Algorithm:
    • Service First (FCFS)
    • Short job priority (SPNs)
    • Shortest time remaining (SRT)
    • Time slice Rotation
    • Highest response rate is preferred
    • Fair Share Scheduling

 

 

  • Service first


Just like the name, which process gets the processor time first, and uses a queue to temporarily store the process waiting for the processor. The advantage is that it is easy to implement (too easy to feed). Disadvantages, the smelly and long process is very unpleasant. For example, if the people in front of the canteen are not buying and the people in the backend are waiting in line, what will happen to the people in the backend? People are hungry! At the same time, if a person who is about to starve to death is in urgent need of meals, this would be embarrassing (the emergency process cannot be handled, and the priority process is in hunger ), so with the priority queue, the first-come service algorithm is not very good, because there are always smelly and long processes, and no one is happy to queue, and the processing time is unfair.

  • Short job priority

Because the service is not good first, short jobs are given priority. It is also very rough to set the priority of a process job with a short execution time. That is to say, the shorter the process time, the more advanced the execution, it looks better, it's not a waste of time, but do you want to feel like a long process, a group of short processes, and then a short process all the time? This is the rhythm of a long process to be starved to death, are people and parents wrong? If it is a preemption method (see the version of the shortest time remaining), it will be even worse. If it comes to a shorter version, don't think about it...

  • Shortest time remaining

That is, the short job is given priority.Preemptible versionSaid his shortcomings. There are still 10 time units left for the currently executed process, but there has been a group of processes that run as long as 2 time units, then the current process will be preemptible and then starved to death ..

  • Time slice Rotation

Since the above algorithms may have hunger processes, it is unfair to let every process be executed for a while? Every process has the opportunity to run on the processor. It looks very harmonious, but it still does not solve the priority problem, and the priority is not well controlled. For example, there are urgent processes that need to be executed immediately, it is hard to do. In addition, the specific situation of each process is also different. For example, there are I/O-consuming processes, and the processor-consuming processes actually occupy different time in the same event chip, we really want the same time to take up the processor, so it's fair. In this case, slice rotation also has shortcomings.

  • Highest response rate is preferred

What is response ratio? Let's take a look at this formula:R = (w + s)/s, WhereR is the response ratio, w is the time waiting for the processor, and s is the expected service time.In shortThe response ratio is the time from the process joining the waiting queue until the execution is completed divided by the time when the process uses the processor., This response is relatively high, it proves that the process has been waiting for a long time, it is estimated that it will be very hungry, first let it eat!

  • Fair Share Scheduling

The scheduling method used by common processes in Linux is an instance of fair and shared scheduling.Completely fair scheduling algorithm (CFS)Although it cannot be fair... For more information, see my other blog .. Portal call !! : Http://www.cnblogs.com/lenomirei/p/5516872.html

  • Process scheduling solution in Linux

In Linux, process scheduling is divided into two types:1. Common process; 2. Real-time process

The priority of a real-time process is always higher than that of a common process. That is to say, a real-time process can seize a common process as long as it comes, and it will not stop executing it until all the real-time processes are completed, the processor is used by common processes.

As mentioned earlier,Common process scheduling adopts SCHED_NORMAL for completely fair scheduling (CFS ).

However, the scheduling method used by real-time processes is simple and crude,Linux provides two real-time scheduling policies: SCHED_FIFO and SCHED_RR.

SCHED_FIFO: a simple first-in-first-out scheduling algorithm. If no time slice is used, it can only be preemptible by FIFO or SCHED_RR with a higher priority.

SCHED_RR: time slice rotation method. The priority is higher than SCHED_FIFO, and SCHED_FIFO can be preemptible.

The real-time process scheduling does not have a real-time priority. It uses a static priority. It will not change after the priority is set at the beginning.

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.