Scheduling Algorithm Basics

Source: Internet
Author: User
Author: Jeffrey. Zhu

My blog:Http://blog.csdn.net/gueter/

 

 

0. What is scheduling?

Long-term scheduling: which oneProgramSelected by the system and created a process to run it

Interim scheduling: determines whether the process is transferred to the memory.

Short-term scheduling: Which process receives processor resources (usually called scheduling): single, multi, and Real-Time Processor Scheduling

 

 

I,Single processor Process SchedulingAlgorithm

FCFSAlgorithm (FIFOAlgorithm, preemptible)

The cyclic execution algorithm (time slice rotation method, preemptible) has the following Disadvantages:I/OResource usage imbalance occurs when an operation-intensive process or a processor uses a intensive process. Improvement: the virtual loop execution algorithm, which isFCFSAdd an auxiliary process Queue Based onI/OThe pending process is nowI/OIf the operation is completed, it enters the secondary queue instead of the normal queue. When the new processor time slice comes, the secondary queue gives priority to processor control, the running time does not exceed the time remaining in the time slice it obtained in the previous time.

SPNsAlgorithm (non-preemptible): processes with the shortest running time are preferentially run. Disadvantage: the processor is never equal for a long time

SRTAlgorithm (SPNsAlgorithm preemptible version): always selects the process running with the shortest time remaining.

HrrnAlgorithm: the highest response time ratio principle is observed when processes are selected:R = (W + S)/s, WIs the waiting time, SThe expected running time.

Feedback Algorithm: the shortest run time in the past is preferred. Programming Method: Create a process and enter the queue with the highest priority. After each running period of time, lower the level to wait for the next running, so that the recurrence is completed.

 

 

II,Multi-Processor Scheduling Algorithm

1. multi-processor system classification:

Loosely Coupled: the total system is composed of autonomous subsystems.

Tightly coupled: A group of processors share one memory and are under the control of an operating system. Also divided into: master-slave type (such as generalArm+ DedicatedDSP); Peer-to-peer system

2. Problems to be Solved during multi-processor process scheduling:

2.1 processor-based process allocation problems

Peer-to-Peer Model, multiple processors are considered as a processor resource pool. allocation methods: static methods (after allocation, the processor is not changed within the process lifecycle) and dynamic methods (allows you to change the processor, corrected uneven processor load of the static method)

Considering the inequality of the Process status, the core process generally runs on a specific processor, and the other processor only runs the user process, which causes the following problems: A single processor failure will cause the entire system to crash (Innovation: whether a composite scheduling algorithm can be implemented first/In this way, when a single processor fails, the peering type is used ??), Peer-to-peer, implementation is more complex, and many systems adopt the compromise between the two methods.

2.2Multi-channel programming on a single processor

The loose coupling processor is relatively independent. Multi-Channel program design should be considered. The tightly coupled processor is not necessary. The overall system performance must be considered. A multi-threaded program only works when all threads are running, program performance can be significantly improved.

2.3Actual process allocation problems

The process forms several queues and obtains the processor from the processor resource pool according to a certain scheduling policy. The research shows that the difference in the system performance of the multi-processor caused by the difference in scheduling algorithms is not obvious, this effect fades out as the number of processors increases.

3. Thread Scheduling Solution

As a research hotspot, there are four outstanding solutions:

3.1 load sharing method (Load Sharing)

All the waiting threads are in a queue, and the idle processor selects a thread to run according to a certain policy, regardless of which process it belongs. Advantages:1The computing load is evenly distributed in the processor;2The central scheduling program does not need to exist. When a processor is idle, it runs on it and selects the next thread to be run;3Single processor algorithms can be easily used here. Disadvantage: waiting for unified management of thread queues must be mutually exclusive. As a result, it is unlikely that all threads of an application obtain control of the processor at the same time, so that program performance is not optimal.

3.2 group scheduling method (Gang Scheduling)

A coupled thread is used to specify the same number of processors one to one and run them simultaneously. Advantages: reduces blocking synchronization, process switching, and group scheduling, and reduces the execution frequency of scheduling programs.

3.3 Processor Allocation Method (Dedicated processor assignment)

