Vous êtes sur la page 1sur 27

EMBEDDED SYSTEMS

UNIT IV

by Venkatesan N Lect. | CSE | KITE

Introduction
What is RTOS?
A Real-Time Operating System (RTOS) is a computing environment that reacts to input within a specific time period

Purpose?
To handle the Deadline Time Constraints

Process, Tasks, Thread


A process is an instance of a computer program that is being executed Ex: -This can be anything from a small background task, such as a spell-checker or system events handler to a full-blown application like Internet Explorer or Microsoft Word.

TASK
a task is a basic unit of programming that an operating system control Depending on how the operating system defines a task in its design, this unit of programming may be an entire program or each successive invocation of a program

THREADS
A thread is a single sequence stream within in a process they are sometimes called lightweight processes

Processes Vs Threads
Similarities
Like processes threads share CPU and only one thread active (running) at a time. Like processes, threads within a processes, threads within a processes execute sequentially. Like processes, thread can create children. And like process, if one thread is blocked, another thread can run

Differences
Unlike processes, threads are not independent of one another. Unlike processes, all threads can access every address in the task . Unlike processes, thread are design to assist one other. Note that processes might or might not assist one another because processes may originate from different users.

Threads and Processes


int main(){

Process Code Data Child Processes Resource List

int input;

Resources
Monitor
Keyboard buffer

cout<<Enter a number:; cin >> input; cout<< you entered:<<input; return 0; }

Process
Thread
cout:you entered cin: input
cout: enter a number

Critical region

ISRs have the higher priorities over the RTOS functions and the tasks. An ISR should not wait for a semaphore, mailbox, message or queue message An ISR should not also wait for mutex else it has to wait for other critical section code to finish before the critical codes in the ISR can run.

ISRs in RTOS

Three alternative ways systems to respond to hardware source calls from the interrupts
- Direct Call to an ISR by interrupting - Event Message (IPC) from the ISEvent ISR Direct Call to an ISR and ISR Enter Direct Enter message

Operating System Services


Goals
Facilitating easy sharing of resources as per schedule and allocations Facilitating easy implementation Optimally scheduling the process Maximizing the system performance to let difference processes Providing management functions Management and organization functions for files and files like devices

Providing easy interfacing and management functions for the network protocols Providing portability for hardware configurations Providing interoperability of applications on different networks Providing a common set of interfaces that integrates various applications and open systems

Structure of RTOS
Top-down Layers Application software Application Program Interface System software other than the one provided at the OS Hardware-OS Interface Hardware

Generally OS runs in two modes


USER Mode(The user process is permitted to run and use only a subset of functions) Supervisory Mode(The OS runs the privileged functions and instructions in a protected mode)

Kernel
The OS includes certain structural units.
Kernel is also one of the structural unit It is the secured unit of an OS It operates under the supervisory mode But the application software operates in the user mode

Kernel Services in OS
Process Management
Process Creation Management of the created process(creation, activation, running, blocking, resumption, deactivation, deletion)

Memory Management
Memory Allocation Memory Management after initial allocation Managing Strategy(Fixed blocks, Dynamic Blocks, Dynamic page, Data Memory Allocation, Address relocation, Multiprocessor Memory Allocation)

Device Management
It manages physical as well as virtual devices like pipes and sockets Device mgmt. has three approaches to 3 types of drivers
Programmed I/Os by polling Interrupts from the device drivers ISR DMA operation

It has certain functions like Device detection, addtion, deletion, allocation, registration, detaching, deregistration, queue,etc

OS command functions for a device


Create and open Write Read Ioctl(Configuring the device to operate at particular baud rate) Close and delete

File System organisation and implementation


A file is a named entity on a magnetic disc, optical disk or system memory It may be a named entity or a structured record or an unstructured record of bits It uses set of command functions in POSIX file system
Open Write Read Lseek close

I/O Subsystems
They are the subsystems of OS device management systems It is used for the drivers to communicate with many devices which is present in the system

Interrupt Routines Handling in RTOS


There are three ways to call the services on interrupting
Direct call to ISR By an Interrupting Source Direct call to RTOS by an Interrupting Source and Temporary Suspension of a Scheduled Task Direct call to RTOS by an Interrupting Source and Scheduling of Tasks as well as ISRs by the RTOS

RTOS Task Scheduling Models


Control Flow Strategy Data Flow Strategy Control -Data Flow Strategy

Scheduling Models used by RTOS Schedulers


Cyclic cooperative scheduling of ready tasks in a circular queue. Cooperative scheduling with precedence constraints Cyclic cooperative scheduling with time slicing Preemptive scheduling Fixed times scheduling Scheduling of Periodic, Sporadic and aperiodic tasks Dynamic Real Time Scheduling using Earliest Deadline First(EDF) precedence Advanced scheduling algorithms using the probabilistic timed petri nets or multi thread graphs.

RTOS inserts a list of ready tasks for sequential execution Program counter changes whenever the CPU starts executing another process Worst case latency is same for each task It is calculated by summing up detection time, switching time, execution time

The Cooperative Round Robin Scheduling Using a circular queue of Ready Tasks

Cooperative scheduling with precedence constraints


In the first layer ISR has set of short codes that have to be executed immediately Its sends a flag or token and its priority parameter for the task to be initiated

Cyclic cooperative scheduling with time slicing(Rate Monotonic Cooperative Scheduling)

The RTOS defines a time slice for each task to finish If the process is not executed within the time then it is executed in the next cycle

Preemptive scheduling
In the cooperative scheduling the low priority job is executed for long time and thus making a high priority job to wait for execution Preemptive scheduling lets a pending highpriority job take resources away from a running job of lower priority.

Critical section service by a preemptive scheduler


The blocking of a lower priority process for executing high priority process should not be done in critical situations It creates tasks and

Vous aimerez peut-être aussi