Reading material TDDB47 Real-time Systems Lecture 8: Real-time operating systems

advertisement
Reading material
TDDB47 Real-time Systems
• Chapter 10 of book by Shaw
Lecture 8: Real-time operating
systems
• Extra Reading:
– Chapter 12 of Jane Liu’s book on
Real-time Systems, Prentice Hall 2000
– Chapter 15.1 in Burns & Wellings on
I/O devices
Simin Nadjm-Tehrani
Real-time Systems Laboratory
Department of Computer and Information Science
Linköping university
Undergraduate course on Real-time Systems
Linköping
20 pages
Autumn 2005
Undergraduate course on Real-time Systems
Linköping
Recall ...
2 of 20
Autumn 2005
Layers of design
To ensure timeliness:
• define end-to-end deadlines
• define deadlines for individual tasks
• ascertain (worst case) execution
time for each task
• document assumptions/restrictions
• assure that implementation
satisfies requirements
Undergraduate course on Real-time Systems
Linköping
3 of 20
Autumn 2005
Application modelling support
Programming environment support
System software support (kernels)
Hardware support
Undergraduate course on Real-time Systems
Linköping
The role of the OS
Depends on who you ask:
• The bare machine people
• The application-dependent OS people
• The buy-kernel-and-complete people
• The off-the-shelf OS people
• The reconfigurable OS people
• The middleware people
Undergraduate course on Real-time Systems
Linköping
4 of 20
Autumn 2005
Main functions
• Task management
• Inter-task communication and
synchronisation
• Timer services
• Interrupt services
• Memory management (DMA)
• Device I/O management
5 of 20
Autumn 2005
Undergraduate course on Real-time Systems
Linköping
6 of 20
Autumn 2005
Task management
May be:
• Time-driven
– At each tick of a clock the kernel
checks if some tasks need to be
queued, a task should start to run, or
a task should stop running
• Event-driven
– When an I/O operation is completed,
or a task signals completion, the
kernel checks ...
Undergraduate course on Real-time Systems
Linköping
7 of 20
Autumn 2005
Task attributes
• On creation of threads RT kernels may
allow specification of attributes such as
– Start time
– Deadline
– Priority
– ...
• Used for releasing, aborting, and
scheduling
Undergraduate course on Real-time Systems
Linköping
Event-based task switching
Upon arrival of an event:
• Determine if the current running task
should continue (based on scheduling
policy)
• If not, determine the next task to be run
• Save the environment of the preempted
task
• Prepare the selected task to be run
... in deterministic time!
Undergraduate course on Real-time Systems
Linköping
9 of 20
Autumn 2005
Basic operations
• Search, insert and delete of tasks in
ready queue
• Restore the state of the highest priority
task
Undergraduate course on Real-time Systems
Linköping
Main functions
10 of 20
Autumn 2005
Task communication
• Shared memory and semaphores
– Priority inversion
– Deadlocks
• Message passing
– Can above problems still arise?
• Deterministic time:
– Locking and unlocking latency
– Message passing delays (size
independent!)
• Task management
• Inter-task communication and
synchronisation
• Timer services
• Interrupt services
• Memory management (DMA)
• Device I/O management
Undergraduate course on Real-time Systems
Linköping
8 of 20
Autumn 2005
11 of 20
Autumn 2005
Undergraduate course on Real-time Systems
Linköping
12 of 20
Autumn 2005
Main functions
Timer services
• Even event-driven OS need time services to
construct timers and detect overruns
• Task management
• Inter-task communication and
synchronisation
• Timer services
• Interrupt services
• Memory management (DMA)
• Device I/O management
• OS may allow defining one or more high
resolution clocks with get_value, set_value,
get_resolution operations
• Timers can be defined to signal an event after
a particular period
• Real-time POSIX allows queued signals
according to priority
Undergraduate course on Real-time Systems
Linköping
13 of 20
Autumn 2005
Interrupt services
When an interrupt event is generated:
• State of the current running task is
saved
• Interrupt handler (ISR) is executed
• Next task to be run (application task or
the scheduler) is invoked
Undergraduate course on Real-time Systems
Linköping
15 of 20
Autumn 2005
Undergraduate course on Real-time Systems
Linköping
Deterministic interrupts
• RT OS vendor has to provide data on
the timing determinism for the given
steps
• Interrupt service routines (ISR) have to
be short
• But also predictable!
• If several interrupts are to be serviced
the relative (fixed) priority determines
the order
Undergraduate course on Real-time Systems
Linköping
Main functions
16 of 20
Autumn 2005
Memory allocation
Points of view:
• Real-time programmer should have absolute
control over resources used by the program.
– Dynamic memory allocation (malloc, free)
supported by OS?
• Task management
• Inter-task communication and
synchronisation
• Timer services
• Interrupt services
• Memory management (DMA)
• Device I/O management
Undergraduate course on Real-time Systems
Linköping
14 of 20
Autumn 2005
• Dynamic memory allocation takes nondeterministic time due to fragmentation and
should not be allowed in RTOS.
– Pools instead of heap
– Real-time garbage collection/Real-time Java
17 of 20
Autumn 2005
Undergraduate course on Real-time Systems
Linköping
18 of 20
Autumn 2005
File system
• Traditional file systems not suitable for
real-time OS!
• Those that support filing services also
provide a mechanism for efficient
locking of task data into main memory
storage
• Avoiding unpredictable memory swaps!
Undergraduate course on Real-time Systems
Linköping
19 of 20
Autumn 2005
Device controllers
• To initialise device interrupt information
and disable/enable a device interrupt
• Upon generation of a hardware interrupt
identify which device is involved
• Managing interrupt-driven I/O can be
difficult unless the number of generated
interrupts can be bounded
Undergraduate course on Real-time Systems
Linköping
20 of 20
Autumn 2005
Download