0% found this document useful (0 votes)
52 views

Chapter Five: Real-Time Operating Systems Rtos

Real-time operating systems (RTOS) are optimized to handle tasks within timing limits. They respond immediately to inputs and complete tasks within specified time delays. An RTOS must meet timing constraints and prevent simultaneous access to shared resources. Common RTOS scheduling algorithms include priority scheduling, earliest deadline first, and rate monotonic scheduling. An RTOS has low interrupt latency, a small kernel size, and lacks features like virtual memory for embedded applications. RTOS are used in applications like telecommunications, industrial controls, and military systems that require predictable and immediate response.

Uploaded by

natnael demissie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Chapter Five: Real-Time Operating Systems Rtos

Real-time operating systems (RTOS) are optimized to handle tasks within timing limits. They respond immediately to inputs and complete tasks within specified time delays. An RTOS must meet timing constraints and prevent simultaneous access to shared resources. Common RTOS scheduling algorithms include priority scheduling, earliest deadline first, and rate monotonic scheduling. An RTOS has low interrupt latency, a small kernel size, and lacks features like virtual memory for embedded applications. RTOS are used in applications like telecommunications, industrial controls, and military systems that require predictable and immediate response.

Uploaded by

natnael demissie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

CHAPTER FIVE

REAL-TIME OPERATING SYSTEMS


RTOS
What’s Real time ?
 Real time in operating systems:
 The ability of the operating system to provide a
required level of service in a bounded response
time.
RTOS

 It responds to the inputs immediately(Real-


Time).
 Here the task is completed within a specified
time delay.
 In real life situations like controlling traffic signal
or a nuclear reactor or an aircraft, the operating
system has to respond quickly.
CHARACTERISTICS OF RTOS
Types of operating systems

 General purpose OS(GPOS)


Optimized for throughput and fairness
 Real-Time OS (RTOS)
Optimized for handling tasks within timing
limits
Types of RTOS
Hard RTOS
 has time-critical deadlines that must be met at the
time of request
 Strict timing requirements
 Optimized w.r.t. predictability and timing limits
 Does not share critical resources such as CPU
 Missing a single deadline cause a catastrophic
system failure
HARD RTOS
 Examples of application under hard real time
 Defense applications
 Life supporting medical equipment
 Industrial control systems
 air traffic control
 vehicle subsystems control
 Nuclear power plant control, etc…
SOFT RTOS
 Relative tolerable timing deadlines
 Tolerance is defined as a part of policy
 Occasional deadline missing may not cause
system failure
Examples
 Audio processing
 Real-time video processing
 Network interface subsystem
Task/Process States

• Each task/Process can belong to one and only one


state at a time
• The Scheduler only operates on the processes in the
Ready state
• There is a single process in the Run/current state at
any time.
• Transitions to and from the Ready queue are affected
as a part of the execution of the RTOS
resource/object services or as a result of timing
events
Typical Task Operations

 creating and deleting tasks,


 controlling task scheduling, and
 obtaining task information.
 a job/task is characterized by :
 execution time
 ready time
 deadline and
 resource requirements.
TYPES OF TASK CONSTRAINTS

 Typical constraints that can be specified on real time tasks are


of three classes:

 Timing Constraints
 Precedence Relations
 Mutual Exclusion Constraints on Shared Resources.
TIMING CONSTRAINTS

 In general, a real time task can be characterized by the following


parameters:

 Arrival Time ai: is the time at which a task becomes ready for
execution.
 Computation Time Ci: is the time necessary for the processor to
execute the task without interruption.
 Deadline di: is the time before which a task should be completed
to avoid damage to the system.
 Start Time si: is the time at which a task starts execution.
 Finishing Time fi: is the time at which a task finishes execution.
Cont…
 Criticalness: is a parameter related to the consequences of missing
the deadline.
 Value vi: represents the relative importance of the task with respect
to other tasks in the system.
 Lateness Li: Li = fi – di represents the delay of a task completion
with respect to its deadline, it is negative if a task completes before
its deadline.
 Tardiness or Exceeding Time Ei: Ei = max(o, Li) is the time a task
stays active after its deadline.
 Laxity or Slack Time Xi: Xi = di – ai – Ci is the maximum time a
task can be delayed on its activation to complete within its deadline.
Cont…
 Another timing characteristic that can be specified on a real time
task concerns the regularity of activation. In particular, tasks can
be defined as periodic or a-periodic.
 Periodic tasks consist of an infinite sequence of identical
activities called instances or jobs, that are regularly activated at a
constant rate.
 A-periodic tasks also consist of infinite sequence of identical
activities, however, their activations are not regular.
scheduling
 Giving an execution order for the jobs/tasks to
get the service such that various constraints are
satisfied.
 Done according to the task/job information
Scheduling policy
 Things to be considered in scheduling a real-time
system:
 Meeting the timing constraints of the system
 Preventing simultaneous access to shared resources
and devices
 Reducing the cost of context switches caused by
preemption
 Attaining a high degree of utilization while satisfying
the timing constraints of the system
 Reducing the communication cost in real-time
Scheduling in RTOS
 More information about the tasks are known
 No of tasks
 Resource Requirements
 Release Time
 Execution time
 Deadlines
 Being a more deterministic system better
