Unit No: 1 Real Time Operating Systems Prepared by: Pavan R Jaiswal
Unit 1 objectives ◦ ◦ ◦ ◦ ◦
To To To To To
understand operating system architecture know in depth various kernel types learn and use real time systems differentiate various real time systems understand real time operating system
Real Time OS
2
Basics of operating systems Kernel & its types Real time tasks Real time systems Types of real time tasks Real time operating system
Real Time OS
3
Computer = set of resources ◦ Processor(s), memory, I/O & communication devices
OS ◦ Enables use of resources ◦ Manages resources
Resources not limited to hardware Shift from ◦ Pure efficient use of resources ◦ Enhance user experience
to
Real Time OS
4
Real Time OS
5
Kernel ◦ Substance, core, essence, centre, heart, heart & soul, marrow ,etc.
Pieces of software that performs OS tasks
Has privileged access to resources
Real Time OS
6
Kernel mode or kernel space
User mode or user space
System call ◦ User mode functionality
program
invokes
kernel
Real Time OS
mode
7
Processor scheduler
Memory manager
I/O manager
Inter-process communication manager
File system manager
Real Time OS
8
OS tends to be complex because ◦ Provides many services ◦ Support variety of hardware and software
Monolithic Layered Micro Distributed Exo
Real Time OS
9
Real Time OS
10
Part of UNIX OS that contains code for ◦ Controlling execution of process ◦ Scheduling process fairly
◦ Allocating main memory ◦ Allocating secondary memory
◦ Handling peripherals
Real Time OS
11
Loading and existence into main memory
Mostly written in C and assembly language
User programs accesses kernel services via system call interface Provides its services transparently
Real Time OS
12
File system
Process management
Input / output
Inter-process communication
Memory management
◦ Directory hierarchy, regular files, peripherals ◦ Multiple file system ◦ How processes share CPU, memory and signals ◦ How processes access files, terminals
Real Time OS
13
Kernel services are implemented with several data structures ◦ Process table ◦ Open file table
When process executes a system call, execution mode of process changes from user mode to kernel mode
In kernel mode, process access system data structures
Real Time OS
14
Real Time OS
15
Main function
OS services
Utility functions
Real Time OS
16
All OS functionality is included in single address
space
Strong points – well understood, good performance
Problems ◦ Kernel components aren’t protected from each other ◦ Not easily extended / modified ◦ May be unclear structure
Eg – UNIX, Linux, most commercial system
Real Time OS
17
Real Time OS
18
Real Time OS
19
Provides set of minimal core services
Interface to hardware layer
Max functionality is moved to user space
Essential functions in kernel ◦ Primitive memory management ◦ I/O & interrupt management ◦ Inter-process communication ◦ Basic scheduling
Message passing is a communication mean
Eg – Win NT, Amoeba, Chorus, Mach, L4
Real Time OS
20
Benefits ◦ Extensibility / reliability Easier to extend More reliable More secure Rigorously tested
◦ Portability Easier to port
◦ Distributed system support Messages are sent without knowing target machine
◦ Object oriented OS
Real Time OS
21
Motivation ◦ Traditional centralized resource management cannot be specialized, extended or replaced ◦ Privileged applications applications
must
be
used
by
all
◦ Fixed high level abstractions to costly for good efficiency
Real Time OS
22
Goals ◦ Implement traditional abstraction entirely at application level ◦ Focus on managing security not resources
Design principles ◦ Track resource ownership ◦ Ensure protection by guarding resource usage
◦ Revoke access to resources ◦ Expose hardware allocation and revocation
Real Time OS
23
Separates resource allocation & protection from resource management
Relies on application specific library OS to provide user modification
Incomplete without library OS
Multiplexes hardware directly
Provides primitives for secure management of physical resources
Applications use them to develop appropriate abstraction
Real Time OS
24
Real Time OS
25
The operating system, and in particular the scheduler, is perhaps the most important component
•control of laboratory experiments •process control in industrial plants
Examples:
•robotics •air traffic control
•telecommunications •military command and control systems
Correctness of the system depends not only on the logical result of the computation but also on the time at which the results are produced Tasks or processes attempt to control or react to events that take place in the outside world These events occur in “real time” and tasks must be able to keep up with them Real Time OS
26
Hard real-time task
one that must meet its deadline otherwise it will cause unacceptable damage or a fatal error to the system
Soft real-time task
Has an associated deadline that is desirable but not mandatory It still makes sense to schedule and complete the task even if it has passed its deadline
Real Time OS
27
Periodic tasks ◦ requirement may be stated as:
once per period T exactly T units apart
Aperiodic tasks
◦ has a deadline by which it must finish or start ◦ may have a constraint on both start and finish time
Real Time OS
28
Real-time operating systems have requirements in five general areas: Determinism
Responsiveness User control
Reliability Fail-soft operation
Real Time OS
29
Concerned with how long an operating system delays before acknowledging an interrupt Operations are performed at fixed, predetermined times or within predetermined time intervals when multiple processes are competing for resources and processor time, no system will be fully deterministic The extent to which an operating system can deterministically satisfy requests depends on:
the speed with which it can respond to interrupts
whether the system has sufficient capacity to handle all requests within the required time Real Time OS
30
How to achieve determinism? ◦ Maximum delay between arrival of event and response to the event
Real Time OS
31
Concerned with how long, after acknowledgment, it takes an operating system to service the interrupt Together with determinism make up the response time to external events critical for real-time systems that must meet timing requirements imposed by individuals, devices, and data flows external to the system Responsiveness includes: •amount of time required to initially handle the interrupt and begin execution of the interrupt service routine (ISR) •amount of time required to perform the ISR •effect of interrupt nesting
Real Time OS
32
Execution of ISR If process switch then delay included Time of execution of ISR depends hardware In case another interrupt occurs
Real Time OS
on
33
Generally much broader in a real-time operating system than in ordinary operating systems It is essential to allow the user fine-grained control over task priority User should be able to distinguish between hard and soft tasks and to specify relative priorities within each class May allow user to specify such characteristics as: paging or process swapping
what processes must always be resident in main memory
what disk transfer algorithms are to be used Real Time OS
what rights the processes in various priority bands have
34
More important for real-time systems than non-real time systems (reboot) Real-time systems respond to and control events in real time so loss or degradation of performance may have catastrophic consequences such as: financial loss major equipment damage loss of life
Real Time OS
35
A characteristic that refers to the ability of a system to fail in such a way as to preserve as much capability and data as possible Important aspect is stability a real-time system is stable if the system will meet the deadlines of its most critical, highest-priority tasks even if some less critical task deadlines are not always met
Real Time OS
36
Real-time operating systems are designed with the objective of starting real-time tasks as rapidly as possible and emphasize rapid interrupt handling and task dispatching Real-time applications are generally not concerned with sheer speed but rather with completing (or starting) tasks at the most valuable times Priorities provide a crude tool and do not capture the requirement of completion (or initiation) at the most valuable time
Real Time OS
37
Ready time
Starting deadline
• time task becomes ready for execution
Resource requirements
• time task must begin Priority
Completion • time task must be completed deadline Processing time
•resources required by the task while it is executing
• time required to execute the task to completion
Subtask scheduler
Real Time OS
•measures relative importance of the task
•a task may be decomposed into a mandatory subtask and an optional subtask
38
Real Time OS
39
Real Time OS
40
Real Time OS
41
Used in hard real time system Schedules task using static priority policy with pre-emption Priority is based on execution time Less time left highest priority Task rate (in Hertz ) is inversely proportional to its period. A task with 50ms period will occur at rate of 20Hz
Real Time OS
42
Real Time OS
43
Real Time OS
44
Real Time OS
45
Standalone Applications ◦ Often no OS involved ◦ Micro controller based Embedded Systems
Some Real Time Applications are huge & complex ◦ ◦ ◦ ◦
Multiple threads Complicated Synchronization Requirements Filesystem / Network / Windowing support OS primitives reduce the software design time
Real Time OS
46
Scheduling.
Resource Allocation.
Interrupt Handling.
Other issues like kernel size.
Real Time OS
47
More information known ◦ ◦ ◦ ◦ ◦
about
the
tasks
are
No of tasks Resource Requirements Release Time Execution time Deadlines
Being a more deterministic system better scheduling algorithms can be devised.
Real Time OS
48
Real Time OS
49
1. 2. 3. 4. 5. 6.
Define operating system. Draw and explain its architecture Write short notes on core functions of operating system. What is kernel? Explain with neat diagram any two types of kernel. What is real time task? Differentiate between soft, hard and firm real time tasks. Write short notes on real time systems. Real Time OS
50
7. 8. 9. 10. 11.
12.
Explain in details the concept of real time operating system and its necessity. Explain in detail kernel services of real time operating system. Write description on periodic and aperiodic tasks. Explain with example deadline scheduling. Explain with example rate monotonic scheduling. Define embedded system. List few examples of embedded system. Real Time OS
51
[1] Maurice J. Bach, “The Design of UNIX Operating
System”, PHI, ISBN 978-81-203-0516-8 [2] Lyla B. Das, “Embedded Systems: An Integrated Approach” Pearson, ISBN:978-81-317- 8766-3
Real Time OS
52
Thank You http://www.pavanjaiswal.com/
Real Time OS
53