Share this

Analysis and Research on Real-Time Performance of Embedded Linux Operating Systems

2026-04-06 07:22:32 · · #1
Abstract: This paper analyzes the shortcomings of embedded Linux in real-time applications and proposes methods to improve the real-time performance of the system from aspects such as soft interrupt simulation technology, preemptive kernel mechanism, and real-time scheduling strategy. A macro-level scheduling structure is also proposed to expand the application scope of real-time systems. I. Introduction Linux itself is a time-sharing operating system, aiming for good average response time and high throughput. Real-time systems, on the other hand, mainly consider the timely completion of tasks and minimizing the unpredictability of process execution. However, compared with commercial embedded operating systems, Linux follows the GPL and has advantages such as open source code, convenient customization, and support for a wide range of computer hardware. Therefore, embedded Linux has become a research hotspot in the field of embedded systems in recent years. This paper first analyzes the characteristics of real-time systems and the shortcomings of the Linux kernel in real-time applications. Then, it studies several aspects affecting the real-time performance of the operating system, proposes solutions, and finally summarizes the entire paper. II. Classification of Real-Time Systems The most important characteristic of real-time systems is real-time performance, meaning that the correctness of the system depends not only on the correctness of the logical results of the calculations but also on the timeliness of the output results. From this perspective, a real-time system is "a system that can complete system functions and respond to the external environment within a specified or determined time." According to the degree of real-time performance requirements, real-time systems can be divided into two categories: (1) Hard real-time systems: require strong determinism and have clear real-time constraints. Failure to complete the task before a certain time limit will result in catastrophic consequences. (2) Soft real-time systems: are also time-sensitive, but occasional failure to meet strict real-time requirements is also allowed. III. Deficiencies of Linux in Real-Time Although Linux conforms to the POSIX 1003.1b standard for real-time extensions, such as supporting SCHED_FIFO and SCHED_RR real-time scheduling policies, memory locking mechanism, real-time signals, etc., since its initial design goal was a general-purpose time-sharing operating system, as a real-time operating system, Linux still has the following defects: (1) The Linux kernel itself is non-preemptive. Linux has two modes: user mode and kernel mode. When a process runs in user mode, it can be preempted by a process with higher priority, but when it enters kernel mode, no matter how high the priority of other user mode processes is, they cannot preempt it. (2) Although Linux provides high priority to real-time processes, it does not add time limits. For example: the deadline for completion, how long it should take to complete, the execution cycle, etc. At the same time, a large number of other non-real-time processes may also block the real-time process, making it impossible to ensure the response time of the real-time process. (3) Coarse clock granularity. Clock management is the pulse of the operating system. The execution and termination of tasks are often directly or indirectly triggered by the clock. It is also an important basis for process scheduling. The periodic mode timer frequency of Linux is only 100Hz, which is far from meeting the requirements of real-time applications. IV. Analysis and research on improving the real-time performance of the kernel The embedded Linux kernel is studied from three aspects: interrupt software simulation, preemptive kernel architecture, and real-time task scheduling strategy. Corresponding methods to improve real-time performance are given. 1. Analysis and solutions for response time The response time of a task is defined as the interval between the occurrence of an event and the start of task response. The following factors usually affect the response time of a task. (1) Interrupt dispatch time (IDT): When an interrupt occurs, before the interrupt handler occupies the CPU, the operating system uses the time to save the contents of all registers and other information about the status of this task in the system. (2) Interrupt Service Time (IST): The time taken by an interrupt service routine to read information from hardware devices or collect information from the operating system. (3) Kernel Preemption Time (KPT): The time interval between the operating system's intention to preempt the current process and the actual occurrence of the preemption. (4) Schedule Delay (SD): The time taken by the scheduler to schedule another thread to run. (5) Contest Switching Time (CST): The sum of the time taken by the current thread to save registers and system state and the time taken by the thread to restore the contents of registers and system state. (6) Return from System Call (RST): The time taken by a thread in kernel mode to check some states before returning to user mode. Of these times, SD, CST, and RST are always fixed. If the Linux kernel is designed properly, IDT, IST, and KPT can be effectively reduced. In real-time application environments, it is entirely possible for several interrupts to occur simultaneously. At this point, the task response time will contain at most N(IDT+IST), where N is the number of interrupts. Interrupt software emulation is used to handle situations where multiple interrupts occur simultaneously. When a hardware interrupt occurs, the system simply reports its occurrence in the timetable and immediately returns CPU control to the operating system, completely skipping the interrupt vector table lookup and execution of the corresponding interrupt service routine. The system intercepts all interrupt signals before the Linux kernel and handles or suspends the interrupt according to the needs of the current real-time task using a software interrupt emulation mechanism (e.g., the 8259 interrupt controller in an IBM PC). This method reduces the task response time when multiple interrupts occur simultaneously, with the longest delay being N*IST', where N is the number of interrupts. The reason it's IST' instead of IST is because the software interrupt emulation method allows only simple operations to be performed within the IST time period. 2. Design of Preemptive Kernel Architecture To overcome the biggest obstacle to achieving hard real-time in Linux and make the Linux kernel a fully preemptible real-time kernel, a typical implementation is a dual-core architecture. A real-time kernel is used to run real-time tasks, and the Linux kernel runs non-real-time tasks. For example, in real-time data sampling and analysis, a real-time task is run using a real-time kernel to complete data acquisition, while another real-time task handles data analysis and control output. Simultaneously, an interface running on the Linux kernel is used to display the data. See Figure 1. [align=center][img=307,202]http://www.e-works.net.cn/images/127886737032031250.GIF[/img] Figure 1 Dual-kernel architecture[/align] A small real-time kernel is added between the Linux kernel and the hardware. This kernel manages interrupts, provides necessary functions such as low-level task creation, interrupt service routines, and queues communication between low-level tasks, ISRs, and Linux processes. The Linux kernel itself becomes the lowest-priority idle task. Applications with high real-time requirements are written as real-time tasks and run directly on the real-time kernel. The Linux kernel can be preempted by higher-priority real-time tasks. Modifications to the Linux kernel mainly focus on three aspects: (1) Adding control points in places in the Linux kernel that affect real-time performance, so that the kernel can be preempted at the control points, reducing kernel preemption latency; (2) Dividing long-running systems into several or even a dozen smaller blocks for separate execution, so that real-time tasks can interrupt non-real-time tasks at any time; (3) Adding some functions according to actual needs. With the deepening of embedded applications, especially in digital communication and networking, multi-core processors have been launched one after another. For example, Motorola's MPC8260 PowerQUICC integrates two CPUs - an embedded PowerPC core and a communication processing module (CPM); Infineon's TC10GP and enhanced TC1130 are both tri-core microprocessors. The emergence of these processors has greatly helped the real-time performance of Linux applications. 3. Research on Real-Time Scheduling Algorithms Commonly used real-time scheduling algorithms include: priority-driven scheduling (PD); time-driven scheduling (TD); and share-driven scheduling (SD).
    [*] Priority-based scheduling algorithms
