An Overview of Real-Time Operating Systems (RTOS)

Real-Time Operating Systems (RTOS) are Operating Systems for systems operating in Real Time. These Operating Systems have functions dedicated to detecting and responding to tasks from the real world within their deadlines.  Real-Time  Operating Systems are systems that are subject to real time limitations and are expected to deliver services within strict time boundaries. The correctness of such systems depends not only on computational output, but also on the instant at which the system produces the output.

Real-Time Operating Systems (RTOS) can be generally categorized into soft and hard real time systems. When a deadline is missed in a hard real time system, i.e. a service is not provided at the instant at which it is expected, the result would be catastrophic. Hence, hard real time systems are generally safety or mission critical. Examples of Hard Real Time Systems are, Air Traffic Control Systems, Pace makers for heart patients and Car Engine Control Systems, etc. In a soft real time system, failure to meet a deadline or latency in meeting deadlines, only causes degradation of system performance and can continue functioning despite the failure.

Real-Time Operating Systems are Operating Systems designed to serve real time applications. Features of the Real-Time Operating Systems (RTOS) are designed and selected such that output and feedback is provided from the system in a timely fashion. These operating systems are designed to specifically meet real time needs and constraints and hence these systems are specific to the application in which they are used. Typical features in a Real-Time Operating System would include, multi-threading, preemptibility, scheduling, fault tolerance, etc.

Real-Time Operating Systems versus General Purpose Operating Systems

Systems that function in real time situations have different and more challenging requirements than other systems. An example would be an Air Traffic Control System, where the correctness of the system not only lies in the right output but timely output. An untimely response could cost human lives. This would be a case of hard real time system where delay in output could be catastrophic. The Operating System would need to manage with several external events and produce output in a timely manner. Real-Time Operating Systems (RTOS) is designed with features that would enable it to handle such tough real time situations.

We need to note that not all real time systems require an operating system. Examples would be microwave ovens and washing machines, where there is minimal user interaction and only a combination of a few tasks. The system could be hardwired as implementing an Operating System would be too expensive for a simple system.

Real-Time Operating Systems (RTOS), in comparison with a General Purpose Operating System (GPOS) is designed to enable effective sharing of resources with many processes and producing output quickly. In an RTOS, a scheduling algorithm is implemented for this purpose. A General Purpose operating system on the other hand uses the “fairness” policy whereby each task is given an equal amount of time and resources to every application and task. Hence, there is no differentiation between urgent tasks and other tasks. Moreover, the time at which output can be generated is not predictable in a GPOS. Hence, these qualities make GPOS unsuitable for real time conditions.

While GPOS is designed to optimize performance and thus reduce costs, RTOS is designed to give the fastest response to a triggered task depending on its criticality. RTOS tasks have deadline and hence are time bound, whereas GPOS tasks have no time bound. RTOS is designed to be more deterministic than GPOS through its schedulers.

Basic Features of the  Real-Time Operating Systems (RTOS)

Though Real-Time Operating Systems differ depending on the application for which it is designed, there are a few basic features expected. These features are discussed briefly below.

  1. Timeliness:  Timeliness is a crucial factor when designing RTOS especially for Hard Real Time systems which are safety or mission critical. In order to achieve timeliness, the RTOS has to be able to handle multiple tasks simultaneously. Multi threading needs to be used to achieve this. Multithreading is the efficient management of multiple threads where each thread is assigned a task. All threads share resources from a single core. A scheduler is designed to assign priorities to threads and ensure higher priority threads can preempt the lower priority threads to access the CPU when they need them.
  2. Determinism:  In order for the Real time operating system to function in a predictable manner, latencies in operation need to be predicted and delays need to be defined. The common latencies are as follows. Task switching latency is the time between saving the state of the current task and the start of the next task. Interrupt latency is the time taken for an interrupt to be executed. Interrupt dispatch latency is the time taken from the interrupt completion time to the starting time of the next task. The static scheduler predefines the duration taken for each task to execute so that the Real Time System has a more deterministic and controlled behavior.
  3. Data Integrity:  Resources are shared between threads and hence the same data may be modified by two or more strings at the same instance. To ensure data integrity, mutexes are used. A mutex allows exclusive access to the resource. A mutex can be in the locked state or the unlocked state. When a task is in progress with a resource, the mutex is in a locked state. When the task is done, it unlocks the mutex and only then any other task can modify that resource.

