Download presentation
Presentation is loading. Please wait.
Published byBettina Flater Modified over 6 years ago
1
Real Time Operating Systems for Networked Embedded Systems
2
Real Time System A system is said to be Real Time if it is required to complete it’s work & deliver it’s services on time. It responds within stipulated time constraint It provides a software abstraction layer for MC and CPU.
3
Hard and Soft Real Time Systems
Hard Real Time System Critical task are completed on time. Failure to meet deadlines is fatal Secondary storage is limited Air traffic control Soft Real Time System Critical real time task gets priority over other task. System performance degrades as more & more jobs miss deadlines Online Databases
4
Hard and Soft Real Time Systems (Operational Definition)
Hard Real Time System Validation by provably correct procedures or extensive simulation that the system always meets the timings constraints Soft Real Time System Demonstration of jobs meeting some statistical constraints suffices. Example – Multimedia System 25 frames per second on an average
5
Responsibilities of RTOS
Task management and scheduling Interrupt servicing IPC and synchronization Memory management
6
Benefits of RTOS’s Simplify the development and improve productivity
Present an abstraction to processor. Implements reliable scheduling Integrates and manage resources. Optimizes the resources. Brings all elements together in a single platform.
7
Characteristics of RTOS
Deterministic Operations are performed at fixed Long os delay before ack an interrupt Responsiveness User control Reliability Fail soft operation
8
OS services Initial loading of programs Process management function
Memory management function Device management function File management function Secondary storage management function Network management function Protection and security management function Command interpretation.
9
Process management It is a program in a state of execution
It handles allocation of resources. Various states during execution of the process New: process is created Ready: process is ready to be executed on processor. Running: processor executes the process. Waiting: processor waits for some event to happen Terminated: process has finished the execution.
10
Process management (continued)
Multiple processes share the hardware at same time. Process manager implements CPU sharing, process synchronization and deadlock strategy. Process manager carries out several services such as creating, suspending, executing, terminating and destroying the processes.
11
Functions of Process manager
CPU sharing. Resource allocation Implements process synchronization and IPC. Implements deadlock strategies and protection mechanism.
12
Creation of process Process manager allocates the process control block when it creates the process and later manages it. PCB is a process descriptors used by process manager Identifier. Process state Priority. Program counter CPU registers CPU scheduling information (e.g., priority, scheduling queue information) Memory management information (e.g., base and limit registers) Accounting information (e.g., time) I/O status information
13
Process termination A process terminates when it finishes executing its last statement. Its resources are returned to the system, it is purged from any system lists or tables, and its process control block (PCB) is erased i.e., the PCB's memory space is returned to a free memory pool
14
Process termination The new process terminates the existing process, usually due to following reasons: Normal Exist :Most processes terminates because they have done their job. This call is exist in UNIX. Error Exist :When process discovers a fatal error. For example, a user tries to compile a program that does not exist. Fatal Error: An error caused by process due to a bug in program for example, executing an illegal instruction. Killed by another Process: A process executes a system call telling the Operating Systems to terminate some other process. In UNIX, this call is kill. Cascading termination: if parent process is terminated, child processes are automatically terminated.
15
Timer functions Timer function is a simple service that delays a task for a period of time. Timer function: TaskDelay()- It creates a period of time of delay in its argument. Timer functions must be accurate to the nearest system tick (period)
16
Timer functions in RTOS.
OS_TICK_PER_SEC─ to set the system clock ticks and hence SysClkIntr interrupts per second. OSTickInit ( )─ to initiate system clock ticks. OSTimeDelay ( )─ to delay the process making call by a fixed number of system clock ticks specified in argument. OSTimeDelay-Resume ( )─ to resume a delayed process specified in the argument OSTimeSet ( )─ to set the counts of system clock ticks OSTimeGet ( ) ─ to read the counts of system clock ticks to find the time interval from the previous read or write of the counts. OSSemPend (semVal, twait, *semErr)─ to wait for a semaphore release OSMboxPend (semVal, twait, *mboxErr) ─ to wait for a message in mailbox (wait for message pointed not Null)
17
Event function Event is an boolean flag that tasks can set or reset
Features of event More than on task can block waiting for an event and RTOS will unblock all of them. RTOS woks on group of events and task can wait for any subset of event within group. OS event register flag bits Flag=1 occurrence of an event in an event register. Flag=2 an event in a group has not occurred.
18
Event functions in RTOS.
OSEventQuery ( )─ to query an event register to find the event register existence and its contents. OSEventDelete ( ) ─ delete the event register SET (event_flag) to set one of the bits at the event register CLEAR (eventFlag) clears the flag in the event register. An event flag can be cleared by an ISR or Task WAIT_ALL function─ task waits for the occurrences of setting all the event flags in a group. [Wait till AND operation between all flags in the group equals true.] WAIT_ANY function─ task waits for the occurrences of setting at least one event flag setting in a group. [Wait till OR operation between all flags in the group equals true.]
19
Memory management Allocation of portions of memory to programs
Main parts of main memory Resident monitor: area of memory accessed by user process and OS resides User area: main memory space which is allocated for user process.
20
Memory allocation Contiguous Memory Allocation.
Single partition allocation Multiple partition allocation Static or fixed partition Dynamic or variable partition. Non contiguous Memory Allocation. Paging Basic paging Demand paging segmentation
21
Device management Device management: the OS component that manages hardware devices Provides a uniform interface to access devices with different physical characteristics Optimize the performance of individual devices I/O device hardware includes buses, port and device controllers Device controller Conversion a block of bytes and I/O operations Performs error correction if necessary Expose hardware registers to control the device Typically have four registers: Data-in register to be read to get input Data-out register to be written to send output Status register (allows the status of the device to be checked) Control register (controls the command the device performs)
22
Device manager It provides the appropriate level abstraction to handle system devices. Functions of device manager Achieve devices independent. Handle error Speed up transfer of data Handle deadlock Enable multi user system to use dedicated devices. Techniques for device management Dedicated devices Shared devices Virtual devices
23
File management Requirement of file system Store the info in long term
Data sharable among processes. Huge size data accommodated in appropriate storage. Files are structured, named, accessed and protected by OS File management system objectives Data management need and requirement by user I/O support by storage devices Standardized set of I/O interface routine Minimize the potential for lost or destroyed data
24
File manager Keeps track of every file in the system Need for file
Long term existence Shareable between processes structure Functions of File manager Enforces the restriction on who access to which file Controls the user are allowed to access the file Allocates resources by OS Controls the naming of files Responsible for achieving and backups
25
I/O subsystem Combination of I/O device, device driver and I/O subsystem Purpose of I/O system Hide the device specific info from kernal Provide uniform access
26
Basic design of RTOS An embedded system with a single CPU can run only one process at an instance. The process at any instance may either be an ISR, or kernel function or task
27
Other RTOS’s (contd) VxWorks pSOS Monolithic Architecture
Real Time Posix compliant Cross development System pSOS Object Oriented OS
28
RTOS facilities Provides running the user threads in kernel space so that they execute fast. Provides effective handling of the ISRs, device drivers, ISTs, tasks or threads Disabling and enabling of interrupts in user mode critical section code Provides memory allocation and deallocation functions in fixed time and blocks of memory. Provides for effectively scheduling and running and blocking of the tasks in cases of number of many tasks I/O Management with devices, files, mailboxes, pipes and sockets becomes simple using an RTOS Effective management of the multiple states of the CPU and, internal and external physical or virtual devices
29
Design principles of RTOS
Design with the ISRs and Tasks. Provides of nesting of ISRs, while tasks run concurrently A task─ wait and take the messages (IPCs) and post (send) the messages using the system calls Each ISR design consisting of shorter code A design principle is that the ISR code should be optimally short and the detailed computations be given to an IST or task by posting a message or parameters for that. Design with using Interrupt Service Threads or Interrupt Service tasks In certain RTOSes, for servicing the interrupts, there are two levels, fast level ISRs and slow level ISTs, the priorities are first for the ISRs, then for the ISTs and then the task Design with using Interrupt Service Threads. Each task has a while loop which never terminates. A task waits for an IPC or signal to start. The task, which gets the signal or takes the IPC for which it is waiting, runs from the point where it was blocked or preempted.
30
Design principles of RTOS
Design Each Task with an infinite loop. Each task has a while loop which never terminates. A task waits for an IPC or signal to start. Design in the form of tasks for the Better and Predictable Response Time Control. provide the control over the response time of the different tasks. The different tasks are assigned different priorities and those tasks which system needs to execute with faster response are separated out. Design in the form of tasks Modular Design. System of multiple tasks makes the design modular. The tasks provide modular design Design in the form of tasks for Data Encapsulation. System of multiple tasks encapsulates the code and data of one task from the other by use of global variables in critical sections getting exclusive access by mutex
31
Design principles of RTOS
Design with taking care of the time spent in the system calls. expected time in general depends on the specific target processor of the embedded system and the memory access times. Some IPCs takes longer than the other Design with Limited number of tasks Limit the number of tasks and select the appropriate number of tasks to increase the response time to the tasks, better control over shared resource and reduced memory requirement for stacks Use appropriate precedence assignment strategy and Use Preemption. Use appropriate precedence assignment strategy and Use Preemption in place of Time Slicing Avoid Task Deletion Create tasks at start-up only and avoid creating and then deleting tasks later at the later times.
32
Design principles of RTOS
Use CPU idle CPU time for internal functions Read the internal queue. Manage the memory. Search for a free block of memory. Design with Memory Allocation and DeAllocation By the Task. If memory allocation and de-allocation are done by the task then the number of functions required as the RTOS functions is reduced. This reduces the interrupt-latency periods. As execution of these functions takes significant time by the RTOS whenever the RTOS preempts a task. Design with taking care of the Shared Resource or Data among the Tasks. The ISR coding should be as like a reentrant function or should take care of problem from the shared resources or data such as buffer or global variables Design with limited RTOS functions Use an RTOS, which can be configured. RTOS provides during execution of the codes enabling the limited RTOS functions. For example, if queue and pipe functions are not used during execution, then disable these during run
33
RTOS programming
34
Types of RTOS In-House developed RTOS Broad based commercial RTOS
General purpose OS with RTOS Special focus RTOS.
35
RTOS µCOS-II MicroC/OS-II (commonly termed as µC/OS-II or uC/OS-II), is the acronym for Micro-Controller Operating Systems Version 2 It is a priority-based real-time multitasking operating system kernel for microprocessors, written mainly in the C programming language. It is a very small real-time kernel. Memory footprint is about 20KB for a fully functional kernel. Source code is written mostly in ANSI C. Highly portable, ROMable, very scalable, preemptive real-time, deterministic, multitasking kernel. It can manage up to 250 application tasks (56 user tasks available).
36
Features of µCOS-II Source code Multitasking Portability Scalability
Services Automotive add-on
37
system level functions
Initiating the os before starting the use of the RTOS functions. Starting the use of RTOS multi tasking functions and running the task. Starting the use of RTOS system clock. Sending msg to RTOS Kernel for take control At the start of an ISR. Sending msg to RTOS Kernel for quitting the control at the return from an ISR. Sending msg to RTOS Kernel for take control At the start of a critical section. Sending msg to RTOS Kernel for quitting the control at the return from a critical section. Locking & Unlocking OS scheduler
38
Task Service & Time Functions
Service functions means the functions to create task, Suspend and resume and time setting and time retrieving functions. Time functions set Time & Get Time in terms of the no.of system clock ticks. 1. The functions OS task create () returns the following OS_NO_ERR OS_PRIO_EXIST OS_PRIO_INVALID OS_NO_MORE_TCB 2. suspending a task OS_TASK_SUSPEND_PRIO OS_TASK_SUSPEND_IDLE 3. resuming a task 4. setting time in system clock 5. getting time of system clock
39
Time delay functions Delaying by defining a time delay by no.of clock ticks function. Function void Os time dly delays tasks by tick of system clock it returns no parameter. Resuming a delay task by Os time dly. function unsigned byte Os time dly resume a previously delayed task whether delay parameters was interms of the delay counticks or hours, minutes, seconds. Delaying by defining a time delay in units of hours, minutes, seconds, milli seconds function void Os time dly HMSM delays up to ticks.
40
Memory Allocation –Related Functions
Mem0ry functions are required to allocate fixed size memory Blocks from the memory partition having integer no.of blocks the allocation takes Place with out fragmentation the allocations & deallocations takes places in fixed & Deterministic. Creating a memory blocks at memory address. Function OSMem *OSMem create is an Os function which partitions the memory from an address with partitions in the blocks. Getting a memory blocks at memory address.Function void *OSMem get. Querying a memory block.Function unsigned byte OSMemquery. Putting a memory block into a partition.function unsigned byte OSMemput.
41
Semaphore – Related functions
Creating a semaphore for the IPCs. Function Os_event Os sem create. Waiting for an IPC for semaphore release. Function void Os sempend. Check for availability of an IPC after a semaphore release. Sending an IPC after a semaphore release function unsigned byte Os sempost. Retrieve the error information for a semaphore.
42
Queue – related Functions
By using a queue we can communicate an array of msg pointers From the task. The msg pointers can be posted into queue by the task either at the Back as in a queue or at the front as in a stack Creating a queue for An IPC. Waiting for an IPC msg at a queue. Emptying the queue & eliminating all the msg pointers. Sending a msg pointer to the queue. Sending a msg pointer & inserting it at the queue front. Querying to find the msg & error information for the queue ECB
43
Mail Box – Related Functions
Creating a mail box for an IPC. Check for availability of an IPC after a msg at mail box. Wating for availability of an IPC for a msg at mail box. Send a msg for an IPC through mail box. Finding mail box data and retrieving the error information for mail box.
46
Peripheral devices and protocols
Interfacing Serial/parallel ports, USB, I2C, PCMCIA, IDE Communication Serial, Ethernet, Low bandwidth radio, IrDA, 802.11b based devices User Interface LCD, Keyboard, Touch sensors, Sound, Digital pads, Webcams Sensors A variety of sensors using fire, temperature, pressure, water level, seismic, sound, vision
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.