Efficient execution optimization method for embedded operating system based on MIPS instruction set

By adopting intelligent analysis and dynamic scheduling strategies in embedded operating systems, improving instruction parallelism and branch prediction capabilities, and optimizing context switching efficiency, the problem that existing operating systems fail to fully utilize the characteristics of MIPS instruction sets is solved, and more efficient system performance is achieved.

CN119759427APending Publication Date: 2025-04-04BEIJING INST OF COMP TECH & APPL
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411727729.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-28
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

Existing embedded operating systems fail to fully utilize the parallel capabilities of the hyperscalar architecture when processing MIPS instruction sets, resulting in system performance not being optimal.

Method used

Through intelligent analysis and dynamic scheduling strategies, improve instruction parallelism; enhance branch prediction capabilities, dynamic adjustment through intelligent scheduling strategies, cache consistency optimization and affinity strategies; optimize context switching efficiency, judge register usage and delay recovery of registers.

Benefits of technology

Enhanced instruction parallelism, improve branch prediction accuracy, reduce overhead during task switching, and ensure smoother computing and more efficient management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119759427A_ABST
    Figure CN119759427A_ABST
Patent Text Reader

Abstract

The invention relates to an efficient execution optimization method for an embedded operating system based on an MIPS instruction set, and belongs to the field of computer operating systems. The method comprises the following measures: improving the parallelism of instructions: maximizing the parallel execution of the instructions through the intelligent analysis and dynamic scheduling strategy of an operating system; enhancing branch prediction capability: based on process and thread affinity, adding an intelligent scheduling strategy, cache consistency optimization and affinity strategy dynamic adjustment; the context switching efficiency is optimized; and through an improved context switching mechanism, the overhead during task switching of the operating system is reduced. According to the method, the instruction parallelism is enhanced, so that the processor can more efficiently execute a plurality of instructions; the branch prediction accuracy is improved, and the performance loss caused by wrong prediction is reduced; by improving the context switching efficiency, the overhead during task switching is reduced. These measures collectively ensure smoother computing and more efficient management.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the field of computer operating systems, and in particular relates to a high-efficiency execution optimization method for an embedded operating system based on a MIPS instruction set. Background Art

[0002] With the rapid development of information technology and the widespread application of embedded systems, the requirements for operating system performance and energy efficiency are increasing. The MIPS instruction set is widely used in embedded devices due to its simplicity and efficiency. However, when processing the MIPS instruction set, existing embedded operating systems fail to fully utilize the characteristics of the instruction set, especially the parallel capability of the superscalar architecture, resulting in suboptimal system performance.

[0003] Traditional embedded operating systems usually face many challenges in terms of performance.

[0004] The most significant problem is the lack of instruction parallelism. The superscalar architecture can execute multiple instructions in one clock cycle. By adding multiple execution units, the processor can issue and execute multiple instructions at the same time. However, many embedded operating systems lack in-depth analysis of the dependencies between instructions, resulting in the failure to fully utilize the superscalar architecture and parallel execution capabilities of the MIPS instruction set, and the inability to effectively utilize processor resources.

[0005] Branch prediction is also a key technology to improve execution efficiency. The processor often encounters branch instructions during execution. These instructions will determine whether to jump to another section of code based on conditions. In order to improve execution efficiency, the processor will predict the branch target in advance, but when the branch prediction fails, it will increase pipeline conflicts and waiting cycles, hindering the parallel execution of instructions.

[0006] These factors combine to cause frequent context switching, which makes the system perform poorly in a multitasking environment and significantly increases the switching overhead. When many operating systems handle context switching, they save and restore all registers indiscriminately, even if only a small number of registers are used in some tasks, which undoubtedly increases the time overhead of switching. Summary of the invention

[0007] 1. Technical issues to be resolved

[0008] The technical problem to be solved by the present invention is how to provide an efficient execution optimization method for an embedded operating system based on the MIPS instruction set, so as to solve the problem that the existing embedded operating system fails to fully utilize the characteristics of the MIPS instruction set when processing the MIPS instruction set, especially fails to fully utilize the parallel capability of the superscalar architecture, resulting in the system performance not reaching the optimal level.

[0009] (II) Technical solution

