lesson_03.md 3.8 KB

Advanced Operating Systems and Embedded Systems - lesson 3

William Fornaciari

11 October 2016

Real Time Operating Systems

Real time system

Is a system which has to provide a result within a time range usually before a deadline

Classification

  • mission critical systems
    • tipycally involves safety
    • static allocation of resources
  • soft real time: Best effort performance, if the system underperforms, nobody dies but we have a loss of quality

In a system like windows OS, a general delay from an event like mouse movement and the reaction takes 200ms, while is a RTOS this time needs to be under 10ms.

Charachteristics required for a RTOS

  • Deterministic behaviour: operations are executed ad predetermined times or intervals
  • Responsiveness: involves minimum interrupt latency, and is due to the fact that usually RTOS systems are part of control loops, and the speed of the control system needs to be some tipically 5 times the speed of the system. Measures to guarantee fast ISR time include:
    • Inhibiting nested routines
    • Calling ISR without context switching
  • User control: User should have a much more specific control on applications w.r.t. ordinary OS
  • Reliability: The worst case is to have a blue screen where everything stops. A much less worse case is to have a graceful degradation of the performances, an example is the thermal throttling of the CPUs when overheating.

For example in the case of a washing machine, in case of a power loss we have 30-100ms before the capacitors discharge, to save the content of RAM to a permanent memory. This behaviour is called fail-soft and consists of preserving as much data ad possible in case of failure.

RTOS Features

  • Low cost, small size: usually they employ open-source code.
  • ~20 tasks usually required for an embedded project.
  • Use of semaphors for fast access protection.
  • A general paradigm for fast access is shared memory protected by semaphors
  • For choosing schedulers predictability is preferred over complexity, because of this generally used schedulers are FIFO or round robin

Time Constraints

The "ready" event (process woke up for receiving data) may be:

  • periodic: for example sampling at fixed rate, ex: 100Hz
  • aperiodic but predictable The computation time may be:
  • Fixed in duration
  • Variable
  • Unpredictable: for example human activity with a computer is unpredictable.

Deadlines

  • hard: the computation must be completed within the limit or there will be a critical error
  • soft: the deadline is expressed as a preference, but is not critical. The criticality of a Deadline can be expressed by means of a Value Function

Preemption

Makes possible to suspend a process when another task needs to be executed and and restore the work later.

Different tipes of computation can be preemptable or not or, only preemptable in a specific part of their execution

Keeping the system in a safe state is costly, a better tradeoff could be keeping the system in a safe state only for portions of the time.

Schedulability analisys consist in deciding to accept or not a new process

to guarantee the safely conclusion of the existing processes. Can be carried out:

  • statically: at bootstrap time
  • dinamically: when the process is created Static table driven sched. an. is suitable only for mature systems when the execution of the processes is known from the project. A famous example is the Rate Monotonic analisys Dynamic planning based: feasibility is determined at runtime

Design Issues

A key problem is choosing the process to be executed next Sometimes using a non-preemptive scheduler makes sense because this way you can not take away the resources that you have allocated.