RTOS scheduling policy
RTOS scheduling policy
• Primary function of OS
• (1) Make the system convenient
• (2) Organize and manages the system resources efficiently
and correctly.
Types of Operating Systems
• Fail-soft operation
Real Time Kernel
• Code- programs
• Co-operative multitasking
• Preemptive multitasking
• Non-Preemptive multitasking
Types of multitasking
• Co-operative multitasking :
• Task/ Process gets a chance only when the currently executing
Task/ Process voluntarily relinquishes the CPU.
• In this method a Task/ Process can hold the CPU as much
time as it wants.
• Each ready task cooperates to let the running one finish.
• None of the task does a block anywhere during the ready to
finish state.
• If the currently executing task is non-cooperative , the other
task may have to wait for a long time to get CPU.
Types of multitasking
• Preemptive multitasking:
• Non-Preemptive multitasking:
• In Non-Preemptive multitasking, the process/task which is
currently given the CPU time, is allowed to execute until it
terminate or enters a Blocked/ Wait state.
• RMS priorities
• Optimal (fixed) priority assignment:
– shortest-period process gets highest priority;
– priority inversely proportional to period;
– break ties arbitrarily.
P3 P3 P3 P3 period
P2 P2 P2 period
P1 P1 P1 P1 period
0 2 4 6 8 10 12 time
Overheads for Computers as
© 2008 Wayne Wolf Components 2nd ed.
RM (Rate Monotonic)
T1 (4,1)
T2 (5,2)
5 10 15
T3 (7,2)
5 10 15
RM (Rate Monotonic)
• Executes a job with the shortest period
T1 (4,1)
T2 (5,2)
5 10 15
T3 (7,2)
5 10 15
RM (Rate Monotonic)
• Executes a job with the shortest period
Deadline Miss !
T1 (4,1)
T2 (5,2)
5 10 15
T3 (7,2)
5 10 15
Conditions
n 2 n − 1
Ci 1
i =1
Pi
• The LHS of the inequality is the total CPU utilization for n
tasks, where Ci is the execution time and Pi is the period of
task Ti.
• If this condition is satisfied, the RM algorithm will be able to
schedule the task within their respective deadlines.
• This is a sufficient condition, but not a necessary condition.
Earliest-deadline-first scheduling
– Disadvantages of EDF
• Generally considered too expensive (more over heads)to use
in practice.
• Dynamic priority schemes are not usually used in systems
which require absolute predictability.
Fixing scheduling problems
memory
CPU 1 CPU 2
Update time
Low priority
High priority
Process A
Process B
(write the *T1 (Read the
level & *T2
level &
Time)
Time)
Process A is preempted from updating time and process B is allowed
to read both level and Time.(wrong result)
Semaphore
Using Semaphore
Take semaphore( )
{
Low priority Update level
High priority
Update time
}
Release semaphore( )
Process A Process B
Critical
region Critical
region
(write the Process B asking for (Read the
level & semaphore(Blocked)
level &
Time) Process B gets
semaphore Time)
Process A Taken PB PB
semaphore Process A release
(Critical region) PA PA the semaphore
P and V SEMAPHORES
• It does not eliminate the delay in waiting the high priority task
to get resource from low priority task.