[0010] In order to solve the above technical problems, the present invention proposes an embedded operating system efficient execution optimization method based on the MIPS instruction set, the method comprising the following measures:

[0011] S1. Improve instruction parallelism: Maximize the parallel execution of instructions through intelligent analysis and dynamic scheduling strategies of the operating system, including: instruction parallelism analysis, dynamic scheduling, and performance and resource management;

[0012] S2. Enhanced branch prediction capability: Based on process and thread affinity, intelligent scheduling strategies, cache consistency optimization, and dynamic adjustment of affinity strategies are added to enhance the accuracy of branch prediction and reduce the impact of misprediction on parallel execution and system performance.

[0013] S3. Optimize context switching efficiency: Reduce the overhead of operating system task switching through an improved context switching mechanism, including: register usage judgment and delayed recovery of registers.

[0014] (III) Beneficial effects

[0015] The present invention proposes an embedded operating system efficient execution optimization method based on the MIPS instruction set. Compared with the prior art, the present invention has the following advantages: it enhances instruction parallelism, enabling the processor to execute multiple instructions more efficiently; it improves the accuracy of branch prediction, reducing the performance loss caused by misprediction; and at the same time, by improving the context switching efficiency, it reduces the overhead during task switching. These measures together ensure smoother calculations and more efficient management. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] Figure 1 It is a diagram of the composition of the instruction parallel optimization module of the present invention;

[0017] Figure 2 A flowchart of thread affinity setting and CPU allocation in branch prediction optimization of the present invention;

[0018] Figure 3 This is a context switching flow chart of the present invention. DETAILED DESCRIPTION

[0019] In order to make the purpose, content and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the drawings and examples.

[0020] The invention belongs to the field of computer operating systems, relates to embedded operating systems and operating system optimization, and in particular to a high-efficiency execution optimization method for embedded operating systems based on a MIPS instruction set.

[0021] In view of the shortcomings of existing operating system optimization solutions, the purpose of the present invention is to provide an efficient execution method of an embedded operating system based on the MIPS instruction set, which specifically includes the following three points.

[0022] S1. Improve instruction parallelism: Through the intelligent analysis and dynamic scheduling strategy of the operating system, maximize the parallel execution of instructions, improve resource utilization, and thus speed up the overall execution speed;

[0023] S2. Enhanced branch prediction capability: Based on process and thread affinity, intelligent scheduling strategies, cache consistency optimization, and dynamic adjustment of affinity strategies are added to enhance the accuracy of branch prediction and reduce the impact of incorrect predictions on parallel execution and system performance.

[0024] S3. Optimize context switching efficiency: Through an improved context switching mechanism, the overhead of operating system task switching is reduced, and the system's response speed and processing power in a multi-tasking environment are improved.

[0025] The present invention provides an embedded operating system efficient execution optimization method based on the MIPS instruction set, comprising the following optimization measures:

[0026] S1. Instruction parallel optimization

[0027] S11, instruction parallelism analysis

[0028] Instruction parallelism analysis includes static analysis and dynamic analysis, which are used to identify instructions that can be executed in parallel.

[0029] Static analysis analyzes program code during the compilation phase, and identifies instructions that can be executed in parallel through data flow analysis and control flow analysis; dynamic analysis is performed at runtime, and identifies instructions that can be executed in parallel by detecting actual execution situations.

[0030] S12. Dynamic Scheduling

[0031] The operating system analyzes the instructions that can be issued in parallel during the emission phase, and dynamically allocates independent instructions to different execution units based on the idle status of the execution units, thereby maximizing resource utilization and reducing execution delays, ensuring that as many instructions as possible are issued in each clock cycle, and improving the instruction parallelism rate.

[0032] S13. Performance and Resource Management

[0033] Task division: In the MIPS architecture, a task can be divided into multiple subtasks. Selecting independent subtasks can be executed in parallel on different cores.

[0034] Core status monitoring: Regularly collects the load information of each core (CPU usage, number of context switches, etc.), combines this information with the MIPS instruction execution queue, and evaluates the instruction parallel processing capability of each core.

[0035] Load balancing strategy: Combined with the instruction parallelism of MIPS, when a core exceeds the threshold, some tasks are migrated to new cores with lighter loads based on the parallelism analysis results, providing a concurrent execution environment through task switching and multi-threading.

