Is Linux a Real-Time Operating System or Time-Sharing Operating System?

Is Linux a Real-Time Operating System or Time-Sharing Operating System?

The systems we usually share, such as µC/OS, FreeRTOS, RT-Thread, ThreadX, are all real-time operating systems (RTOS). So some readers ask: What is a time-sharing operating system, and does Linux belong to real-time operating systems?

Real-Time Operating System (RTOS)

RTOS, the full English name is Real Time Operating System, which means real-time operating system.

1. Definition of Real-Time Operating SystemA real-time operating system (RTOS) is one that can accept and process external events or data at a sufficiently fast speed, and the results of that processing can control production processes or respond quickly within a specified time, coordinating the operation of all real-time tasks.
Thus, providing timely responses and high reliability are its main characteristics.
Real-time operating systems are divided into hard real-time and soft real-time. Hard real-time requires that operations must be completed within a specified time, which is guaranteed during the design of the operating system.
Soft real-time simply requires that operations be completed as quickly as possible according to task priority. The operating systems we typically use can be modified to become real-time operating systems.

Is Linux a Real-Time Operating System or Time-Sharing Operating System?

A real-time operating system is one that guarantees the completion of specific functions within a certain time limit. For example, an operating system can be designed to ensure that a robot on a production line can access a certain object. In a “hard” real-time operating system, if the calculation to make the object reachable cannot be completed within the allowed time, the operating system will terminate due to an error.
In a “soft” real-time operating system, the production line can still continue to operate, but the output of the product may slow down due to the object not arriving within the allowed time, causing a brief period of non-production for the robot. Some real-time operating systems are designed for specific applications, while others are general-purpose.
Some general-purpose operating systems call themselves real-time operating systems. However, to some extent, most general-purpose operating systems, such as Microsoft’s Windows NT or IBM’s OS/390, have characteristics of real-time systems. This means that even if an operating system is not strictly a real-time system, it can still solve some real-time application problems.
2. Characteristics of Real-Time Operating Systems1) Multi-tasking; 2) Thread priority; 3) Multiple interrupt levels.
Small embedded operating systems often require real-time operating systems, and the kernel must meet the requirements of real-time operating systems.
3. Related Concepts of Real-Time Operating Systems(1) Basic ConceptsCritical Section: Refers to code that cannot be interrupted during processing. Once this part of the code begins execution, interruptions are not allowed;
Resource: Any entity occupied by a task;
Shared Resource: A resource that can be used by more than one task;
Task: Also known as a thread, is a simple program. Each task is assigned a certain priority, has its own set of CPU registers, and its own stack space. Typically, each task is an infinite loop and can be in one of the following five states: sleeping, ready, running, suspended, and interrupted;
Task Switching: Saves the current state of the currently running task (all contents in the CPU registers) in the task’s own stack area, then loads the current state of the next task to be run from that task’s stack into the CPU registers and begins the next task’s execution;
Kernel: Responsible for managing various tasks, allocating CPU time for each task, and handling communication between tasks. It can be divided into non-preemptive kernels and preemptive kernels;
Scheduling: One of the main responsibilities of the kernel is to decide which task gets to run. Generally based on priority scheduling;
(2) About Priority IssuesTask Priority: Divided into static priority (priority cannot be changed) and dynamic priority (priority can be changed);
Priority Inversion: The priority inversion problem is the most common issue in real-time systems. The allocation of shared resources can lead to lower-priority tasks running first and higher-priority tasks running later. The solution is to use the “priority inheritance” algorithm to temporarily change task priorities to curb priority inversion.
(3) Mutual Exclusion Although shared data areas simplify information exchange between tasks, exclusivity must be ensured for each task when processing shared data. Common methods to satisfy mutual exclusion conditions include: disabling interrupts, using Test and Set (TAS) instructions, preventing task switching, and utilizing semaphores.
The significance of adopting a real-time operating system lies in its ability to promptly handle various unexpected events, i.e., processing various interrupts. Therefore, the most important and representative performance indicator for embedded real-time operating systems should be the interrupt response time. The interrupt response time is typically defined as:
Interrupt Response Time = Interrupt Latency + Time to Save CPU State + Execution Time of the ISR Entry Function of the Kernel.
Interrupt Latency = MAX (Maximum Time with Interrupts Disabled, Maximum Instruction Time) + Time of the First Instruction Executed in ISR.

