"Operating System" real-time scheduling

Source: Internet
Author: User
Tags current time inheritance
Basic conditions for implementing real-time schedulingProvide the necessary scheduling information (readiness time, start deadline and completion deadline, processing time, resource requirements, priority) The system has strong processing power. In the real-time system, if the processing capacity of the processor is not strong enough, it may be because the processor is too busy to get some real-time tasks can not be processed in time. Using preemptive scheduling mechanism with fast switching mechanism real-time scheduling of CPU processing power

Single Processor:

M: Number of real-time tasks, CI: Each processing time, pi: Cycle time

For example: There are 6 hard real-time tasks, the cycle time is three MS, each processing time is ten MS, the system is not scheduled.

Multiprocessor: (N: Number of processors)

classification of real-time scheduling algorithms Hard real-time scheduling According to the nature of real-time tasks (that is, the strength of time constraints) : Must meet the task deadline requirements, missed serious consequences. Soft real-time scheduling algorithm: expected to meet the task deadline requirements, Miss can
Endure. by dispatch mode

Non-preemptive scheduling algorithm non-preemptive rotary scheduling algorithm: In the industrial production of the group control system. Non-preemptive priority scheduling algorithm: It is used in real-time control system with a certain period of demand.

Preemptive scheduling algorithm (according to preemption time) priority scheduling algorithm based on clock interrupt preemption preemption scheduling algorithm for preemptive scheduling algorithm

first cutoff time First algorithm

The algorithm determines the priority of a task based on the start and finish deadlines of the task. The earlier the cutoff time, the higher the priority. The tasks in the ready queue are arranged according to their deadlines, and the first task of the team allocates the processor.

Non-preemptive scheduling method for non-periodic real-time tasks
Preemptive scheduling method for periodic real-time tasks non-preemptive scheduling for aperiodic real-time tasks

preemptive scheduling method for periodic real-time tasks

There are two recurring tasks, Task A has a cycle time of 20ms, each cycle processing time is 10ms, task B has a cycle time of 50ms, each cycle processing time is 25ms. The arrival time, deadline and execution time of the two tasks are as follows:

Fixed priority scheduling (A has a higher priority)

Fixed priority scheduling (B with higher priority)

First deadline completion time first algorithm

minimum Relaxation priority algorithm

Minimum relaxation priority algorithm (Llf,least laxity first)
Low relaxation = high urgency

The algorithm determines the priority of a task based on the degree of urgency (or relaxation) of the task. The higher the urgency of the task, the higher its priority and the priority it performs.

The algorithm adopts preemptive scheduling method, which can be used to schedule periodic real-time tasks with completion deadlines.

Relaxation = Must finish time-the remaining run time itself-current time

For example:

In a real-time system, there are two periodic real-time tasks A and B, task A is required to execute every 20ms, execution time is 10ms, task B is only required to execute per 50ms, and the execution time is 25ms. The minimum relaxation priority algorithm is used to schedule the test.

Priority Inversion

Priority inversion Phenomenon
A high-priority process (or thread) is delayed or blocked by a low-priority process (or thread).

For example, there are three completely independent processes, task A, task B, and taskc,task A have the highest precedence, task B follows, and task C is the lowest. Task A and Task C share the same critical resource X.

High-priority processes are prioritized according to the priority principle. However, in this case, Task A and task C share the same critical resource, and there is an unreasonable phenomenon.

The high-priority process task A is blocked due to the low-priority process task C, and because the presence of the low-priority process task B prolongs the blocked time. resolution of priority inversion

Priority Ceiling

Process Task C is not allowed to be preempted by a processor that is occupied by task C when it enters the critical section. In this case, Task C has the highest precedence (priority Ceiling).

If the critical sections in the system are short and not much, the method is feasible. Conversely, if the task C critical section is very long, the high-priority process task A still waits for a long time and its effect is unsatisfactory.

Priority inheritance

When the high-priority process task A is going into the critical section using critical resource X, if there is already a low-priority process, task C is using the resource, you can use the priority inheritance method.

At this point, task A is blocked, on the other hand, the priority of task A is inherited by task C, and is persisted until task C exits the critical section.

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.