Lecture 9 - Embedded operating systems Flashcards
What is the difference between a process and the operating system?
The process defines the state of an executing program, and the OS provides mechanisms to switch execution between processes
Why can using OS and processes be beneficial in embedded systems?
Combining these can allow us to implement complex applications with greater flexibility that satisfy timing requirements.
When abstracting the control required to switch between processes to the OS, it is easier to meet timing requirement while keeping the control within the processes cleaner.
What is a RTOS?
Real-time Operating System
An OS that facilitates to meet real time requirements.
An RTOS allocates resources using algorithms that takes timing into account.
How does resource allocation differ in an OS and a RTOS?
An OS will try to allocate resources using the criteria of fairness, giving the different parts of the CPU equally much resources.
A RTOS need to take timing into account. If a RTOS allocate resources equally without thinking about timing, deadlines are likely to be missed.
Define the term “Task” in regards to real-time computing
A set of real-time programs that communicates.
What is a task-graph?
Graph showing the different subtask and dependencies between these.
The edge-arrows defines dependencies between subtasks
What is a process?
Single execution of a program.
Has its own state, memory and registers.
What are threads?
Processes that run in the same address space.
What is multirate systems?
A system where multiple rates of computation must be handled.
Certain operations must execute periodically, and each operation is executed at its own rate.
What are two types of timing requirements that are important for processes?
Initiation time and deadlines
What is the initiation time?
The time at which the process goes from the waiting state to the ready state.
How are aperiodic processes initialized?
The initiation time is measured from the event that initialises it (arrival of extern data, computation of data from another process)
How are periodic processes initialised?
Can be ready at the beginning of a period.
Others may set initiation time at the arrival time of certain data after the start of the period
What are deadlines?
Specifies when computation must be finished.
How are deadlines for aperiodic processes measured?
Deadlines are measured from the initiation time, as these are the only reasonable time references available.
How are deadlines for periodic processes measured?
Deadlines will generally occur at some time before the period ends.
Some scheduling policies simplify that the deadline occurs at the end of the period
What are rate requirements?
How quickly must processes be initialised
What is a period?
The time between successive executions in a process.
Specification of the expected behaviour of a task
What is the process’s rate?
Inverse of its period.
In multirate systems, each process executes at their own rate
What is a common requirement for periodic processes?
Initiation interval to be equal to the period
What is response time?
The time at which the process finishes.
If the schedule meets the requirements, the response time will be before the period end.
Computation time is a part of response time, but response time also includes time the process is de-scheduled by other tasks.
What is computation time?
How long it takes to execute.
What is the jitter of a task?
The allowable variation in its completion.
What can happen if a deadlines is missed?
In safety-critical systems it can be catastrophic if deadlines are missed, and they might want to take measures to i.e. approximating data or switching into a safety modes.
For systems where safety is not that important, simpler measures can be taken, or the failure can be ignored all together.
What is utilization?
Available CPU time, a way to measure the efficiency at which we use the CPU.
U = CPU-time-for-useful-work / total-available-CPU-time
What is scheduling?
The work of choosing the order of running processes
Name the 3 scheduling states
Waiting, ready and executing
Ready: Any process that could be executing are in the ready state, have received all data, has entered a new period
Waiting: A process waiting for data, completed all work for this period
Executing: Process selected by the scheduler to run
What is a scheduling algorithm?
Algorithm that decides how processes are selected for the promotion from the ready to the execute state.
What does scheduling algorithms take into account?
Timing requirements
The efficiency with which they use the CPU.
Utilization is a key metric in evaluating scheduling policies.
Scheduling overhead, execution time required to choose next execution
What 2 concepts does RTOS depend on?
Preemption and priority-based scheduling
What is preemptive scheduling?
Running tasks can be preempted during execution
Based on the system’s timing constraints, we are allowed to jump between functions whenever necessary.
The kernel is the part of the OS that determine what process is running.
The timer periodically activates the kernel.
The time quantum is the length of the timer period. This is generally shorter then the period of the processes being scheduled
The kernel decides what process is going to be run next.
What is prioritised scheduling?
The processes are assigned priories. The kernel looks at these priorities to decide what process to run next. This would be the process with the highest priority, that is ready to run.
What is context switching?
Switching from one process’s context to another one’s
This happens when the timer interrupts a process, the process state is saved by assembly language.
The kernel is then given execution rights and decide what process to schedule.
This new process’s state is restored
What is a context?
The registers that defines a process
What is a record?
The data structure that holds the state of a process
What are active objects in UML?
When processes are described in UML they are active objects.
Active objects have independent threads of control.
Includes name, attributes, operations, signals
Signals: An object passed between an object for asynchronous communication
What is the round robin scheduling algorithm?
Used in general-purpose OS
All processes kept on a list and scheduled one after another. Uses some preemption so that one proces does not keep all resources. Schedules to provide fairness.
Does not guarantee completion time. As list of processes increase, so does response time for all processes.
How is scheduling often done in RTOS?
Priority based
Real time requirements are important
What is the Rate-monotonic scheduling algorithm?
A static scheduling policy: Processes gets fixed priorities
preemptive
Based on the rate-monotonis analysis (RMA) theory, this gives a quite simple scheduling policy.
Priorities are assigned by rank order of period, shorter periods gets higher priority
This policy is the optimum assignment of static priorities to processes, in that it provides highest utilisation while ensuring everyone meets deadlines.
What is the Rate-monotonis analysis (RMA) theory
All processes run periodically on a CPU
Context switching time is ignored
No data dependencies between processes (resource sharing)
Execution time for a process is constant
All deadlines are at the end of their periods
The highest-priority ready process is always selected
What is the critical instant for a process?
The instant during execution at which the task has the longest response time.
What is the critical interval for a process?
The complete interval for which the process has the longest response time
What is the critical instant for any process under RMS?
When the process is ready and all the higher priority processes also are ready
Does RMS always provide feasible scheduling?
No, the scheduling algorithm might not provide scheduling of processes in a way that all deadlines are met
What is the Earliest-deadline-first scheduling policy?
Its a dynamic priority scheme: Changes process priorities based on initiation time.
Preemptive
Assumption: Deadline=Period (in paper), no sharing, no context switching time
Updates priorities at every time quantum, and they are assigned based on nearest deadline. Highest priority to process where deadline is nearest.
Highest priority process that is ready is scheduled
If a process set is not schedulable by EDF, no other scheduling algorithm can schedule tthe task set
Compare EDF and RMS scheduling
EDF can schedule some process-sets that RMS cannot.
What is a race condition?
When multiple processes accesses the same data and modifies, making wrongful results when operating in different orders.
What are mutexes?
Protects critical sections.
A mutex is called before a critical section is entered. The process calling the mutex reserves it.
If another process tries to get the mutex, it won’t be able to as long as it is reserved by someone else.
A process cannot enter a critical section without a mutex, and needs to wait until the mutex is released.
What are semaphores?
Useful when several copies of resources are available.
They have a name property, which allows to create multiple semaphores in a system, and a counter keeping track of remaining available resources.
P() is called to get access to the resources. If max resources are given, the process waits until a semaphore is released and signaled using V().
What operation is required to be able to implement mutexes and semaphores?
Atomic read/write.
i.e. when setting semaphores we use Test-and-set. We first read it, then if it is set we get returned false. If it is not set we set it and return true.
Why does critical section provide problems in real time systems?
Because interrupts are disabled when working on a critical section. And other processes cannot be scheduled.
What is priority inversion?
When a lower priority process blocks execution of a higher priority process by keeping hold of its resources (critical section).
What is priority inheritance, and what problem does it solve?
Solves priority inversion.
The priority of a process is upgraded when the process requests a resource from the OS. The priority of this process becomes higher than the priority of other processes using this resource. This ensures that it can continue execution once it has this resource to be able to finish its work.
What assumptions have we made with RMS and EDF?
Context switching takes 0 cycles
No data dependencies in RMS
Process execution time is constant: Can vary based on caching and data dependences
What are the two ways a process can send communication?
Blocking and non-blocking
What is blocking communication between processes?
The process goes into a waiting state until it receives a response.
What is non-blocking communication between processes?
The process continues execution after sending the communication
What are the 3 styles of interprocess communication?
Shared memory and message passing
Signals
What is shared memory communication?
Processes can communicate by writing to and reading from a shared memory location
What is message passing communication?
Each process has their own message passing/receive unit
Message is stored at the senders/receivers endpoints.
Use a queue to manage message. This queue uses FIFO.
What is communication using signals?
Signals are software created, and generated by a process and passed to another by the OS.
What do we need to take into account when evaluating RTOS performance
Context switching time
Variable process execution time
Latency from when interrupt is requested to when handling is finished
execution time of scheduler
What is the layout of a single threaded process?
Code | data | files
registers | Stack
thread
What is the layout of a multi threaded process?
each thread has its own registers and stack, in addition to shared code, data and files
What are the properties of embedded OS
Customizable
resource-efficient: Small memory footprint
predictable or deterministic: real-time capabilities
energy efficient: dynamic power management
Why are not desktop OSs suited for embedded systems?
Require large disk space
They are usually monolithic - provide numerous services for diverse hardware
No real-time guarantee
No features for reliability
What is the Compare Fair Scheduling (CFS)
Used in OS
Chooses process with lowest execution time
Goal: Fairness
No real-time guarantee
What does real-time mean for embedded systems?
The correctness of the system depends both the logical result and on the time at which the result was produced.
Predictability and determinism
deadlines and real-time requirements
What is hard real time?
Catastrophic consequenses
What is soft-real time
Desirable features (i.e. video playback)
What information about a process does a real-time scheduler know?
Starting time
Execution time (Worst-case)
Deadline
Period (Common - periodic tasks)
Priority (rigorously respected)
What is energy efficient scheduling?
Energy and power are main concerns especially in systems that are battery supplied.
Can use DVFS to lower power usage
Determine values that just meets the deadline