The scheduler uses priority as the basis for seeking the next task to execute. It can be divided into the following two types: (1) Static priority scheduling algorithm: This algorithm statically assigns a priority to all processes in the system. The allocation of static priorities can be based on the attributes of the application, such as the task cycle, user priority, or other predetermined strategies. RM (RateMonotonic) is a typical static priority scheduling algorithm. It determines the scheduling priority based on the length of the task execution cycle. Tasks with shorter execution cycles have higher priorities. (2) Dynamic priority scheduling algorithm: This algorithm dynamically allocates the priority of tasks based on the resource requirements of the tasks. EDF (earliestdeadlinefirst) algorithm is a typical dynamic priority scheduling algorithm. This algorithm allocates priorities based on the deadline of each task in the ready queue. The task with the closest deadline has the highest priority.
    [*] Time-driven scheduling algorithms
This algorithm is essentially an offline, static scheduling method determined at design time. During the system design phase, with all processes in the system clearly defined, the start, switching, and end times of each task are pre-arranged and designed.
    [*] Proportional sharing-based scheduling algorithm
This is a real-time scheduling mode that is receiving increasing attention. Based on the GPS (general processors scheduling) algorithm, its basic idea is to schedule a group of tasks that need to be scheduled according to a certain weight (the proportion of CPU usage), so that the execution time is completely proportional to the weight. The proportional sharing scheduling algorithm can be implemented in two ways: (1) adjust the frequency of each ready process appearing at the head of the current scheduling queue and schedule the process at the head of the queue to execute; (2) schedule each process in the ready queue to run one by one, but adjust the running time slice allocated to each process according to the assigned weight. The proportional sharing algorithm includes several types such as round-robin, fair sharing, fair queue and lottery scheduling. Each scheduling strategy has its own advantages and disadvantages. Here we propose a macro scheduling structure. By designing and constructing a multi-attribute and multi-scheduler selection mechanism, the application of the three real-time scheduling strategies is supported. Compared with the scheme that only supports a single scheduling strategy, the scope of use of the system is expanded. The macro scheduling structure is shown in Figure 2. [align=center][img=462,389]http://www.e-works.net.cn/images/127886737201406250.GIF[/img] Figure 2 Macro-scheduling Structure[/align] We define four scheduling attributes for each real-time task: priority (limits the priority of this task compared to other related tasks), starttime (start time: the time when the task starts execution), finishtime (deadline time: the time when the task stops), and budget (preset value: the time the task is allowed to execute). Different attribute data corresponds to different scheduling strategies. The macro-scheduling structure is divided into two modules: the attribute allocation module and the scheduler selection module. The attribute allocation module assigns multiple attribute values ​​to each real-time task, and determines which attribute takes precedence based on one or two attribute values. In this way, the scheduler selection module can select different schedulers according to the priority level of the attributes. For example, if the priority attribute takes precedence, the scheduler becomes a pure PD scheduler; if the deadline takes precedence, then the scheduler works as an EDF scheduler. The experiment used a Pentium-||400 processor, 128MB of memory, and Linux 2.0.35 (with RED-Linux 0.5 patched). Taking the RM scheduling strategy as an example, the time consumed by each system request was measured. The data is summarized as follows: Under the macro scheduling structure, the time consumed by the attribute allocation module was mostly less than 40Ls, averaging about 35Ls; the average time consumed by the scheduler selection module was about 85Ls, for a total consumption of 118Ls, accounting for about 0.118% of CPU time. Under the single scheduling strategy, the average consumption time was about 25Ls, accounting for about 0.025% of CPU time. The latency of the macro scheduling structure is 5 times that of the traditional scheduling method. For most embedded systems, the flexibility and configurability of the kernel are more important than the latency of scheduling. The CPU availability of the macro structure and the single scheduling structure were 99.88% and 99.97% respectively, with minimal difference, which meets the real-time requirements of embedded systems. V. Conclusion and Outlook Although Linux is a time-sharing operating system, its powerful functionality, open-source nature, and high portability have made it an increasingly popular solution for embedded real-time operating systems. This paper presents methods to improve system real-time performance from three aspects: soft interrupt simulation technology, preemptive kernel, and real-time scheduling strategies. It also proposes a hybrid scheduling approach implemented using a macro-scheduling structure, expanding the application scope of real-time systems. The gradual improvement of Linux's real-time performance will greatly promote the widespread application of embedded Linux in industrial control, post-PC era information appliances, and other fields. The needs of these applications will further promote the emergence of numerous new control algorithms.
Read next

CATDOLL 166CM Jo TPE

Height: 166cm Weight: 37kg Shoulder Width: 36cm Bust/Waist/Hip: 76/63/85cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm Anal...

Articles 2026-02-22