The assignment algorithm specified by the processor is an extreme condition of the group scheduling policy. The idea is that a group of processors are allocated to the program during the life cycle of an application, each thread occupies one processor because of waitingI/OBut the application performance is more important than the utilization of a single processor. All this method can reduce process switching and improve program performance, this scheduling method is good in a multi-processor system.

3.4 Dynamic Scheduling Method (Dynamic Scheduling)

The tool is used to adjust the system load in real time during process running, so that system resources can be used to the maximum extent.

 

 

 

Iii. Real-Time Scheduling Algorithm

0 basic real-time operating system knowledge

0.1 real-time classification:

Hard Real-Time (Hard Real-Time): If the system fails to start or end a real-time task at a certain deadline, the final result will be disastrous.

Soft Real-Time (Soft Real-Time): The end time for processing the task to start or end is only an expected value. Even if the end time is exceeded, the calculation result is meaningful.

0.2 differences between a real-time system and a common operating system:

Task Processing certainty (Interrupt requests to the corresponding task Start Time), Response Sensitivity(System Response Request time)Users participate in control, reliability, and fault protection measures.

0.3 goals

Interrupt handling and task allocation speed as quickly as possible.

0.4 two requirements:

Logical computing results are required;

It must meet certain time requirements.

1. Real-time algorithm classification (3Angle)

Does the system perform scheduling analysis? (Information Required for scheduling analysis includes the periodic arrival time, execution time, periodic end time, and priority of each task)

Is it dynamic analysis or static analysis?

Whether the analysis results really affect the real-time dispatching of processes.

Based on this, the real-time scheduling algorithm can be divided4Class:1.1 St(Static table-driver) Class:

Make a real-time scheduling schedule based on the relevant information and schedule the process strictly according to the table. It is suitable for periodic tasks with poor flexibility.

1.2 SSP(Static Priority-driven preemptive) Class:

Static scheduling schedules are also required, which only provide a reference when assigning priority to each task. In actual operation, preemptible scheduling is adopted based on the priority (for exampleRMSScheduling Algorithm ).

1.3 DP(Dynamic Planning-based) Class:

The scheduling plan is dynamically planned during running, and is accepted only when new task requests are satisfied. After the request is accepted, the scheduling algorithm determines when to call the plan.

1.4 DBE(Dynamic best effort) Class:

Without scheduling analysis, the system does its utmost to meet the requirements of the task and directly discards the processes that do not meet the requirements. Advantages: easy to implement. Disadvantage: The task deadline cannot be predicted. It is currently used by many commercial real-time operating systems.

2 time limit Scheduling (Deadline Scheduling)

The real-time scheduling algorithm needs to provide more information about the task itself:

Time when the task is ready to run

Task Start Time Limit

Maximum time for task completion

Time consumed by Task Processing

Resource requirements

Task priority

It is best to divide a task into two subtasks (the upper half and the lower half are similar): the processing is in urgent need; more options are available.

Real-time scheduling needs to answer the following two questions:

Which of the following tasks can be scheduled? What preemptible type is selected?

About the second question: If you emphasize the upper limit of time at the beginning of the task, the non-preemptible scheduling method is very effective.

3 rmsScheduling (Rate Monotonic Scheduling)

SSP ( static priority-driven preemptive ) class has been mentioned, it uses the static scheduling method to give priority to each task. In actual operation, it is scheduled by priority. Obviously, RMS method is suitable for periodic tasks. The priority of a task is inversely proportional to its cycle.


4 RT-Linux RT-LinuxA Software Simulator for hardware control devices is implemented, that is, the so-called virtual machine technology is used,LinuxAs a task runs on a small real-time kernel, the task has a lower priority than other user-level real-time tasks. Therefore,LinuxProcessor control can be obtained only when no real-time task is running.RT-LinuxThe running process is as follows:LinuxSends a request to interrupt prohibition. The kernel intercepts the request in real time, records the request, and pretends to respond.LinuxRequests that disable hardware interruption are not ignored by the actual hardware. When an interrupt signal arrives, the kernel intercepts and processes it in real time.LinuxThe internal status must make way for real-time task processing.RT-LinuxTwo real-time scheduling algorithms are available:EDFAlgorithm (the first time the real-time process reaches the deadline );RMSAlgorithm

 

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.