Rts Notes 2
Rts Notes 2
What is scheduler.
scheduler can also refer to a software or hardware program programmed to
process computer processes based on various priorities. Scheduler
responsible for managing the execution of computer processes in changing
states. Its primary objective is to ensure that all tasks of the computer
system are processed in a timely manner so that the system functions
properly and provides responses on time.
clock-driven approach
The clock-driven approach is one of the approaches used in real-time scheduling.
In this approach, the scheduler makes decisions based on the system clock rather
than the arrival of tasks. Here's how it works:
1. Fixed Time Slots: The system is divided into fixed time slots, often referred to as
frames or time quanta. Each time slot has a predetermined duration.
2. Task Scheduling: Real-time tasks are assigned to these time slots based on their
deadlines and execution requirements. The scheduler determines which tasks will
execute during each time slot.
3. Periodic Execution: Tasks that have periodic deadlines are assigned to
appropriate time slots based on their periodicity. For example, if a task has a
deadline every 100 milliseconds, it will be scheduled to execute every 100
milliseconds within the assigned time slot.
4. Interrupt Handling: If an interrupt occurs during a time slot, the scheduler may
need to preempt the current task and handle the interrupt before resuming the
scheduled tasks.
5. Predictable Behavior: Since the scheduling decisions are based on the system
clock and the fixed time slots, the behavior of the system becomes more
predictable, making it suitable for real-time applications where timing guarantees
are critical.
4. Execution: During each scheduling cycle, the scheduler selects the next task
based on the round-robin order and the assigned weights. The selected task is
allowed to execute for a predetermined time quantum.
5. Fairness and Resource Allocation: The Weighted Round Robin approach aims to
achieve fairness in resource allocation by considering the relative weights of tasks.
Tasks with higher weights receive proportionally more CPU time compared to
tasks with lower weights.
Priority-Driven Approach
1. Task Prioritization: Each task in the system is assigned a priority level. The
priority level typically indicates the importance or urgency of the task.
2. Priority Queue: Tasks are organized into a priority queue, where tasks with
higher priority levels are placed at the front of the queue, and tasks with lower
priority levels are placed at the back.
3. Task Selection: The scheduler selects the next task to execute from the priority
queue based on the task's priority level. Tasks with the highest priority are
selected first for execution.
1. Static System:
- A static system is one in which the output or behavior does not change over
time in response to external stimuli or inputs.
- In a static system, the relationships between inputs and outputs remain
constant and do not vary with time.
-
2. Dynamic System:
- A dynamic system is one in which the output changes over time in response to
varying inputs, disturbances, or environmental conditions.
- In a dynamic system, the relationships between inputs and outputs are time-
varying, and the behavior of the system evolves with time.
- Examples of dynamic systems Online reservation systems, traffic management
systems,
In summary, the main difference between static and dynamic systems lies in how
they respond to changes over time. Static systems have fixed relationships
between inputs and outputs, while dynamic systems exhibit time-varying behavior
in response to changing conditions.
1. Task Arrival: When a new task arrives, its arrival time along with its deadline is
noted.
4. Execution: Tasks are executed according to their priorities. If a task misses its
deadline, it indicates a scheduling violation.
Some key points of the EDF algorithm are:
- Overhead: There is overhead in computing deadlines since it's done upon the
arrival of each new task.
The LST (Least Slack Time) algorithm is another scheduling algorithm used in real-
time systems. In this algorithm, tasks are prioritized based on their "slack time."
Slack time refers to the remaining time for completing a task, meaning if a task
has a lot of time left before its deadline, it will have more slack time.
1. Task Arrival: Upon the arrival of new tasks, their arrival time and deadlines are
noted.
2.Slack Time Computation: Slack time is computed for each task. Slack time is the
time remaining until the task's deadline.
3. Scheduling: Tasks are prioritized based on their slack time. The task with the
least slack time is executed first.
4. Execution: Tasks are executed according to their priorities. If a task misses its
deadline, it indicates a scheduling violation.
- Slack Time: This algorithm relies on determining the slack time for tasks, which
can incur additional overhead.
- Optimality: The LST algorithm does not provide optimal solutions but generally
produces acceptable schedules.
Overall, the LST algorithm is another important scheduling algorithm for real-time
systems that manages tasks based on their remaining time, thereby improving
system performance and efficiency.
1. Task Assignment: Each task is assigned a priority based on its rate of execution.
Tasks with shorter periods (higher frequency) are assigned higher priorities. The
priority assignment is fixed and determined before execution.
2. Scheduling: During scheduling, the task with the highest priority (shortest
period) is selected for execution. If multiple tasks have the same priority, the task
with the earliest arrival time is chosen.
3. Execution: Tasks are executed according to their priorities. The task scheduler
ensures that higher priority tasks preempt lower priority tasks if necessary.
- Priority Inversion: RMA can suffer from priority inversion issues, where lower
priority tasks hold resources needed by higher priority tasks. Proper resource
locking mechanisms or priority inheritance protocols are required to mitigate
priority inversion.
1. Offline Scheduling:
- In offline scheduling, the entire set of tasks is known in advance, including their
arrival times, execution times, and deadlines.
- The scheduler has complete information about the tasks before making
scheduling decisions.
2. Online Scheduling:
- In online scheduling, tasks arrive dynamically over time, and the scheduler
makes scheduling decisions without complete knowledge of future tasks.
- The scheduler must make decisions based on the current state of the system
and any available information about future tasks.
Comparison:
Overall, the choice between offline and online scheduling depends on factors such
as the system's requirements, the predictability of task arrivals, and the desired
level of optimality versus responsiveness.
"Sporadic" and "aperiodic" are two terms used to describe different types of tasks
in real-time systems based on their arrival patterns and deadlines:
1. Sporadic Tasks:
- Sporadic tasks are tasks that arrive periodically but with variable inter-arrival
times.
- These tasks have deadlines associated with them, but the deadlines are
typically relative to their arrival times.
- The time between consecutive arrivals of sporadic tasks is not constant, and
they may arrive in bursts or clusters.
2. Aperiodic Tasks:
- Aperiodic tasks are tasks that do not follow a regular periodic pattern in their
arrivals.
- These tasks arrive at irregular intervals, and their arrival times are not
predictable.
- Aperiodic tasks often have deadlines associated with them as well, but the
deadlines may be absolute or relative depending on the application.
Comparison:
- Arrival Pattern: Sporadic tasks have a periodic arrival pattern with variable inter-
arrival times, while aperiodic tasks arrive at irregular intervals without following
any specific pattern.
- Predictability: Sporadic tasks have some predictability in their arrivals due to
their periodic nature, while aperiodic tasks are less predictable since their arrivals
are irregular.
- Resource Usage: Sporadic tasks may have better utilization of resources since
they arrive in bursts, allowing for efficient resource allocation during active
periods. Aperiodic tasks, on the other hand, may lead to underutilization of
resources during idle periods if not managed effectively.
In real-time systems, it's essential to design scheduling algorithms that can handle
both sporadic and aperiodic tasks efficiently to meet timing constraints and
ensure system reliability and performance.