Presentation is loading. Please wait.

Presentation is loading. Please wait.

Real-Time Scheduling --- An Overview Real-Time Scheduling --- An Overview Xiaoping He.

Similar presentations


Presentation on theme: "Real-Time Scheduling --- An Overview Real-Time Scheduling --- An Overview Xiaoping He."— Presentation transcript:

1 Real-Time Scheduling --- An Overview Real-Time Scheduling --- An Overview Xiaoping He

2 What is Real Time System  Real Time System (RTS):  A computer-controlled mechanism in which there are strict timing constraints on the computer’s actions.

3 Real-Time System bConsists of four parts: Physical ProcessPhysical Process --controlled by the computer for some productive end --controlled by the computer for some productive end SensorsSensors --converts state of physical process into information analog or digital --converts state of physical process into information analog or digital ComputersComputers --will work based on infromation from sensors, deduces state of physical process and issues commands to control the process. --will work based on infromation from sensors, deduces state of physical process and issues commands to control the process. ActuatorsActuators --will response to commands issued by computer, modifies the physical process. --will response to commands issued by computer, modifies the physical process.

4 Real-Time System bCharacteristics: DeterminismDeterminism It is concerned with how long an operating system delays before acknowledging an interrupt. It is concerned with how long an operating system delays before acknowledging an interrupt. ResponsivenessResponsiveness It is concerned with how long, after acknowledgment, it takes an operating system to serve the interrupt. It is concerned with how long, after acknowledgment, it takes an operating system to serve the interrupt. User ControlUser Control It is essential to allow the user have control over task priority. The user should be able to distinguish between hard and soft tasks and to specify relative priorities within each class. It is essential to allow the user have control over task priority. The user should be able to distinguish between hard and soft tasks and to specify relative priorities within each class. ReliabilityReliability It is very important because it is responding to and controlling events in real time. It is very important because it is responding to and controlling events in real time. Fail-soft operationFail-soft operation It is refers to the ability of a system to fail in such a way as to preserve as much capability and data as possible. It is refers to the ability of a system to fail in such a way as to preserve as much capability and data as possible.

5  Real-Time Computing:  Hard-Real-Time Task It must meet its deadline, otherwise it will cause undesirable damage or a fatal error to the system.  Soft-Real-Time Task It has a associated deadline that is desirable but not mandatory, it still makes sense to schedule and complete the task even if it has passed its deadline. It has a associated deadline that is desirable but not mandatory, it still makes sense to schedule and complete the task even if it has passed its deadline.

6 Terminology b Static versus dynamic Scheduling Static Scheduling: the scheduling algorithm has complete knowledge of the task set and its constraints.Static Scheduling: the scheduling algorithm has complete knowledge of the task set and its constraints. Dynamic Scheduling: this algorithm has complete knowledge of currently active tasks, but didn’t know new task activation. So this kind of scheduling changes over time.Dynamic Scheduling: this algorithm has complete knowledge of currently active tasks, but didn’t know new task activation. So this kind of scheduling changes over time.

7 Terminology (continue) b Periodic versus aperiodic tasks Periodic task: the requirement may be stated as "once per period T" or "exactly T units apart".Periodic task: the requirement may be stated as "once per period T" or "exactly T units apart". Aperiodic task: has a deadline by which it must finish or start, or it may have a constraint on both start and finish time.Aperiodic task: has a deadline by which it must finish or start, or it may have a constraint on both start and finish time.

8 Uniprocessor Scheduling Uniprocessor Scheduling bTypes of scheduling Long-term scheduling: This is a decision to add a new process to the set of processes that are currently active. It is performed when process is created.Long-term scheduling: This is a decision to add a new process to the set of processes that are currently active. It is performed when process is created. Medium-term scheduling: is a part of the swapping function. The decision to add process to the set of processes that are partially or fully on main memory (swapping).Medium-term scheduling: is a part of the swapping function. The decision to add process to the set of processes that are partially or fully on main memory (swapping). Short-term scheduling: is called dispatcher who decide which process to be executed next.Short-term scheduling: is called dispatcher who decide which process to be executed next. I/O scheduling: The decision as to which process’s pending I/O request shall be handled by an available I/O deviceI/O scheduling: The decision as to which process’s pending I/O request shall be handled by an available I/O device