[0036] S2. Branch prediction optimization

[0037] An important reason for branch prediction failure is the instability of the historical behavior of branches, which is particularly evident when spanning multi-core CPU cores or processing multiple processes and threads. In a multi-core processor and multi-threaded environment, the execution state of the processor and the usage of the cache are closely related to the scheduling strategy of the operating system. Therefore, the present invention proposes the following solution to improve the accuracy of branch prediction based on process and thread affinity.

[0038] S21. Intelligent scheduling strategy

[0039] The operating system analyzes the behavior of instructions and identifies code areas that may generate branch instruction hot spots. For frequently executed branch paths, the operating system prioritizes scheduling these threads to processor cores with better cache locality. In multi-threaded programs, the operating system tries to assign multiple threads executing the same hot path to the same core to avoid prediction failures caused by thread migration, while also making more efficient use of resources.

[0040] S22, cache consistency optimization

[0041] By maintaining the affinity of processes and threads, the operating system ensures that the same process or thread is executed on the same core, enhancing the effectiveness of the cache. In this way, the historical data of branch instructions can be cached more effectively, reducing prediction failures caused by cache replacement, thereby improving the accuracy of branch prediction.

[0042] S23. Dynamic adjustment of affinity strategy

[0043] During program execution, the operating system dynamically adjusts thread affinity to adapt to changes in program behavior. When it is found that the execution path of a thread shows good branch prediction accuracy on a certain core, the operating system can pin the thread to the core, thereby further improving the overall performance of the system.

[0044] S3, context switching optimization

[0045] The MIPS architecture has 32 general registers. Traditional operating systems will save and restore all registers during context switching. This part of the operation involves writing data into the memory and reading data from the memory, which requires data transmission between the CPU and other components, resulting in a lot of overhead. The optimization strategy described in the present invention is that the operating system selectively restores only the currently required registers, and the restoration of temporarily unused registers can be delayed. This can effectively reduce the number of memory accesses, reduce the time overhead of context switching, and reduce the overhead of the operating system when switching between different threads, thereby improving system performance.

[0046] S31, register usage judgment

[0047] When switching contexts, the operating system first determines the usage of registers. Based on the context of task execution, the operating system determines which registers are needed by the current task and which registers are not used in the task.

[0048] S32, delayed recovery register

[0049] When restoring registers during context switching, the operating system first restores the most important registers during thread switching, including the program counter, stack pointer, etc. Then, based on the results of register usage analysis, it restores the registers required for the current task. If the current thread does not need certain registers, the restore operation is delayed until the register is actually needed.

[0050] The key points of the present invention are:

[0051] The key point of the present invention is that it not only takes into account the deficiencies of traditional operating systems in instruction parallelism and branch prediction, but also introduces a more complete context switching strategy to reduce switching overhead and improve resource utilization. Specifically, the core elements of the present invention include:

[0052] 1. Improve instruction parallelism: By dynamically analyzing the behavior of the program, the operating system can more intelligently schedule the execution order of instructions to maximize the parallel execution capability.

[0053] 2. Improve branch prediction mechanism: By optimizing the affinity of processes and threads at the operating system level, cache invalidation and branch prediction failure are reduced, helping to improve the accuracy of CPU branch prediction.

[0054] 3. Optimize the context switching strategy: manage whether registers are used or not, delay the restoration of unused registers, reduce the overhead during context switching, and thus enhance multi-tasking capabilities.

[0055] Effects of the present invention:

[0056] The present invention proposes an embedded operating system efficient execution optimization method based on the MIPS instruction set. Compared with the prior art, the present invention has the following advantages: it enhances instruction parallelism, enabling the processor to execute multiple instructions more efficiently; it improves the accuracy of branch prediction, reducing the performance loss caused by misprediction; and at the same time, by improving the context switching efficiency, it reduces the overhead during task switching. These measures together ensure smoother computing and more efficient management.

