Overview of real time operating system
Real time operating system (RTOS) is an operating system that can accept and process external events or data quickly enough when they are generated. The results of processing can control the production process or respond to the processing system quickly within the specified time, schedule all available resources to complete real-time tasks, and control all real-time tasks to run in harmony. Its main characteristics are timely response and high reliability.
Real time operating system is a preemptive operating system. If your process has high priority, it will be the first to be executed until the end of execution. The intermediate time can be calculated by CPU frequency.
In fact, it requires you to make a request to him, and he must give you the result within a certain time limit, instead of procrastinating because the system is busy or scheduling algorithm. That is, as long as a specified time or a high priority time occurs, no matter what operation, it must be interrupted immediately, even the kernel.
Windows kernel is not preemptive, so it is not a real-time operating system. Linux is soft real-time, and there are still a lot of non preemptive areas in the kernel. Hard real-time is the most demanding, while soft real-time is the least demanding
Overview of non real time operating system
The common operating systems Windows and Linux are both called time-sharing operating systems. They generally use fair scheduling algorithm. When there are more threads / processes, they have to share CPU time. There is a scheduling algorithm for “real-time process” in Linux. The scheduling algorithm is different from ordinary processes, but it only reduces the response time. The “real-time” priority in similar windows is only the highest priority First class, not real time
The real RTOS kernel is interruptible and preemptive. Linux is soft real-time. It adds some interruptible points in the kernel instead of allowing interruptions at any time.
Windows kernel is not preemptive, so it is not a real-time operating system. Linux is soft real-time, and there are still a lot of non preemptive areas in the kernel.
In this way, the design of the kernel is very demanding.
Difference between real time operating system and non real time operating system
The fundamental difference between real-time system and non real-time system is that real-time system has the ability to interact with external environment in time. That is to say, the real-time system to obtain information from the outside and the conclusion of the system to be completed in a very short limited time.
The operating system used in embedded real-time system is called embedded real-time operating system. It is not only an embedded operating system, but also a real-time operating system. As an embedded operating system, it has the common characteristics of embedded software, such as tailoring, low resource occupation and low power consumption. As a real-time operating system (the discussion on the characteristics of real-time operating system in this paper is limited to the strong real-time operating system, and the real-time operating system mentioned below also refers to the strong real-time operating system), it is similar to the general operating system (such as windows, UNIX and Li) Next, we will describe the main features of real-time operating system by comparing the differences between the two operating systems.
In our daily work and learning environment, we are most exposed to the general operating system. The general operating system is developed from the time-sharing operating system. Most of them support multi-user and multi process, and are responsible for managing many processes and allocating system resources for them. The basic design principle of time-sharing operating system is to shorten the average response time of the system as much as possible and improve the throughput of the system, so as to provide services for as many user requests as possible in unit time. From this we can see that the time-sharing operating system focuses on average performance, not individual performance. For example, for the whole system, it pays attention to the average response time of all tasks but not the response time of a single task. For a single task, it pays attention to the average response time of each execution but not the response time of a specific execution. Many strategies and techniques used in the general operating system reflect this design principle. For example, due to the use of page replacement algorithms such as LRU in the virtual memory management mechanism, most of the memory access requirements can be quickly completed through physical memory, and only a small part of the memory access requirements need to be completed through page adjustment. But on the whole, the average memory access time is shorter than that without virtual memory technology At the same time, the virtual space can be much larger than the physical memory capacity, so the virtual memory technology has been widely used in the general operating system. There are many similar examples, such as the indirect index query mechanism of file storage location in UNIX file system, and even the cache technology in hardware design and the dynamic branch prediction technology of CPU also reflect this design principle. It can be seen that the design principle of focusing on average performance, that is, statistical performance characteristics, has a far-reaching impact.
As for the real-time operating system, we have mentioned before, in addition to meeting the functional requirements of the application, it is more important to meet the real-time requirements put forward by the application. The real-time requirements of many real-time tasks that constitute an application are different. In addition, there may be some complex association and synchronization relations between real-time tasks, such as the execution sequence limit It is very difficult to guarantee the real-time performance of the system.
Therefore, the most important design principle of real-time operating system is to adopt various algorithms and strategies to ensure the predictability of system behavior. Predictability means that the resource allocation strategy of real-time operating system can reasonably allocate resources for multiple real-time tasks competing for resources (including CPU, memory, network bandwidth, etc.) at any time and under any circumstances, so that the real-time requirements of each real-time task can be met. Different from the general operating system, the real-time operating system does not focus on the average performance of the system, but requires each real-time task to meet the real-time requirements in the worst case, that is to say, the real-time operating system focuses on the individual performance, more accurately, the individual worst case performance. For example, if the real-time operating system adopts the standard virtual memory technology, the worst case of a real-time task execution is that every memory access needs page adjustment, so the accumulated running time of the task in the worst case is unpredictable, so the real-time performance of the task can not be guaranteed. It can be seen that virtual memory technology widely used in general operating system is not suitable for real-time operating system.