Real Time Scheduling
Real Time Scheduling
Real-time systems are systems that carry real-time tasks. These tasks need to be performed
immediately with a certain degree of urgency. In particular, these tasks are related to control of
certain events (or) reacting to them. Real-time tasks can be classified as hard real-time tasks and
soft real-time tasks.
A hard real-time task must be performed at a specified time which could otherwise lead to huge
losses. In soft real-time tasks, a specified deadline can be missed. This is because the task can be
rescheduled (or) can be completed after the specified time,
In real-time systems, the scheduler is considered as the most important component which is
typically a short-term task scheduler. The main focus of this scheduler is to reduce the response
time associated with each of the associated processes instead of handling the deadline.
Advantages of Scheduling in Real-Time Systems:
Meeting Timing Constraints: Scheduling ensures that real-time tasks are executed within
their specified timing constraints. It guarantees that critical tasks are completed on time,
preventing potential system failures or losses.
Resource Optimization: Scheduling algorithms allocate system resources effectively,
ensuring efficient utilization of processor time, memory, and other resources. This helps
maximize system throughput and performance.
Priority-Based Execution: Scheduling allows for priority-based execution, where higher-
priority tasks are given precedence over lower-priority tasks. This ensures that time-critical
tasks are promptly executed, leading to improved system responsiveness and reliability.
Predictability and Determinism: Real-time scheduling provides predictability and
determinism in task execution. It enables developers to analyze and guarantee the worst-case
execution time and response time of tasks, ensuring that critical deadlines are met.
Control Over Task Execution: Scheduling algorithms allow developers to have fine-
grained control over how tasks are executed, such as specifying task priorities, deadlines,
and inter-task dependencies. This control facilitates the design and implementation of
complex real-time systems.
Disadvantages of Scheduling in Real-Time Systems:
Increased Complexity: Real-time scheduling introduces additional complexity to system
design and implementation. Developers need to carefully analyze task requirements, define
priorities, and select suitable scheduling algorithms. This complexity can lead to increased
development time and effort.
Overhead: Scheduling introduces some overhead in terms of context switching, task
prioritization, and scheduling decisions. This overhead can impact system performance,
especially in cases where frequent context switches or complex scheduling algorithms are
employed.
Limited Resources: Real-time systems often operate under resource-constrained
environments. Scheduling tasks within these limitations can be challenging, as the available
resources may not be sufficient to meet all timing constraints or execute all tasks
simultaneously.
Verification and Validation: Validating the correctness of real-time schedules and ensuring
that all tasks meet their deadlines require rigorous testing and verification techniques.
Verifying timing constraints and guaranteeing the absence of timing errors can be a complex
and time-consuming process.
Scalability: Scheduling algorithms that work well for smaller systems may not scale
effectively to larger, more complex real-time systems. As the number of tasks and system
complexity increases, scheduling decisions become more challenging and may require more
advanced algorithms or approaches.
Scheduling algorithms
A scheduler is not needed for the simpler real-time tasks as their process and execution time are
known, so one task after its completion may call the other task on its own. But for complex systems
in which large entities of tasks do not follow a proper pipeline, we may apply a static scheduling
algorithm where a fixed timeline is provided to ensure the execution of the tasks that are in the
ready queue. These approaches will not work for real-time systems which change their workload
dynamically according to the events, here we need to apply a dynamic scheduling algorithm.
Rate-monotonic scheduling
Rate monotonic scheduling is a priority algorithm that belongs to the static priority scheduling
category of Real Time Operating Systems. It is preemptive in nature. The priority is decided
according to the cycle time of the processes that are involved. If the process has a small job
duration, then it has the highest priority. Thus if a process with highest priority starts execution, it
will preempt the other running processes.
Example: An example to understand the working of Rate monotonic scheduling algorithm.
Process P2 will run first for 2 time units because it has the highest priority. After completing its two
units, P3 will get the chance and thus it will run for 2 time units. As we know that process P2 will run
2 times in the interval of 5 time units and process P3 will run 2 times in the interval of 10 time units,
they have fulfilled the criteria and thus now process P1 which has the least priority will get the chance
and it will run for 1 time. And here the interval of five time units have completed. Because of its
priority P2 will preempt P1 and thus will run 2 times. As P3 have completed its 2 time units for its
interval of 10 time units, P1 will get chance and it will run for the remaining 2 times, completing its
execution which was thrice in 20 time units. Now 9-10 interval remains idle as no process needs it.
At 10 time units, process P2 will run for 2 times completing its criteria for the third interval ( 10-15 ).
Process P3 will now run for two times completing its execution. Interval 14-15 will again remain idle
for the same reason mentioned above. At 15 time unit, process P2 will execute for two times
completing its execution.This is how the rate monotonic scheduling works.
Advantages:
1. It is easy to implement.
2. If any static priority assignment algorithm can meet the deadlines then rate monotonic
scheduling can also do the same. It is optimal.
3. It consists of a calculated copy of the time periods, unlike other time-sharing algorithms as
Round robin which neglects the scheduling needs of the processes.
Disadvantages:
1. It is very difficult to support aperiodic and sporadic tasks under RMA.
2. RMA is not optimal when the task period and deadline differ.