scheduling algorithms can be devised.
CLASSIFICATION OF SCHEDULING ALGORITHMS

 Scheduling algorithms can be classified as follows:

 Preemptive: with preemptive algorithms, the running task can


be interrupted at any time to assign the processor to another
active task, according to a predefined scheduling policy.

 Non – Preemptive: with non – preemptive algorithms, a task


once started, is executed by the processor until completion all
scheduling decisions are taken as a task terminates its execution.
 Static: scheduling decisions are based on fixed parameters
assigned to tasks before their activation in these algorithms.
 Dynamic: scheduling decisions are based on dynamic parameters
that may change during system evolution.
Cont…
 Clock Driven Scheduling
 Weighted Round Robin Scheduling
 (Greedy / List / Event Driven)
Clock Driven

 All parameters about jobs (release time/


execution time/deadline) known in advance.
 Schedule can be computed offline or at some
regular time instances.
 Minimal runtime overhead.
 Not suitable for many applications.
Weighted Round Robin

 Round Robin – give each task an equal share of the


processor(FIFO )
 Implemented when all tasks or threads have the same
priority level
 May be implemented within a priority range
Example use : High speed switching network QOS
guarantee.
 Not suitable for precedence constrained jobs.
Eg. Job A can run only after Job B. No point in giving
time quantum to Job B before Job A.
Priority Scheduling

 Pre-emptive priority scheduling – higher


priority tasks may interrupt lower priority tasks.
 Processor allocated to processes according to
priorities Categorized as:
Static – priorities are set before the system
begins execution(at design time)
Dynamic – priorities can be redefined at run
time(at runtime)
Priority Scheduling
Earliest deadline first
 The Earliest Deadline First is a dynamic scheduling rule that
selects tasks according to their absolute deadlines.
 Specifically, tasks with earlier deadlines will be executed at higher
priorities.
 EDF is a dynamic priority assignment and is intrinsically
preemptive, that is, the currently executing task is preempted
whenever another periodic instance with an earlier deadline
becomes active.
Cont…
Earliest Deadline First (EDF)
 Process with earliest deadline given highest priority
 The runnable processes are executed in the order determined
by the absolute deadlines of the processes
 the absolute deadlines are computed at run time and hence the
scheme is described as dynamic
Least Slack Time First (LSF)
 slack = relative deadline – execution left
Rate Monotonic Scheduling (RMS)
 For periodic tasks
 Tasks priority inversely proportional to it’s period
Cont…
 This is a simple rule that assigns priorities to tasks according
to their request rates.
 Specifically, tasks with higher request rates will have higher
priorities.
 Since the periods are constant, RM is a fixed priority
assignment: priorities are assigned to tasks before execution
and do not change with time.
 Moreover, RM is intrinsically preemptive: the currently
executing task is preempted by a newly arrived task with
shorter period.
Preemption process
Resource Allocation in RTOS

 Resource Allocation
 The issues with scheduling applicable here.
 Resources can be allocated using
• Weighted Round Robin
• Priority Based
• Some resources are non pre-emptible
Example : semaphores
• Priority Inversion if priority scheduling is used
Other RTOS issues
• Interrupt Latency should be very small
– Kernel has to respond to real time events
– Interrupts should be disabled for minimum
possible time
• For embedded applications Kernel Size should be
small
– Should fit in ROM
• Sophisticated features can be removed
– No Virtual Memory
– No Protection
INTERRUPT HANDLING OF RTOS.

• An interrupt is a signal from a device attached to a


computer or from a program with in a computer
that causes the main program, that is operating
system to stop and figure out what to do next.
• Interrupts cause the processor to suspend the
operations whatever it is doing instead execute
the code that will respond to the event whatever
caused the interrupt.
APPLICATIONS OF RTOS.
 modern telecommunication systems
 Radar systems
 network switching control systems,
 satellite monitoring systems, satellite launch-
control and global positioning systems all have
their roots in RTOS.
 Now a days RTOSes have increasingly finding use
in strategic and military operations. These are
used in guided missile launching units, track-and-
trace spy satellites, etc.
RTOS vs GPOS
 Unfair scheduling  Fair scheduling
Scheduling based on  Scheduling can be
priority adjusted dynamically for
 Predictable behavior optimized throughput
 Priority inversion is a  No predictability
major issue guarantees
 Kernel is preemptive  Priority inversion remain
either completely or up unnoticed
to maximum degree  Kernel is long/non-
preemptive code sections
Limitations for RT applications
 Page faults
 Occurs when requested data is not available or its
reference is absent from a page table
 Types of page faults
 Major/Hard page faults
 Minor/Soft page faults
Major page faults
 Occurs when requested data has to be fetched
from disk
 Can cause very large latencies
 RT applications should be written to minimize
Major page faults
Minor page faults
 Occurs when requested data resides in the main
memory but missing from TLB
 It does not involve IO operation to fetch data
from disk
 Has negligible impact in RT performance
Avoid page faults
 Use mlockall() to load all the address space of the
program and then lock it such that it cannot be
swapped out
 Create all threads at startup time of the application
because run time thread creation can cause latencies
 Avoid dynamic allocation and freeing of memory
 Minimize the use of system calls that are known to
generate page faults
Context switching
 Switching the CPU to another task requires
saving the state of the old task and loading the
saved state for the new task.
 The time wasted to switch from one task to
another without any disturbance is called context
switch or scheduling jitter.
Is context switching really a problem?

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy