Real Time Operating Systems RTOS - PowerPoint PPT Presentation

1 / 45
About This Presentation
Title:

Real Time Operating Systems RTOS

Description:

No lateness is accepted under any circumstances, otherwise the aircraft is not controllable. ... Ostrich Algorithm. Do nothing ... – PowerPoint PPT presentation

Number of Views:109
Avg rating:3.0/5.0
Slides: 46
Provided by: Ste8254
Category:

less

Transcript and Presenter's Notes

Title: Real Time Operating Systems RTOS


1
Real Time Operating Systems(RTOS)
  • Stephen Ferzetti

2
Types of Operating Systems
  • An example of a hard real time system is a
    digital fly-by-wire control system of an
    aircraftNo lateness is accepted under any
    circumstances, otherwise the aircraft is not
    controllable.Useless results if late, if the
    control system does not respond timely, the
    result is a hole in the ground.Catastrophic
    failure, which needs no explanation in the case
    of an aircraft crash.Cost of missing deadline is
    infinitely high, the lives of people depend on
    the correct working of the control system of the
    aircraft.A soft real-time system can be a
    vending machineRising cost for lateness of
    results As it will take longer to treat a
    customer when the performance of the vending
    machine is degrading, less customers pay at this
    machine which results in less profits for the
    shop owner. Accept lower performance for
    lateness, it is not catastrophic when deadlines
    are not met. It will take longer to handle one
    client with the vending machine.Non real time
  • http//www.omimo.be/encyc/techno/terms/defini/def.
    htmHARD

3
Topics
  • Why are Real Time Operating Systems Important
  • Processes and Threads
  • Scheduling
  • Deadlocks

4
What makes Operating Systems that are real time
so important?
Nuclear Plant Example
  • Lets say there is a power plant
  • And lets say that the temperature is rising
  • And that there is 10 seconds to cool it down
    before it is too late
  • But..

5
Nuclear Plant
  • Since the plant was running its anti-virus
    program at the time it missed its window
  • Meltdown

6
The Main Reasons for Having a RTOS
  • Meeting deadlines
  • Being able to break out of lower priority
    processes so that more important tasks can be
    accomplished
  • When you break out of these processes that the
    data collected remains intact

7
What is a Process?
  • A process is an instance of a program running in
    a computer.

Whatis.com
8
The Process Model
  • A process can be broken into 2 parts
  • Resource grouping Process says what it needs to
    run
  • Execution The commands that need to occur for
    the command to run (handled by threads)

9
Threads
  • A thread has a program counter that keeps track
    of which instruction to execute next.
  • It also has memory to store the variables it is
    using

10
Threads and Processes
int main() int input coutltltEnter a
number cin gtgt input coutltlt you
enteredltltinput return 0
  • Process
  • Code
  • Data
  • Child Processes
  • Resource List
  • Resources
  • Monitor
  • Keyboard buffer

Process
Thread
Critical region
cout enter a number
cin input
coutyou entered
11
Process Creation
  • Processes are created when
  • The system is initialized
  • A process creates another process
  • The user requests a new process
  • Initiation of a batch job

12
System Initialization
  • There are always processes running in the
    background so when the system starts these
    initial processes begin

13
Process Creates a Process
  • A process that is running meets a condition that
    requires another process to run
  • Real World Example
  • A policeman is patrolling at night, then he
    sees something suspicious. He goes to
    investigate. If there is nothing he continues on
    his rounds. If there is something wrong he calls
    for backup and takes action.

14
The User Requests a Process
  • The user can start up a new program which will
    spawn new processes
  • These programs may be something less important
    like opening an internet browser, or they may be
    critical and require immediate response like the
    triggering of an alarm

15
Process States
  • Running
  • Ready
  • Blocked

running
1
2
3
ready
blocked
  • Process blocks for input
  • Scheduler picks another process
  • Scheduler picks this process
  • Input becomes available

4
16
Running
  • When a process is running that means that it is
    accessing the processor and that its code is
    executing
  • Requirements
  • The process must have all of its devices
    allocated, and it must not be waiting for any
    other processes to run

17
Ready
  • The ready condition is when the process has all
    of its resources allocated and it is not waiting
    on any other processes, and all that it is
    waiting for is to have processor time

18
Blocked
  • A process is blocked when either it is waiting on
    other processes to complete, or it has not been
    able to allocate all of the devices that it needs

19
Process Termination
  • Ways a process is terminated
  • Normal exit (voluntary)
  • Error exit (voluntary)
  • Fatal error (involuntary)
  • Killed by another process (involuntary)

20
Termination Example
  • Normal Exit
  • The document prints
  • Error Exit
  • The printer is out of paper
  • Fatal Error
  • The computer crashes
  • Killed by another process
  • The User cancels the job

21
Scheduling
  • When multiple processes are in the ready state a
    scheduler is required
  • The scheduler uses a scheduling algorithm to
    decide which process can enter the critical region

22
Types of Scheduling Algorithms
  • Non-preemptive Picks a process to run and will
    allow it to run forever until it chooses to end
  • Preemptive Allows the process to run, but at
    anytime it can force the process to move into the
    ready state and allow another process to run

23
Deadlocks
Deadlock Condition when no processes will be
completed because they cannot get the resources
they require
  • All of these conditions must be true for a
    deadlock to occur
  • Mutual Exclusion resources may only be
    allocated to one process at a time
  • Hold and Wait A process may allocate a resource
    and wait for others
  • No Preemption A resource may not be forcibly
    taken away
  • Circular Wait Processes

