Académique Documents
Professionnel Documents
Culture Documents
Michael Thomas
Date:
Date
Rev. 1.00
Objective
Priority
Real-time Scheduling
Soft
Hard
Dynamic
Preemptive
Static
Non-preemptive Preemptive
Non-preemptive
Kernel
(Scheduler + Memory management + IPC + Synchronization)
primitives
Kernel latency (microkernel, picokernel etc)
Kernel space
Program Counter
Register Contents
Task Status
Priority
Typical TCB
Task ID
Other Info
task2 ready
task1
Context
task2
running
running
Switch
LOCAL
VARIABLES
task1
LOCAL
VARIABLES
task2
Preemption
RUNNING
Priority
WAITING
ISR
task 2
Context Switch
task 1
Time
10
Timer Interrupt
Task1
Task1
Task1
Task1
Task2
Task2
Task2
Task2
Task1
Task3
Task1
Task3
Task3
Task4
Task3
Task4
Task1
Task5
Task1
Task5
Simple
cyclic
Multi-rate
Time
Multi-rate
cyclic
driven
cyclic
for
cyclic
periodic
11
12
RTOS Services
13
14
Task Management
15
Task Management
State transitions of a task in a typical RTOS
Waiting for
resources
Resources
available
Interrupt
task
deleted
ISR done
Task resumed
Task preempted
16
Round Robin
Earliest deadline First (EDF)
Maximum Urgency First (MUF)
Priority Ceiling Protocol (Resource based)
17
Interrupt Handling
RTOS Independent Interrupts
ISR preempts the RTOS and runs
Used for events that require accurate timing
18
Timer primitives
Allow user to specify Run task every x unit of time during task
creation. eg: scan keyboard
19
Synchronization
Synchronization constructs:
Mutex (Binary semaphore)
Semaphore (Counting semaphore)
20
Issues:
Deadlocks
Priority Inversion: Low priority thread obtains a lock that blocks a
higher priority thread
21
Priority Inversion
Preemption after
resource X released
preemption
time
Tasks L & H both need access to resource X
Task L has locked this resource and hence delays H.
Task M preempts L causing further delay to H; this is priority inversion
22
Ready to run
Running
Shared Memory
Mailbox/Message Queues
23
Mailbox/Message Queue
Task 1
Mailbox 1
Task 3
Task 2
24
Memory Management
Memory Management Unit (MMU)
Handles Virtual memory operations.
Memory protection esp. in process based OS
25
31
62
127
255
511
Buffer size
26
27
28
29
30
31
Debugging tools
Debugging tools have to be developed/ported for in house
RTOS; usually takes 4x time needed to develop the RTOS
Commercial vendors have readily available debuggers and will
port over desired features in most cases
32
33
Objectives: Recap
34