9 Scheduling and Process state Transitions

10 Scheduling Policies b First Come First Served (FCFS) The simplest scheduling policy which performs much better for long processes than short ones. See text book example page391 The simplest scheduling policy which performs much better for long processes than short ones. See text book example page391 b Round Robin (RR, also known as Time Slicing) This is a way to reduce the penalty that short jobs is not performed well in FCFS. It use preemption based on a clock.Clock interrupt is generated at periodic intervals. When the interrupt occurs the currently running process is placed in the ready queue, and the next ready job is selectec on an FCFS basis. This is a way to reduce the penalty that short jobs is not performed well in FCFS. It use preemption based on a clock.Clock interrupt is generated at periodic intervals. When the interrupt occurs the currently running process is placed in the ready queue, and the next ready job is selectec on an FCFS basis. b Shortest Process Next (SPN) This is a nonpreemptive policy in which the process with the shortest expected processing time is selected next. This is a nonpreemptive policy in which the process with the shortest expected processing time is selected next. b Shortest Remain Time (SRT) In this case, the scheduler always chooses the process that has the shortest expected remaining processing time. In this case, the scheduler always chooses the process that has the shortest expected remaining processing time.

11 Scheduling Policies (continue) b Highest Response Ratio Next (HRRN) RR=(W+S)/S (W: waiting time, S: service time) RR=(W+S)/S (W: waiting time, S: service time) b Feed Back (FB) This scheduling is done on a preemptive basis, and a dynamic priority mechanisms is used.When a process first enters the system, it is placed in highest priority queue. After its first execution, when it returns to the ready state, it is placed in second priority queue. Each subsequent time, it is demoted to the next lower-priority queue. Within each queue, except the lowest-priority queue, a simple FCFS mechanism is used. For the lowest-priority queue, a Round Robin mechanism is used. This scheduling is done on a preemptive basis, and a dynamic priority mechanisms is used.When a process first enters the system, it is placed in highest priority queue. After its first execution, when it returns to the ready state, it is placed in second priority queue. Each subsequent time, it is demoted to the next lower-priority queue. Within each queue, except the lowest-priority queue, a simple FCFS mechanism is used. For the lowest-priority queue, a Round Robin mechanism is used.

12 Uniprocessor Scheduling Algorithms bMany basic algorithms and theoretical results have been developed for uniprocessor scheduling. bTwo famous algorithms: Earliest-Deadline-First SchedulingEarliest-Deadline-First Scheduling Rate-Monotonic SchedulingRate-Monotonic Scheduling

13 Earliest-Deadline-First Scheduling b This is a dynamic scheduling algorithm, the priority of tasks will be changed. b Priorities are assigned to tasks according to the deadlines of their current requests. b Theorem: Any sequence that at any instant schedules the job with EDF among all the eligible jobs is optimal with respect to minimizing maximum lateness. b Full processor utilization is always achievable(U=C/T, C:computation time, T: period)

14 Rate-Monotonic Scheduling b This is a static scheduling algorithm with fixed priority for each task. b Priorities are assigned to tasks according to their request rates(1/T: T is a period), independent of their run-times. Tasks with shortest period will have higher priorities. When more than one task is available for execution, the one with the shortest period is served first. b Theorem: 1.For a set of n tasks with fixed priority order, the least upper bound to processor utilization is U=n(2-1). If the total utilization required for a set of tasks is less than the upper bound, then all the tasks will be successfully scheduled. 1.For a set of n tasks with fixed priority order, the least upper bound to processor utilization is U=n(2 1/n -1). If the total utilization required for a set of tasks is less than the upper bound, then all the tasks will be successfully scheduled. 2.The sum of the processor utilizations of the individual tasks cannot exceed a value of 1(C1/T1+C2/T2+…+Cn/Tn<=1) which will guarantees that a perfect scheduling algorithm can successfully schedule. 2.The sum of the processor utilizations of the individual tasks cannot exceed a value of 1(C1/T1+C2/T2+…+Cn/Tn<=1) which will guarantees that a perfect scheduling algorithm can successfully schedule. b Prerequisite: Periodic task deadlines should be equal to the period.

