Lecture11 - Real Time Opearting System

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

A Real-time system What is it?

• It is any information processing system which has to respond to externally generated input stimuli
within a finite and specified period

–There are 2 types: hard and soft


 In real time systems the reaction to an event has to occur within a specified time.
–the correctness depends not only on the logical result but also the time it was delivered

Hard Real-time Systems


 Hard real-time — systems where it is absolutely imperative that responses occur within the
required deadline.
–failure to meet the deadlines results in a catastrophic system failure or the system is
deemed to be “broken”.

Soft Real-time Systems

• Soft real-time — systems where deadlines are important but which will still function correctly if
deadlines are occasionally missed. E.g. Data acquisition system.
–Its still required to meet the deadlines but it is not fatal if those deadlines are occasionally
missed by a short time.
Multi-tasking What is a task?

A TASK is a small, simpler individual piece of a complex problem.

MULTI-TASKING: Is when tasks work together in an organized way to solve a complex problem

The important aspects of multi-tasking are:


–Exchange or sharing data between tasks
–Synchronizing tasks
–Scheduling task execution
–Sharing resources among tasks

Who coordinates tasks?

An OPERATING SYSTEM: Is the piece of software that provides the required coordination during
multitasking.

REAL-TIME OPERATING SYSTEM (RTOS): Is an operating system where the control must
ensure that a task execution satisfies a specific time constraint.
A look at processes & programs

EMBEDDED PROGRAM is a collection of firmware modules and is normally static (not running)

PROCESS is a firmware module that is running or executing

Resources allocated to the process by the operating system are:


–Process stack
–Memory address space
–Registers
–I/O ports
–Network connections
–Program counter: it points to next
instruction to be executed
What are Threads?
THREAD: this is the smallest subset of resources needed for a task/process

Examples of threads are: registers, program counter, stack.


–A single task with one thread of execution as shown below
–Also many threads can be allocated to a single process as shown below
Multi - threads
MULTI-THREADED OPERATING SYSTEM: is an operating system that supports tasks with
multiple threads

The four categories of a multitasking operating systems are:


1. single process - single thread: one process running forever
2. multiprocess - single thread: multiple simultaneously executing processes each with a single thread
3. single process - multiple thread: has only one process with multiple threads of control
4. multiprocess - multiple thread: has multiple processes each with mutliple threads.
What states can processes have?
Actually during multitasking only one process is in RUN state, others in READY/WAITING states

Task states change depending on how active they are as shown in state diagram

How are tasks scheduled?

SCHEDULE: specifies when, under what conditions, and for how long each task uses the resources

SCHEDULING STRATEGY: is the criteria used to decide which task runs next.

The three scheduling strategies are:


1.Multiprogramming: Here a running task will continue until it performs a WAITING operation
2. Real-time: tasks with deadlines allowed to complete first
3. Time sharing: timer is used to allocate a time for each task one after another
RTOS
• REALTIME OPERATING SYSTEM (RTOS): is an operating system that ensures that rigid time
constraints are met.

• RTOS Applications:
–scientific experiments
–control systems,
–applications were missed deadlines cannot be tolerated

• Functions Of Real Time Operating System (RTOS):


1. schedule task execution (using a scheduler)
2. Dispatch a task to run (using a dispatcher)
3. Ensure communication and synchronization among tasks

Real-time Kernel
• Real Time Kernel: this is the smallest portion of the Real Time Operating System that performs
the scheduling, dispatching, communication/ and syncronization of tasks.
Preemptive and Non-Preemptive and Early Deadline first
Priority based Scheduling

 In preemptive priority based scheduling, any high priority process entering the
‘Ready’ queue is immediately scheduled for execution

 Non-preemptive scheduling any high priority process entering the ‘Ready’ queue
is scheduled only after the currently executing process completes its execution or
only when it voluntarily releases the CPU

 Earliest deadline first selects a task according to its deadline such that a task
with earliest deadline has higher priority than others. A task which has a higher
priority due to earliest deadline at one instant it may have low priority at next
instant due to early deadline of another task. EDF typically executes in preemptive
mode i.e. currently executing task is preempted whenever another task with
earliest deadline becomes active.
Preemptive and Non-Preemptive and Early Deadline first
Priority based Scheduling

Arrival time (AT) is the time when a process enters into the ready state and is ready for its
execution.
Burst time (BT) is the total time taken by the process for its execution on the CPU.

Exit (Completion) time (CT) is the time when a process completes its execution and exit from the system.

Response time (RT) is the time spent when the process is in the ready state and gets the CPU for the first
Response time = Time at which the process gets the CPU for the first time - Arrival time
time

Waiting time (WT) Waiting time is the total time spent by the process in the ready state waiting for CPU.
Waiting time = Turnaround time - Burst time

Turnaround time (TAT) is the total amount of time spent by the process from coming in the ready state for the
first time to its completion.
Turnaround time = Burst time + Waiting time or Turnaround time = Exit time - Arrival time
Throughput is a way to find the efficiency of a CPU. It can be defined as the number of processes executed
by the CPU in a given amount of time.
Preemptive - Priority based Scheduling
Example

https://www.youtube.com/watch?v=hDn4hM148V8
Non-Preemptive - Priority based Scheduling
Example

https://www.youtube.com/watch?v=i4PQucowf1c

You might also like