Time-Sharing Operating System (TSOS)

TSOS, the full English name is Time-sharing Operating System, which means time-sharing operating system.

A time-sharing operating system is one that allows a computer to serve several, dozens, or even hundreds of users simultaneously. It connects the computer with many terminal users, and the time-sharing operating system switches the system’s processor time and memory space to each terminal user’s program in turn at certain time intervals.
Because the time intervals are very short, each user feels as if they exclusively own the computer. The characteristic of a time-sharing operating system is that it can effectively increase resource utilization. For example, the UNIX system adopts preemptive dynamic priority CPU scheduling, which strongly supports time-sharing.
The emergence of time-sharing systems is a new type of OS formed to meet user needs. It has a distinctly different performance difference from multi-program batch processing systems. User needs are specifically reflected in the following aspects: Human-machine interaction, sharing the host, and ease of user access.
1. Basic Idea of Time-Sharing SystemsTime Slice: Refers to dividing the computer’s system resources (especially CPU time) into time segments, each segment is called a time slice, and each user takes turns using a time slice.
Time-Sharing Technology: Divides the CPU’s running time into very short time slices and allocates the CPU to various online jobs in turn according to these time slices.
Time-Sharing Operating System: Is an online multi-user interactive operating system. It generally uses a time-slice round-robin method to serve multiple terminals with one computer. It ensures a sufficiently fast response time for each user and provides interactive session capabilities.
Design Goals: To respond to user requests in a timely manner and to improve the utilization of system resources as much as possible under feasible conditions.
It is suitable for scenarios requiring human-computer interaction such as office automation, education, and transaction processing.
2. Working MethodA mainframe connects several terminals; each terminal has a user; users interactively submit command requests to the system; the system accepts commands from each user; processes service requests using a time-slice round-robin method; and displays results to users on terminals interactively; users issue the next command based on the previous result.
Key issues in the implementation of time-sharing systems: Timely reception. Timely processing.
3. FeaturesInteractivity: Users engage in human-computer dialogue with the system. Multiplexing: Multiple users simultaneously use the same CPU at their respective terminals. Independence: Users can operate independently of each other without interference or confusion. Timeliness: Users can receive timely responses from the system in a short time. Factors affecting response time: Number of terminals, size of time slices, volume of information exchanged, and speed of information exchange.

Differences

RTOS and TSOS each have their characteristics, RTOS is generally used for relatively low-speed MCUs, such as motion control, key input, and other systems that require real-time processing, typically requiring ms or even us level responses.
Time-sharing: The popular PCs and servers today all adopt this operating mode, dividing the CPU’s operation into several time slices to handle different computation requests.
Real-time: Generally used in microcontrollers, such as in controlling the up and down movements of elevators, where real-time processing of actions such as button presses is required.

Finally

Through the above analysis, it can be concluded that Linux is a time-sharing system, but it can be modified to become real-time, such as: ucLinux is a real-time system derived from Linux. As for their differences, we can refer to similar answers found on Baidu:
A time-sharing system is one that can simultaneously serve two or more accounts!
A real-time system is one that can immediately respond to instructions! Common Microsoft systems cannot do this! Moreover, they can crash! The operating systems in fighter jets are real-time systems; think about it: if the computer in a fighter jet reacts to the pilot’s previous command or crashes during a battle, who would dare to fly that plane?

Reference Source:

https://www.cnblogs.com/xiawen/p/3317302.html

Is Linux a Real-Time Operating System or Time-Sharing Operating System?

1. None)

2. Why are circuit diagrams always drawn poorly? These tips are essential to know.

3. How do embedded devices display IP locality?

4. RISC-V is aimed at MCU/MPU and RTOS but faces challenges…

5. A method for self-updating firmware in microcontrollers!

6. The XuanTie Cup RISC-V Application Innovation Competition is officially launched, and registration is now open!

Is Linux a Real-Time Operating System or Time-Sharing Operating System?

Disclaimer: This article is a network reprint, and the copyright belongs to the original author. If there are copyright issues, please contact us, and we will confirm the copyright and pay remuneration or delete the content based on the copyright certificate you provide.

Leave a Comment