The  Real-Time Operating Systems (RTOS)  Kernel

The Kernel, like in other Operating Systems, is the most important part of the Real-Time Operating Systems (RTOS). It acts as an interface between the top level application layer, which can be accessed by users, and the hardware layer, consisting of the data processing hardware components.

The central duty of the kernel is to manage tasks. In an Real-Time Operating Systems (RTOS), a task is a basic unit of execution. Task management involves assigning these threads / tasks priority levels. A task that needs to be completed with a tighter deadline and has a larger impact on the output is normally given a higher priority. Apart from creating priority for threads, the kernel needs to manage priority inversion situations efficiently and ensure that the higher priority threads get resources as soon as they need them.

The next most important task of the kernel would be the inter task communication and synchronization. Given the multitude of events RTOS need to deal with, within a short span of time, this feature of the kernel is necessary to ensure that corrupted information is not passed between tasks. Examples of common mechanisms that are used for Inter task communication and synchronization would be semaphores, conditional variables, flags, and message queues.

The next most critical function of the kernel would be timers. They assist the schedulers in determining if a task has met or missed its schedule. Timers can also be used for watch dog functions and to quit a task that has timed out. Timers can be absolute, where they calculate time and date according to the calendar, or relative, where time is calculate by the number of ticks.

Memory management is an important task of the kernel. With many threads using the memory, the system will run out of memory if the threads that have completed do not return the memory back to the system. The memory in an RTOS is usually small in size and only used for user application, hence needs to be managed efficiently. In a few Real time operating systems, temporary memory divided into fixed sizes, is allocated to tasks. Once the tasks have executed, they must return the memory block back to the memory pool. Lower priority tasks are allocated smaller memory blocks while higher priority tasks are allocated larger memory blocks. When a lower priority task requires more memory, it has to wait till a memory block is returned to the pool before continuing execution.

Though the above functionalities are general, features of the kernel differ depending on the usage of the Real-Time Operating System. A few of the common categories of kernels would be, Small, proprietary kernels, real time extensions to kernels of general purpose operating systems, and component-based kernels.

  1. Small, proprietary kernels:  This category of kernels is used where the real time system has tight deadline to meet. These kernels have very few functionalities and very well defined tasks to handle. Hence, the response time of these kernels are predictable and suitable for use in hard real time systems. These kernels are highly customized and can be designed in-house or commercially available. A few of the special features of these kernels are the short context switching duration, limited features and hence lower overhead, shorter duration when the interrupts are disabled, priority based preemptive scheduling, etc. These features enable the Real-Time Operating Systems (RTOS) to respond quickly to events in a predictable manner.
  2. Real Time extensions:  Kernels belonging to this category are extensions to the kernels of existing commercial operating systems. An example would be Real Time Linux from the Linux operating systems. Real time features are included to the kernel of these operating systems. Compared to the small, proprietary kernels, these kernels have many more features and hence much slower. Given that the commercial kernels are popular, there are more comprehensive software development environments and many more developers in the market with the technical skill. Hence, time to design and market these products would be lesser. However, these kernels cannot be used for real time operating systems supporting hard real time environments.
  3. Component Based Kernel:  This category of kernels has microkernel architecture. The functionalities of the kernels are broken into components. There is a nucleus whose sole duty is to switch between components. Such a component based design allows flexibility in deciding the functionality of the kernel and can be tailor made to suit the Real-Time Operating Systems (RTOS) and the real time environment. This category of kernels is not suitable for hard real time systems as adding components to the system can increase overhead and delay.

Leave a Reply

Your email address will not be published. Required fields are marked *