Real-Time Operating System (RTOS) PDF
Document Details
Uploaded by DiversifiedKunzite8277
Tags
Summary
This document provides an overview of Real-Time Operating Systems (RTOS). It details the requirements for a real-time system, defines what an RTOS is, and explores the characteristics and applications of these systems, along with the different types of RTOSes. The document further discusses the working of RTOS in various scenarios.
Full Transcript
Top of Form **REAL-TIME OPERATING SYSTEM (RTOS)** **For a real-time system to be capable of real-time computing, it must satisfy two requirements:** **Timeliness: The ability to produce the expected result by a specific deadline.** **Time synchronization: The capability of agents to coordinate i...
Top of Form **REAL-TIME OPERATING SYSTEM (RTOS)** **For a real-time system to be capable of real-time computing, it must satisfy two requirements:** **Timeliness: The ability to produce the expected result by a specific deadline.** **Time synchronization: The capability of agents to coordinate independent clocks and operate together in unison.** **When evaluating real-time systems, companies can measure the value of any system in how predictable it is in completing events or tasks. Predictability can be further evaluated by examining the system's:** **Latency: Measurement of time between two events** **Compute jitter: Latency variation between iterations** **What is a real-time operating system (RTOS)?** Real-time operating system (RTOS) is an operating system intended to serve real time application that process data as it comes in, mostly without buffer delay. The full form of RTOS is Real time operating system. In a RTOS, Processing time requirement are calculated in tenths of seconds increments of time. It is time-bound system that can be defined as fixed time constraints. In this type of system, processing must be done inside the specified constraints. Otherwise, the system will fail. A real-time operating system (RTOS) is an OS that guarantees [real-time applications](https://www.techtarget.com/searchunifiedcommunications/definition/real-time-application-RTA) a certain capability within a specified deadline. RTOSes are designed for critical systems and for devices like [microcontrollers](https://internetofthingsagenda.techtarget.com/definition/microcontroller) that are timing-specific. RTOS processing time requirements are measured in milliseconds. Any delays in responding could have disastrous consequences. Real-time operating systems have similar functions as general-purpose OSes (GPOSes), like Linux, Microsoft Windows or macOS, but are designed so that a scheduler in the OS can meet specific deadlines for different tasks. RTOSes also commonly appear in embedded systems, which are a combination of hardware and software designed for a specific function and may also operate within a larger system. Often, embedded systems are used in real-time environments and use a real-time operating system to communicate with the hardware. RTOSes are designed to handle multiple processes at one time, ensuring that these processes respond to events within a predictable time limit. Processing in an RTOS occurs within defined time constraints and monitors the priority of tasks. An RTOS is also able to make changes to task priority. Systems that are event-driven often switch between tasks based on priority. Some real-time operating systems are created for special applications, while others are more general purpose. Usually, RTOSes provide the following functionality: - - - **APPLICATIONS OF RTOS:** RTOSs are included in the following devices: - - - - - **CHARACTERISTICS OF A REAL-TIME OPERATING SYSTEM** Real-time operating systems generally have the following characteristics: - - - - - - - It offers priority-based scheduling, which allows you to separate analytical processing from non-critical processing. - The Real time OS provides API functions that allow cleaner and smaller application code. - Abstracting timing dependencies and the task-based design results in fewer interdependencies between modules. - RTOS offers modular task-based development, which allows modular task-based testing. - The task-based API encourages modular development as a task, will typically have a clearly defined role. It allows designers/teams to work independently on their parts of the project. - An RTOS is event-driven with no time wastage on processing time for the event which is not occur. **HOW DOES A RTOS WORK?** RTOSes are subdivided into *soft* and *hard *real-time systems. A soft RTOS is designed to operate within a few hundred milliseconds, while a hard RTOS is designed to provide predictable response times within tens of milliseconds. Soft real-time systems typically have larger file sizes compared to hard RTOSes. Some executions act less predictably during peak load but are tolerated, as computations are rolled back to previously established checkpoints if an error occurs. Soft RTOSes are normally used in systems where time-based executions are less important, such as in PCs, cameras and smartphones. Hard RTOSes typically have small or medium-sized data files. They act predictably during moments of peak loads, and computation is rolled back if an error occurs. Hard RTOSes are normally used in systems that require important time-based executions, such as in airplane sensors, autopilot systems or medical devices. In hard real-time OSes, if the calculation cannot be performed to make an object available at the designated time, the OS terminates with a failure. In a soft RTOS, the OS continues to function, but certain tasks may be unproductive if they fail to execute at a given time. RTOSs also act as a scheduler, in which tasks can be scheduled as ready to run, running or blocked. How a kernel works A kernel interacts with the rest of the operating system, including the application layer and the device layer, and with components such as the CPU and memory. They typically have a monolithic [kernel](https://www.techtarget.com/searchdatacenter/definition/kernel) and microkernel architecture. The OS kernel is the core of an OS, which provides basic services for all other parts of the OS. Kernels are the main layer between the OS and hardware. Monolithic RTOS kernel and operation processes share one space. This architecture operates quickly when compared to microkernel configurations and typically provides better performance. Even though monolithic RTOSes run faster, they are harder to perform updates on, and a programming error in the file system, protocol [stack](https://www.techtarget.com/whatis/definition/stack) or driver can cause system crashes. The microkernel architecture houses the kernel and operations in separate locations. This architecture is slower than monolithic RTOS, as any action must return to the kernel before it can move to the component it references. The microkernel also lacks file systems. **COMPONENTS OF RTOSs: Here, are important Component of RTOS** **The Scheduler: This component of RTOS tells that in which order, the tasks can be executed which is generally based on the priority.** **Symmetric Multiprocessing (SMP): It is a number of multiple different tasks that can be handled by the RTOS so that parallel processing can be done.** **Function Library: It is an important element of RTOS that acts as an interface that helps you to connect kernel and application code. This application allows you to send the requests to the Kernel using a function library so that the application can give the desired results.** **Memory Management: this element is needed in the system to allocate memory to every program, which is the most important element of the RTOS.** **Fast dispatch latency: It is an interval between the termination of the task that can be identified by the OS and the actual time taken by the thread, which is in the ready queue, that has started processing.** **User-defined data objects and classes: RTOS system makes use of programming languages like C or C++, which should be organized according to their operation.** **RTOS vs. GPOS** General-purpose OSes, like Windows or [Unix](https://www.techtarget.com/searchdatacenter/definition/Unix), can handle multiple tasks concurrently but are not ideal for important, time-sensitive applications due to [latency](https://www.techtarget.com/whatis/definition/latency) and synchronization issues. GPOSes can also operate without time constraints, so tasks may sometimes fail or take longer to execute. In other words, they provide a potential nondeterministic, soft real-time response to tasks. RTOSes typically provide a deterministic, hard real-time response with the goal of providing a quick reaction to events. While GPOSes are good for general consumer use, RTOSes are designed for instances where a system needs to respond to an event or task within a short, designated time frame. RTOSes need to be quick and accurate for the typically embedded systems they reside in. **Popular RTOS software and factors for choosing an OS** Popular open source and commercial RTOS software products include the following: - - - - **Features of RTOS** Here are important features of RTOS: - Occupy very less memory - Consume fewer resources - Response times are highly predictable - Unpredictable environment - The Kernel saves the state of the interrupted task ad then determines which task it should run next. - The Kernel restores the state of the task and passes control of the CPU for that task. **FACTORS FOR SELECTING A RTOS** Here, are essential factors that you need to consider for selecting RTOS: - **Performance**: Performance is the most important factor required to be considered while selecting for a RTOS. - **Middleware**: if there is no middleware support in Real time operating system, then the issue of time-taken integration of processes occurs. - **Error-free**: RTOS systems are error-free. Therefore, there is no chance of getting an error while performing the task. - **Embedded system usage**: Programs of RTOS are of small size. So we widely use RTOS for embedded systems. - **Maximum Consumption**: we can achieve maximum Consumption with the help of RTOS. - **Task shifting**: Shifting time of the tasks is very less. - **Unique features**: A good RTS should be capable, and it has some extra features like how it operates to execute a command, efficient protection of the memory of the system, etc. - **24/7 performance**: RTOS is ideal for those applications which require to run 24/7. **Difference between in GPOS and RTOS** Here are important differences between GPOS and RTOS: **General-Purpose Operating System (GPOS)** **Real-Time Operating System (RTOS)** -------------------------------------------------------------- ---------------------------------------------------------------------------------- It used for desktop PC and laptop. It is only applied to the embedded application. Process-based Scheduling. Time-based scheduling used like round-robin scheduling. Interrupt latency is not considered as important as in RTOS. Interrupt lag is minimal, which is measured in a few microseconds. No priority inversion mechanism is present in the system. The priority inversion mechanism is current. So it can not modify by the system. Kernel's operation may or may not be preempted. Kernel's operation can be preempted. Priority inversion remain unnoticed No predictability guarantees **APPLICATIONS OF REAL TIME OPERATING SYSTEM** Real-time systems are used in: - Airlines reservation system. - Air traffic control system. - Systems that provide immediate updating. - Used in any system that provides up to date and minute information on stock prices. - Defense application systems like RADAR. - Networked Multimedia Systems - Command Control Systems - Internet Telephony - Anti-lock Brake Systems - Heart Pacemaker **DISADVANTAGES OF RTOS** Here, are drawbacks/cons of using RTOS system: - RTOS system can run minimal tasks together, and it concentrates only on those applications which contain an error so that it can avoid them. - RTOS is the system that concentrates on a few tasks. Therefore, it is really hard for these systems to do multi-tasking. - Specific drivers are required for the RTOS so that it can offer fast response time to interrupt signals, which helps to maintain its speed. - Plenty of resources are used by RTOS, which makes this system expensive. - The tasks which have a low priority need to wait for a long time as the RTOS maintains the accuracy of the program, which are under execution. - Minimum switching of tasks is done in Real time operating systems. - It uses complex algorithms which is difficult to understand. - RTOS uses lot of resources, which sometimes not suitable for the system. **SUMMARY** - RTOS is an operating system intended to serve real time application that process data as it comes in, mostly without buffer delay. - It offers priority-based scheduling, which allows you to separate analytical processing from non-critical processing. - Important components of RTOS system are: 1)The Scheduler, 2) Symmetric Multiprocessing, 3) Function Library, 4) Memory Management, 5) Fast dispatch latency, and 6) User-defined data objects and classes - Three types of RTOS are 1) Hard time 2) Soft time ,and 3) Firm time - RTOS system occupy very less memory and consume fewer resources - Performance is the most important factor required to be considered while selecting for a RTOS. - General-Purpose Operating System (GPOS) is used for desktop PC and laptop while Real-Time Operating System (RTOS) only applied to the embedded application. - Real-time systems are used in Airlines reservation system, Air traffic control system,etc. - The biggest drawback of RTOS is that the system only concentrates on a few tasks. PRIORITY SCHEDULING ------------------- **Priority Scheduling** is a method of scheduling processes that is based on priority. In this algorithm, the scheduler selects the tasks to work as per the priority. The processes with higher priority should be carried out first, whereas jobs with equal priorities are carried out on a round-robin or FCFS basis. Priority depends upon memory requirements, time requirements, etc. ***Types of Priority Scheduling*** Priority scheduling divided into two main types: ### ***Preemptive Scheduling*** In Preemptive Scheduling, the tasks are mostly assigned with their priorities. Sometimes it is important to run a task with a higher priority before another lower priority task, even if the lower priority task is still running. The lower priority task holds for some time and resumes when the higher priority task finishes its execution. ### ***Non-Preemptive Scheduling*** In this type of scheduling method, the CPU has been allocated to a specific process. The process that keeps the CPU busy, will release the CPU either by switching context or terminating. It is the only method that can be used for various hardware platforms. That's because it doesn't need special hardware (for example, a timer) like preemptive scheduling. **CHARACTERISTICS OF PRIORITY SCHEDULING** - A CPU algorithm that schedules processes based on priority. - It used in Operating systems for performing batch processes. - If two jobs having the same priority are READY, it works on a ***[FIRST COME, FIRST SERVED](https://www.guru99.com/fcfs-scheduling.html) basis.*** - In priority scheduling, a number is assigned to each process that indicates its priority level. - Lower the number, higher is the priority. - In this type of scheduling algorithm, if a newer process arrives, that is having a higher priority than the currently running process, then the currently running process is preempted. **Example of Priority Scheduling** Consider following five processes P1 to P5. Each process has its unique priority, burst time, and arrival time. **Process** **Priority** **Burst time** **Arrival time** ------------- -------------- ---------------- ------------------ P1 1 4 0 P2 2 3 0 P3 1 7 6 P4 3 4 11 P5 2 2 12 **Step 0)** At time=0, Process P1 and P2 arrive. P1 has higher priority than P2. The execution begins with process P1, which has burst time 4. ![Priority Scheduling](media/image2.png) **Step 1)** At time=1, no new process arrive. Execution continues with P1. Priority Scheduling **Step 2) **At time 2, no new process arrives, so you can continue with P1. P2 is in the waiting queue. ![Priority Scheduling](media/image4.png) **Step 3)** At time 3, no new process arrives so you can continue with P1. P2 process still in the waiting queue. Priority Scheduling **Step 4)** At time 4, P1 has finished its execution. P2 starts execution. ![Priority Scheduling](media/image6.png) **Step 5) **At time= 5, no new process arrives, so we continue with P2. Priority Scheduling **Step 6) **At time=6, P3 arrives. P3 is at higher priority (1) compared to P2 having priority (2). P2 is preempted, and P3 begins its execution. **Process** **Priority** **Burst time** **Arrival time** ------------- -------------- -------------------- ------------------ P1 1 4 0 P2 2 1 out of 3 pending 0 P3 1 7 6 P4 3 4 11 P5 2 2 12 ![](media/image8.png) **Step 7) At** time 7, no-new process arrives, so we continue with P3. P2 is in the waiting queue. **Step 8) **At time= 8, no new process arrives, so we can continue with P3. ![](media/image10.png) **Step 9)** At time= 9, no new process comes so we can continue with P3. **Step 10) **At time interval 10, no new process comes, so we continue with P3 ![](media/image12.png) **Step 11)** At time=11, P4 arrives with priority 4. P3 has higher priority, so it continues its execution. **Process** **Priority** **Burst time** **Arrival time** ------------- -------------- -------------------- ------------------ P1 1 4 0 P2 2 1 out of 3 pending 0 P3 1 2 out of 7 pending 6 P4 3 4 11 P5 2 2 12 **Step 12) **At time=12, P5 arrives. P3 has higher priority, so it continues execution. ![](media/image14.png) **Step 13) **At time=13, P3 completes execution. We have** **P2,P4,P5 in ready queue. P2 and P5 have equal priority. Arrival time of P2 is before P5. So P2 starts execution. **Process** **Priority** **Burst time** **Arrival time** ------------- -------------- -------------------- ------------------ P1 1 4 0 P2 2 1 out of 3 pending 0 P3 1 7 6 P4 3 4 11 P5 2 2 12 **Step 14) **At time =14, the P2 process has finished its execution. P4 and P5 are in the waiting state. P5 has the highest priority and starts execution. ![](media/image16.png) **Step 15) **At time =15, P5 continues execution. **Step 16)** At time= 16, P5 is finished with its execution. P4 is the only process left. It starts execution. ![](media/image18.png) **Step 17)** At time =20, P5 has completed execution and no process is left. **Step 18)** Let's calculate the average waiting time for the above example. Waiting Time = start time -- arrival time + wait time for next burst P1 = o - o = o P2 =4 - o + 7 =11 P3= 6-6=0 P4= 16-11=5 Average Waiting time = (0+11+0+5+2)/5 = 18/5= 3.6 **ADVANTAGES OF PRIORITY SCHEDULING** Here, are benefits/pros of using priority scheduling method: - Easy to use scheduling method - Processes are executed on the basis of priority so high priority does not need to wait for long which saves time - This method provides a good mechanism where the relative important of each process may be precisely defined. - Suitable for applications with fluctuating time and resource requirements. **DISADVANTAGES OF PRIORITY SCHEDULING** Here, are cons/drawbacks of priority scheduling - If the system eventually crashes, all low priority processes get lost. - If high priority processes take lots of CPU time, then the lower priority processes may starve and will be postponed for an indefinite time. - This scheduling algorithm may leave some low priority processes waiting indefinitely. - A process will be blocked when it is ready to run but has to wait for the CPU because some other process is running currently. - If a new higher priority process keeps on coming in the ready queue, then the process which is in the waiting state may need to wait for a long duration of time.