24
Mutual Exclusion
  • It is important for many resources to be mutually
    exclusive.
  • If a printer was not mutually exclusive to one
    process at a time then if 2 processes were
    printing at the same time then the output would
    blend together and be unreadable.

25
Hold and Wait
  • When reserving the resources not all of them need
    to be available at that time
  • The process can hold on to the ones that are
    available and wait until the others become
    available
  • This is important because if a process were to
    wait to have everything it may never go into the
    ready state. This is because processes not
    requiring as much might continually jump in its
    position.

26
No Preemption
  • This means that a resource cannot be forcibly
    taken away from a process
  • If preemption for resources was allowed then
    processes could constantly take away from each
    other and never get to the processor, or a
    process that was running and whose time expired
    might still need that resource

27
Circular Wait
  • Circular wait means that processes are holding
    resources that other processes need

28
Deadlocks
Total Resources 1 printer 1 CD drive
Process B Holding CD Drive Requesting Printer
Process A Holding Printer Requesting CD Drive
Neither process is ever completed
29
Strategies for dealing with deadlocks
  • Ignore the problem
  • Detection and recovery
  • Dynamic avoidance by careful resource allocation
  • Prevention, canceling one of the 4 conditions for
    deadlocks to occur

30
Ignoring
  • Ostrich Algorithm
  • Do nothing
  • If you know for a fact that a deadlock will occur
    very rarely, and the system is not a critical
    system you may choose to use this strategies
  • This is totally unacceptable for RTOS because
    reliability is a major issue

31
Detection and Recovery
  • Check and see if you are in a deadlock and
    attempt to get out of it
  • This means that the program will have to
    continually check and see if there is a deadlock
  • This wastes too much time

32
Avoidance
  • This means that the program will continually
    check to see whether or not it is in a safe or
    unsafe condition
  • Unsafe is if it is possible for a deadlock to
    occur
  • Avoidance is also timely, but not as bad as
    detection and recovery

33
Prevention
  • To prevent a deadlock you must attack one of
    the conditions for a deadlock to occur
  • Mutual exclusion
  • Hold and wait
  • No preemption
  • Circular wait

34
Attacking Circular Wait
  • To attack the circular wait condition we place
    what resources need to be used in the order that
    they are used
  • This means that the process cannot obtain any
    resource that is farther down before getting all
    the higher ones

35
Attacking Circular Wait
  • Process A
  • CD drive
  • Printer
  • Monitor

In this example Process A may not hold onto the
monitor until having both the CD drive and the
Printer
36
Attacking Hold and Wait
  • This is the best strategy when using the real
    time operating system
  • The strategy here is requiring the process to
    hold all that it requires before entering
    accessing the processor

37
Attacking Hold and Wait
  • The reason this works best is because if the
    process states up front what it needs then there
    is a list of what each has
  • Therefore if a process needs to be executed
    immediately then it can kill the processes
    holding the resources it needs and be run
    immediately

38
RTOS For Smart Sensors
  • Smart sensors need to make decisions on their own
  • Their decisions also need to be quick
  • Also it is important that data be preserved

39
Decision Making
  • There must be a sense of priority, and there
    needs to be the ability to break out of processes
    to make deadlines
  • Since real time systems have a clock specifically
    so that the system knows what time it is in the
    world around it is able to keep deadlines

40
Data Preservation
  • The systems use threading which can save all the
    current information even if the program is
    immediately ended
  • This allows not only the quick response but also
    all the data at the occurrence to be saved

41
Some Smart Sensor Topicswhere RTOS is Essential
  • Scheduling Communication in Real-Time Sensor
    Applications Huan Li, University of
    Massachusetts, AmherstPrashant Shenoy,
    University of Massachusetts, AmherstKrithi
    Ramamritham, Indian Institute of Technology,
    India
  • Static Real-Time Data Distribution Angela
    Uvarov, University of Rhode Island, Kingston,
    RILisa DiPippo, University of Rhode Island,
    Kingston, RIVictor Fay-Wolfe, University of
    Rhode Island, Kingston, RIKevin Bryan,
    University of Rhode Island, Kingston, RIPatrick
    Gadrow, University of Rhode Island, Kingston,
    RITimothy Henry, University of Rhode Island,
    Kingston, RIMatthew Murphy, University of Rhode
    Island, Kingston, RIPaul R. Work, Raytheon
    Company, Portsmouth, RILouis P. DiPalma,
    Raytheon Company, Portsmouth, RI
  • Radio-Triggered Wake-Up Capability for Sensor
    Networks Lin Gu, University of VirginiaJohn A.
    Stankovic, University of Virginia

42
Example
  • An airplane has many sensors relaying data back
    to the pilot
  • If something were to go wrong the sensors would
    need to send an error to the pilot, and take any
    other action (triggering an extinguisher)
  • However it is almost as important that the
    sensors are able to record the data at the point
    of the problem so that the incident can be
    understood

43
Homework
  • Discuss the differences between preemptive and
    non-preemptive in relation to scheduling
  • Pick a sensor you think would require a real time
    system and state why you picked it

44
Questions
45
References
  • Modern Operating Systems 2nd edition, Tanenbaum
  • Whatis.com
  • Special thanks to Hussein for his help
Write a Comment
User Comments (0)
About PowerShow.com