[0057] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A method for optimizing the efficient execution of an embedded operating system based on the MIPS instruction set, characterized in that: The approach includes the following measures: S1. Improve instruction parallelism: Maximize the parallel execution of instructions through intelligent analysis and dynamic scheduling strategies of the operating system, including: instruction parallelism analysis, dynamic scheduling, and performance and resource management; S2. Enhanced branch prediction capability: Based on process and thread affinity, intelligent scheduling strategies, cache consistency optimization, and dynamic adjustment of affinity strategies are added to enhance the accuracy of branch prediction and reduce the impact of misprediction on parallel execution and system performance. S3. Optimize context switching efficiency: Reduce the overhead of operating system task switching through an improved context switching mechanism, including: register usage judgment and delayed recovery of registers.

2. The method for optimizing the efficient execution of an embedded operating system based on the MIPS instruction set according to claim 1, characterized in that: In S1, instruction parallelism analysis includes: static analysis and dynamic analysis, through which instructions that can be executed in parallel are identified. Static analysis analyzes program code during the compilation phase, and identifies instructions that can be executed in parallel through data flow analysis and control flow analysis. Dynamic analysis is performed during runtime, and identifies instructions that can be executed in parallel by detecting the actual execution situation.

3. The method for optimizing the efficient execution of an embedded operating system based on the MIPS instruction set according to claim 1, characterized in that: In S1, dynamic scheduling includes: the operating system analyzes the instructions that can be issued in parallel during the issuance phase, and dynamically allocates the independent instructions to different execution units according to the idle status of the execution units.

4. The method for optimizing the efficient execution of an embedded operating system based on the MIPS instruction set according to claim 1, characterized in that: In S1, performance and resource management includes: task division, core status monitoring and load balancing strategy; Task division: In the MIPS architecture, tasks are divided into multiple subtasks, and independent subtasks can be executed in parallel on different cores; Core status monitoring: Regularly collects the load information of each core, combines this information with the MIPS instruction execution queue, and evaluates the instruction parallel processing capability of each core; Load balancing strategy: Combined with the instruction parallelism of MIPS, when a core exceeds the threshold, some tasks are migrated to new cores with lighter loads based on the parallelism analysis results, providing a concurrent execution environment through task switching and multi-threading.

5. The method for optimizing the efficient execution of an embedded operating system based on the MIPS instruction set according to claim 1, characterized in that: In S2, the intelligent scheduling strategy includes: the operating system analyzes the behavior of instructions and identifies the code areas that may generate branch instruction hotspots. For frequently executed branch paths, the operating system prioritizes scheduling these threads to processor cores with better cache locality; in multi-threaded programs, the operating system tries to assign multiple threads executing the same hotspot path to the same core to avoid prediction failures caused by thread migration, while also being able to use resources more efficiently.

6. The method for optimizing the efficient execution of an embedded operating system based on the MIPS instruction set according to claim 1, characterized in that: In S2, cache consistency optimization includes: by maintaining the affinity of processes and threads, the operating system ensures that the same process or thread is executed on the same core, thereby enhancing the effectiveness of the cache.

7. The method for optimizing the efficient execution of an embedded operating system based on the MIPS instruction set according to claim 1, characterized in that: In S2, the dynamic adjustment of affinity strategy includes: during the execution of the program, the operating system dynamically adjusts the affinity of the thread to adapt to the changes in the program behavior. When it is found that the execution path of a thread shows better branch prediction accuracy on a certain core, the operating system fixes the thread on the core, thereby further improving the overall performance of the system.

8. The method for optimizing the efficient execution of an embedded operating system based on the MIPS instruction set according to claim 1, characterized in that: In S3, the operating system selectively restores only the currently required registers, and the restoration of temporarily unused registers may be delayed.

9. The method for optimizing the efficient execution of an embedded operating system based on the MIPS instruction set as claimed in claim 8, characterized in that: In S3, the determination of register usage includes: when context switching, the operating system first determines the register usage, and the operating system determines which registers are required by the current task and which registers are not used in the task according to the context of task execution.

10. The method for optimizing the efficient execution of an embedded operating system based on the MIPS instruction set according to claim 8, characterized in that: In S3, the delayed restoration of registers includes: when restoring registers during context switching, the operating system first restores the most important registers during thread switching, including the program counter and the stack pointer; secondly, based on the results of register usage analysis, the registers required for the current task are restored; if the current thread does not need certain registers, the restoration operation is delayed until the state of the register is restored when it is really needed.

Citation Information

Cited By

  • Method and system for dynamically optimizing CPU scheduling based on thread affinity

    CN121255468A