15 Uniprocessor Scheduling b Problems with these two algorithms Shared resources:Shared resources: When there are mutual exclusion constraints, it is impossible to find a totally in-line optimal runtime scheduler. A much more negative result has shown that: The problem of deciding whether it is possible to schedule a set of periodic processes that use semaphores only to enforce mutual exclusion is NP-hard. (NP is the class of all decision problems that can be solved in polynomial time by a nondeterministic machine). When there are mutual exclusion constraints, it is impossible to find a totally in-line optimal runtime scheduler. A much more negative result has shown that: The problem of deciding whether it is possible to schedule a set of periodic processes that use semaphores only to enforce mutual exclusion is NP-hard. (NP is the class of all decision problems that can be solved in polynomial time by a nondeterministic machine). Overloads:Overloads: experiments show that these algorithms perform very poorly in overload conditions. That's because they give the highest priority to processes that are close to missing their deadlines. experiments show that these algorithms perform very poorly in overload conditions. That's because they give the highest priority to processes that are close to missing their deadlines.

16 Multiprocessor Scheduling b We know less about real-time scheduling for multiprocessor-based systems than for uniprocessors. Deterministic (Static) SchedulingDeterministic (Static) Scheduling Dynamic Scheduling (EDF not optimal any more)Dynamic Scheduling (EDF not optimal any more)

17 Static Scheduling Static Scheduling 1. Requests for tasks are periodic, with constant interval between requests. 1. Requests for tasks are periodic, with constant interval between requests. 2. Each task must be completed before the next request for it occurs. 2. Each task must be completed before the next request for it occurs. 3. Tasks are independent. 3. Tasks are independent. 4. Computation time for each task is constant. 4. Computation time for each task is constant.

18 Dynamic Scheduling Dynamic Scheduling b Distributed Dynamic Scheduling In a distributed dynamic scheduling scheme, tasks arrive independently at each processor. When a task arrives at a processor, the local scheduler at the processor determines whether or not it can satisfy the constraints of the incoming task. The task is accepted if they can be satisfied, otherwise, the local scheduler tries to find another processor which can accept the task. In a distributed dynamic scheduling scheme, tasks arrive independently at each processor. When a task arrives at a processor, the local scheduler at the processor determines whether or not it can satisfy the constraints of the incoming task. The task is accepted if they can be satisfied, otherwise, the local scheduler tries to find another processor which can accept the task. b Centralized Dynamic Scheduling In a centralized scheme, all the tasks arrive at a central processor called the scheduler, from where they are distributed to other processors in the system for execution. The communication between the scheduler and the processors is through dispatch queues. In a centralized scheme, all the tasks arrive at a central processor called the scheduler, from where they are distributed to other processors in the system for execution. The communication between the scheduler and the processors is through dispatch queues.

19 Conclusion Conclusion Process scheduling is an important issue in the design and maintenance of Real-Time systems. The primary objective of scheduling is to provide a feasible process allocation and sequenc in order to meet deadlines and achieve high resource utilization. As we have shown, classical scheduling theory does provide a basic set of results for real-time system designers. Many results are known for uniprocessors, unfortunately, for multiprocessors, we need new results that deal more directly with relevant metrics and realistic task characteristics. Process scheduling is an important issue in the design and maintenance of Real-Time systems. The primary objective of scheduling is to provide a feasible process allocation and sequenc in order to meet deadlines and achieve high resource utilization. As we have shown, classical scheduling theory does provide a basic set of results for real-time system designers. Many results are known for uniprocessors, unfortunately, for multiprocessors, we need new results that deal more directly with relevant metrics and realistic task characteristics.


Download ppt "Real-Time Scheduling --- An Overview Real-Time Scheduling --- An Overview Xiaoping He."

Similar presentations


Ads by Google