A method for switching operating systems and a computing device

By providing an operating system switching method in the operating system, it allows instant switching between a general operating system and a real-time operating system, solving the real-time problem caused by insufficient computing power of network terminal equipment, and achieving more efficient real-time task processing.

CN114911597BActive Publication Date: 2025-07-01WUHAN SHENZHIDU TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210539644.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-17
Publication Date
2025-07-01
Estimated Expiration
2042-05-17

AI Technical Summary

Technical Problem

In the prior art, the computing power of network terminal devices is weak, resulting in that when the distance between the cloud center and the network terminal is far away, network transmission affects the real-time nature of the interaction and cannot effectively meet the needs of real-time tasks.

Method used

It provides a switching method for the operating system, allowing the operating system to switch instantly during operation. The general operating system and real-time operating system can be switched to the kernel mode and start the corresponding middleware service program and operating environment module to realize the switching of the system mode.

Benefits of technology

It realizes instant switching of the operating system during the operation of the operating system, meets the real-time requirements in different application scenarios, and improves the real-time processing capabilities of network terminal devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114911597B_ABST
    Figure CN114911597B_ABST
Patent Text Reader

Abstract

The present invention discloses a method for switching operating systems and a computing device. The method is executed during the operation of an operating system, and the operating system includes a kernel, a first operating system, and a second operating system. The method includes the steps of: during the operation of the first operating system, in response to a request to switch to the second operating system, switching the kernel from a first kernel mode corresponding to the first operating system to a second kernel mode corresponding to the second operating system; starting a second middleware service program corresponding to the second operating system; and starting a second middleware operating environment module corresponding to the second operating system so as to start the second operating system. According to the technical solution of the present invention, the operating system can be instantaneously switched according to a user's request during the operation of the operating system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of operating systems, and particularly to a method for switching operating systems and a computing device. Background Art

[0002] Cloud computing technology improves the utilization rate of hardware resources by separating and managing resources, greatly reduces the usage cost of IT information systems, and also improves the availability of the system. Currently, mainstream large-scale Internet services are all based on the infrastructure provided by cloud computing.

[0003] With the development of 5G technology, the Internet has developed into deeper and broader fields, and the topological distance between network terminals and network centers has been continuously extended, affecting the timeliness of network application responses. Network terminals are the dividing lines between the digital world and the physical world. Network terminal devices usually have requirements for real-time performance and need to complete computing tasks and feedback computing results within a limited time.

[0004] In the prior art, due to factors such as cost considerations, the computing power of network terminal devices is generally weak. It is necessary to use the computing resources of the cloud center to complete the core part of the computing tasks, and then the network terminal devices complete the remaining part of the computing tasks. However, due to the long distance between the cloud center and network terminals, the network transmission process affects the real-time performance of interactions. Therefore, it is necessary to introduce a new computing method between the cloud center and network terminals, that is, at the edge of the cloud, to solve the contradiction between computing resources and physical distance.

[0005] Among them, the multi-time characteristic hybrid operating system improves the general operating system from multiple levels of the kernel, middleware, and API, and constructs a hybrid operating system suitable for application in edge computing application scenarios. This hybrid operating system can run both computing tasks and real-time tasks. In terms of technical architecture, the multi-time characteristic hybrid operating system is a relatively large extension based on the general operating system. For the multi-time characteristic hybrid operating system, considering compatibility, debugging, and maintenance in the actual use process, a solution that can be instantaneously switched between the general operating system and the real-time operating system and is applicable to this hybrid operating system is required.

[0006] For the above-mentioned hybrid operating system, in order to be able to instantaneously switch the operating system during the operation of the operating system according to the user's requirements and enter the operating system specified by the user, a method for switching the operating system is required. Summary of the Invention

[0007] Therefore, the present invention provides a method for switching operating systems and a computing device to solve or at least alleviate the problems mentioned above.

[0008] According to an aspect of the present invention, there is provided a method for switching operating systems, which is executed during the operation of an operating system. The operating system includes a kernel, a first operating system, and a second operating system. The method includes the steps of: during the operation of the first operating system, in response to a request to switch to the second operating system, switching the kernel from a first kernel mode corresponding to the first operating system to a second kernel mode corresponding to the second operating system; starting a second middleware service program corresponding to the second operating system; starting a second middleware runtime environment module corresponding to the second operating system so as to start the second operating system.

[0009] Optionally, in the method for switching operating systems according to the present invention, the method further includes the step of: starting one or more application programs running based on the second operating system.

[0010] Optionally, in the method for switching operating systems according to the present invention, a running state control module is deployed above the operating system; the step of switching the kernel from a first kernel mode corresponding to the first operating system to a second kernel mode corresponding to the second operating system in response to a request to switch to the second operating system includes: the running state control module notifies the kernel to switch the first operating system to the second operating system in response to a request to switch to the second operating system; the kernel switches from a first kernel mode corresponding to the first operating system to a second kernel mode corresponding to the second operating system.

[0011] Optionally, in the method for switching operating systems according to the present invention, after switching the kernel from a first kernel mode corresponding to the first operating system to a second kernel mode corresponding to the second operating system, the method includes the steps of: the kernel notifies the running state control module that the switching operation is completed; the running state control module notifies the second middleware service program corresponding to the second operating system to start.

[0012] Optionally, in the method for switching operating systems according to the present invention, the step of starting a second middleware runtime environment module corresponding to the second operating system includes: starting a dependency library corresponding to the second middleware to replace a dependency library corresponding to the first middleware.

[0013] Optionally, in the method for switching operating systems according to the present invention, the first operating system and the second operating system are a general operating system and a real-time operating system respectively; the kernel is a fusion kernel formed by fusing a real-time kernel and a general kernel, and the first kernel mode and the second kernel mode are a general kernel mode and a real-time kernel mode respectively.

[0014] Optionally, in the switching method of the operating system according to the present invention, the real-time middleware service program corresponding to the real-time operating system includes: a fast interrupt service program, adapted to interrupt the currently executing real-time task and perform interrupt processing when an interrupt signal is received; a real-time scheduling service program, adapted to obtain the real-time task with the highest urgency from the real-time task queue by using a real-time scheduling algorithm, so as to immediately execute the real-time task with the highest urgency; and a real-time running component, adapted to provide memory management services for the real-time task with the highest urgency.

[0015] Optionally, in the switching method of the operating system according to the present invention, the general middleware service program corresponding to the general operating system includes: a general scheduling service program, adapted to obtain the highest-priority computational task from the computational task queue by using a fair scheduling algorithm when an interrupt signal is received, so as to immediately execute the highest-priority computational task; a threaded interrupt service program, adapted to interrupt the low-priority computational task and perform interrupt processing; and a general running component, adapted to provide memory management services for the highest-priority computational task.

[0016] According to one aspect of the present invention, there is provided a method for switching an operating system, which is executed during the operation of the operating system. The operating system includes a kernel, a first operating system, and a second operating system. The method includes the steps of: during the operation of the second operating system, in response to a request to switch to the first operating system, closing the second middleware operating environment module corresponding to the second operating system; closing the second middleware service program corresponding to the second operating system; and switching the kernel from the second kernel mode corresponding to the second operating system to the first kernel mode corresponding to the first operating system.

[0017] Optionally, in the switching method of the operating system according to the present invention, before closing the second middleware operating environment module corresponding to the second operating system, the method further includes the step of: closing one or more application programs running based on the second operating system.

[0018] According to one aspect of the present invention, there is provided a computing device, including: at least one processor; and a memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, and the program instructions include instructions for executing the switching method of the operating system as described above.

[0019] According to one aspect of the present invention, there is provided a readable storage medium storing program instructions, which, when read and executed by a computing device, cause the computing device to execute the switching method of the operating system as described above.

[0020] According to the technical solution of the present invention, a method for switching operating systems is provided, where the operating system is a hybrid operating system including a real-time operating system and a general-purpose operating system. During the operation of the operating system, the operation state control module can, in response to a user's request, switch the currently running general-purpose operating system to the real-time operating system. Specifically, the kernel is switched from the general kernel mode to the real-time kernel mode, the real-time middleware service program corresponding to the real-time operating system is started, and the real-time middleware operating environment module corresponding to the real-time operating system is started, thereby switching to the real-time operating system, enabling the operating system to switch from the general-purpose operating system to the operating mode of the real-time operating system, so as to run real-time application programs on the real-time operating system and meet the real-time requirements of the application programs. Moreover, in the operating mode of the real-time operating system, by performing a shutdown operation on the real-time operating system, it is possible to switch the current real-time operating system to the general-purpose operating system. In this way, the present invention can achieve instant switching between the general-purpose operating system and the real-time operating system during the operation of the operating system, so as to meet the real-time requirements when performing tasks in different application scenarios.

[0021] The above description is only an overview of the technical solution of the present invention. In order to be able to understand the technical means of the present invention more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features and advantages of the present invention more obvious and understandable, the following specifically illustrates the embodiments of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] To achieve the above and related purposes, certain illustrative aspects are described herein in connection with the following description and drawings, which indicate various ways in which the principles disclosed herein can be practiced, and all aspects and their equivalent aspects are intended to fall within the scope of the claimed subject matter. By reading the following detailed description in conjunction with the drawings, the above and other purposes, features and advantages of the present disclosure will become more apparent. Throughout the present disclosure, like reference numerals generally refer to like components or elements.

[0023] Figure 1 FIG. shows a schematic diagram of a hybrid operating system 120 deployed in a computing device 100 according to an embodiment of the present invention;

[0024] Figure 2 FIG. shows a schematic diagram of a computing device 100 with an operation state control module 136 deployed therein according to an embodiment of the present invention;

[0025] Figure 3 FIG. shows a flowchart of a method 300 for switching operating systems according to an embodiment of the present invention;

[0026] Figure 4 FIG. shows a flowchart of a method 400 for switching operating systems according to an embodiment of the present invention;

[0027] Figure 5 FIG. 3 shows a schematic diagram of the hardware structure of a computing device 100 according to an embodiment of the present invention. DETAILED IMPLEMENTATION MANNER

[0028] Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present disclosure can be more thoroughly understood and the scope of the present disclosure can be fully conveyed to those skilled in the art.

[0029] Figure 1 FIG. 4 shows a schematic diagram of a hybrid operating system 120 deployed in a computing device 100 according to an embodiment of the present invention. According to an application example, the computing device 100 can be, for example, an edge computing server applied in the field of edge computing.

[0030] As Figure 1 shown, the computing device 100 may include a hardware layer 110, a hybrid operating system 120, and an application layer 130. Among them, in some embodiments, the hybrid operating system 120 may be a part of the operating system, that is, the operating system of the computing device 100 includes the hybrid operating system 120. In still other embodiments, the operating system of the computing device 100 may be implemented as the hybrid operating system 120 of the present invention.

[0031] Specifically, the application layer 130 may include one or more applications, runtime libraries, and interfaces provided by the hybrid operating system. Here, the present invention does not limit the types and quantities of applications. Developers can also develop applications according to actual business needs. Each application can call the interfaces provided by the hybrid operating system to request the business operating system to execute tasks. In one embodiment, the applications include, for example, applications for hybrid environment monitoring, applications for hybrid service debugging, applications for hybrid service analysis, and the like.

[0032] The hardware layer 110 can provide a hardware environment for the operation of the hybrid operating system and applications. The hardware layer 110 may include a processor (CPU), an internal memory, and may also include external hardware devices such as a network card, a hard disk, and a keyboard.

[0033] The hybrid operating system 120 can provide a software operating environment for tasks (including real-time tasks and computational tasks) requested to be executed by one or more applications.

[0034] According to the hybrid operation system 120 of the present invention, real-time tasks and computing tasks can be run simultaneously. It should be noted that real-time tasks are tasks that need to respond in a timely manner within a specified time, such as the task of controlling traffic light signals. Computing tasks refer to tasks that require high computing capabilities for processing a large amount of data, such as audio and video processing, database applications, etc.

[0035] There are differences in the requirements of real-time tasks and computing tasks in aspects such as interrupt handling, scheduling, and memory management. Specifically, in terms of interrupt handling, real-time tasks need to execute the task with the highest urgency as soon as possible through interrupt handling; for computing tasks, it is not desirable for the currently executing task to be frequently interrupted. In terms of scheduling, real-time tasks need to be scheduled as soon as an event arrives; for computing services, it is not desirable for the currently executing task to be frequently scheduled out. In the memory management method, real-time tasks need to be all stored in memory instead of being swapped out by virtual memory; since computing tasks need to process a large amount of data, they need to make full use of virtual memory to achieve large-scale data computing.

[0036] In view of the requirements of real-time tasks and computing tasks in aspects such as interrupt handling, scheduling, and memory management, the present invention provides a hybrid operation system 120 that can schedule and execute real-time tasks and computing tasks simultaneously.

[0037] According to an embodiment of the present invention, as Figure 1 shown, the hybrid operation system 120 includes a preemptive kernel 121, an interrupt preprocessing module 122 arranged on top of the preemptive kernel 121, and a runtime system arranged on top of the interrupt preprocessing module 122. Among them, the runtime system includes a real-time runtime system 123 and a general runtime system 124 (non-real-time runtime system). The real-time runtime system 123 can provide a real-time running environment for real-time tasks, and the general runtime system 124 can provide a non-real-time running environment for computing tasks.

[0038] It should be noted that the preemptive kernel 121 in the present invention adopts a fully preemptive kernel to ensure basic real-time response capabilities and the ability to fuse and schedule resources. Each runtime system adopts a complete and independent core software stack, so that the two runtime systems are isolated from each other to ensure the independence of real-time tasks and computing tasks with different time characteristics during operation.

[0039] In one embodiment, as Figure 1As shown, the hybrid operation system 120 further includes an application domain management module 126 located above the real-time operation system 123 and the general operation system 124. The application domain management module 126 can provide a unified domain control interface for one or more applications in the upper application layer, so that the applications can request to execute tasks by calling the domain control interface. The application domain management module 126 can receive task execution requests sent by one or more applications, and allocate tasks to the corresponding domains for execution according to the types of the tasks. That is, when the task is a real-time task, the real-time task is allocated to the real-time operation system 123 for execution, and the real-time operation system 123 can provide a real-time operation environment for the operation of the real-time task. When the task is a computational task, the computational task is allocated to the general operation system 124 for execution, and the general operation system 124 can provide a general operation environment for the operation of the computational task.

[0040] According to an embodiment of the present invention, each module in the real-time operation system 123 is used to implement preferentially processing the real-time task with the highest urgency level, and each module in the general operation system 124 is used to implement preferentially processing the computational task with the highest priority level.

[0041] Specifically, the preemptive kernel 121 can receive an interrupt signal generated by hardware, that is, a hardware interrupt signal. The hardware interrupt signal is automatically generated by a hardware device (such as a network card, a hard disk, a keyboard, etc.) communicatively connected to the hybrid operation system 120. Subsequently, the preemptive kernel 121 can send the interrupt signal from the hardware to the interrupt preprocessing module 122, so that the interrupt signal can be allocated to the corresponding operation system for processing through the interrupt preprocessing module 122.

[0042] The interrupt preprocessing module 122 can respond to the interrupt signal generated by hardware, determine the interrupt type according to the interrupt signal, and allocate the interrupt signal to the corresponding operation system (the real-time operation system 123 or the general operation system 124) for processing according to the interrupt type. Here, the interrupt signal includes interrupt source information, and the interrupt preprocessing module 122 can obtain the interrupt source information from the interrupt signal and determine the interrupt type according to the interrupt source information. The interrupt type is also to determine whether the real-time task with the highest urgency level or the computational task with the highest priority level needs to be executed immediately.

[0043] Among them, when the real-time operating system 123 receives an interrupt signal, it first immediately interrupts the currently executing real-time task and performs interrupt processing. Subsequently, it can use a real-time scheduling algorithm to obtain the real-time task with the highest urgency from the real-time task queue of the processor (CPU), so that the processor (CPU) can immediately execute the real-time task with the highest urgency. At this time, it is equivalent to the real-time task with the highest urgency preempting the right to use the processor. It can be understood that when the real-time operating system 123 receives an interrupt signal, it first performs interrupt processing on the currently executing task and then performs scheduling processing.

[0044] When the general-purpose operating system 124 receives an interrupt signal, it first obtains the highest-priority computational task from the computational task queue of the processor. For example, it can obtain the highest-priority computational task from the computational task queue based on a fair scheduling algorithm. Furthermore, it can interrupt the currently executing low-priority computational task and perform interrupt processing so that the processor can immediately execute the highest-priority computational task.

[0045] Furthermore, after the general-purpose operating system 124 selects the highest-priority computational task from the computational task queue, it needs to determine whether the selected highest-priority computational task is the currently executing computational task. If the highest-priority computational task is not the currently executing computational task, it means that the currently executing computational task is currently a low-priority computational task. Then, interrupt the currently executing low-priority computational task (this low-priority computational task is also the previous highest-priority computational task) and perform interrupt processing so that the processor can immediately switch to execute the highest-priority computational task. At this time, it is equivalent to the highest-priority computational task preempting the right to use the processor.

[0046] In addition, if the selected highest-priority computational task is the currently executing computational task, there is no need to interrupt the currently executing computational task or perform interrupt processing, thus avoiding the situation where computational tasks are frequently interrupted. It can be understood that when the general-purpose operating system 124 receives an interrupt signal, it first performs scheduling processing and then determines whether interrupt processing is required.

[0047] According to an embodiment of the present invention, the real-time operating system 123 includes a fast interrupt service program 1231, a real-time scheduling service program 1232, and a real-time operating component 1233. During the operation of the real-time task with the highest urgency, the real-time operating component 1233 can provide memory management services for the operation of the real-time task with the highest urgency.

[0048] The fast interrupt service program 1231 runs on the processor. The fast interrupt service program 1231 can, when receiving an interrupt signal, interrupt the currently executing real-time task and perform interrupt processing.

[0049] Furthermore, the fast interrupt service routine 1231 can be bound to the interrupt handler. When the fast interrupt service routine 1231 receives an interrupt signal, it can send the interrupt signal to the processor. The processor looks up the corresponding interrupt handler (i.e., the interrupt handler bound to the fast interrupt service routine 1231) from the fast interrupt vector table and sends the interrupt signal to the interrupt handler, so as to interrupt the currently executing real-time task and perform interrupt processing through the interrupt handler.

[0050] It should be noted that interrupt processing refers to the process in which when a new task that needs to be executed with priority appears, the processor temporarily suspends the execution of the current task and turns to execute the new task (such as the real-time task with the highest urgency or the highest-priority computational task in the above embodiments).

[0051] The real-time scheduling service program 1232 can use a real-time scheduling algorithm to obtain the real-time task with the highest urgency from the real-time task queue, so that the processor immediately executes the real-time task with the highest urgency.

[0052] In one embodiment, the real-time scheduling algorithm can be implemented as the least slack time first scheduling algorithm, that is, the least slack time first scheduling algorithm can be used to obtain the real-time task with the highest urgency from the real-time task queue. It should be noted that the least slack time first scheduling algorithm determines the priority of a task according to the urgency (or slack) of the task. For the embodiments of the present invention, the higher the urgency of a real-time task, the higher the priority assigned to the real-time task, so as to preferentially execute the real-time task with the highest urgency. In the real-time task queue, each real-time task is sorted in ascending order of slack time (that is, in descending order of urgency), where the real-time task with the lowest slack time (the highest urgency) is ranked at the front of the real-time task queue and is preferentially scheduled for execution. The calculation method of slack time is as follows: the slack time of a real-time task = the time when it must be completed - its own running time - the current time. According to this algorithm, when the least slack time of a real-time task is reduced to 0, the real-time scheduling service program 1232 must immediately schedule the real-time task so that the task immediately preempts the processor and ensures that the real-time task is executed according to the requirements of the deadline.

[0053] According to an embodiment of the present invention, the general operating system 124 includes a general scheduling service program 1242, a threaded interrupt service program 1241, and a general operating component 1243. During the execution of the highest-priority computational task, the general operating component 1243 can provide memory management services for the highest-priority computational task.

[0054] The general scheduling service program 1242 can, when receiving an interrupt signal, use a fair scheduling algorithm to select and obtain the highest-priority computational task from the computational task queue of the processor, so that the processor can immediately execute the highest-priority computational task. In one implementation, the fair scheduling algorithm can be implemented as the CFS scheduling algorithm. The general scheduling service program 1242 can use the CFS scheduling algorithm to select the highest-priority computational task from the task queue of the processor. Specifically, according to the CFS scheduling algorithm, the general scheduling service program 1242 always selects the computational task that runs the slowest from the computational task queue as the highest-priority computational task, so that the computational task that runs slower can get more running opportunities.

[0055] It should be noted that if the highest-priority computational task is the computational task that is being executed, then continue to execute the computational task that is being executed, and there is no need to perform interrupt processing on the computational task that is being executed.

[0056] If the highest-priority computational task is not the computational task that is being executed, in other words, the computational task that is being executed is a low-priority computational task, then, further interrupt the low-priority computational task that is being executed through the threaded interrupt service program 1241 and perform interrupt processing.

[0057] In one embodiment, the threaded interrupt service program 1241 runs on the processor. The threaded interrupt service program 1241 can specifically interrupt the low-priority computational task that is being executed and perform interrupt processing according to the following method: an interrupt signal can be sent to the processor, and the processor converts the interrupt signal into a corresponding interrupt request (IRQ), and looks up one or more interrupt handlers associated with the interrupt request from the interrupt request registry. And, the processor wakes up one or more processing threads corresponding to the one or more interrupt handlers in turn, so as to interrupt the low-priority computational task that is being executed and perform interrupt processing via the one or more processing threads.

[0058] Specifically, there can be multiple interrupt handlers associated with the interrupt request. During the process of the processor looking up multiple interrupt handlers associated with the interrupt request from the interrupt request registry, each time a related interrupt handler is found, the processing thread corresponding to the interrupt handler will be woken up, so as to interrupt the low-priority computational task that is being executed and perform interrupt processing via the processing thread. After waiting for the processing thread to complete execution, then continue to look up the next related interrupt handler from the interrupt request registry, wake up the next processing thread corresponding to the next interrupt handler, and wait for the next processing thread to complete execution. And so on, until the processing threads corresponding to all the interrupt handlers associated with the interrupt request have completed execution, thus completing the interrupt processing.

[0059] In addition, in one embodiment, as Figure 1 shown, a domain resource management service program 125 may also be deployed between the real-time operating system 123 and the general operating system 124. The domain resource management service program 125 is used to separate the resources of the real-time operating system 123 and the general operating system 124, ensuring the isolation of resources and characteristics between the real-time operating system 123 and the general operating system 124.

[0060] In an embodiment according to the present invention, the computing device 100 is configured to execute the operating system switching method 300 according to the present invention. The computing device 100 includes multiple program instructions for executing the operating system switching method 300 according to the present invention, so that the computing device 100 can switch the operating system during the operation of the operating system by executing the operating system switching method 300 according to the present invention, so that the operating system switches from the first operating system to the operating mode of the second operating system.

[0061] According to an embodiment of the present invention, a startup management module 135 and a running state control module 136 are also deployed in the application layer 130 of the computing device 100. The startup management module 135 is used to control the startup of the operating system and enter the real-time operating system or the general operating system according to the user's needs during the startup phase of the operating system.

[0062] The running state control module 136 is used to manage the intermediate state of the running environment during the operation of the operating system, including the perception of the state, fault tolerance processing, etc., so as to realize the instant switching of the operating system between different operating systems.

[0063] Figure 2 Shows a schematic diagram of the running state control module 136 deployed in the computing device 100 according to an embodiment of the present invention.

[0064] As Figure 2 shown, the computing device 100 includes a hardware layer 110, an operating system, and an application layer 130 arranged on top of the operating system. The application layer 130 includes a startup management module 135, a running state control module 136, a runtime library, and an interface provided by the operating system.

[0065] In an embodiment according to the present invention, the operating system of the computing device 100 may be implemented as Figure 1The hybrid operating system 120 shown in [the figure]. Specifically, the operating system includes a kernel, a real-time operating system 123, and a general-purpose operating system 124 (non-real-time operating system). The kernel (preemptive kernel) in the operating system can be implemented as a fusion kernel formed by fusing a real-time kernel and a general-purpose kernel (non-real-time kernel). The fusion kernel can switch between the general-purpose kernel mode and the real-time kernel mode. It should be understood that the fusion kernel in the present invention is a specific implementation of a preemptive kernel.

[0066] In one embodiment, the hardware layer 110 includes a processor and an internal memory. Among them, the internal memory includes a boot loader 115. Here, the boot loader 115 is the BootLoader, which is the first program to run before the kernel of the operating system. It can initialize hardware devices and establish a memory space mapping diagram, so as to bring the software environment and the hardware environment to a suitable state, in order to prepare the correct environment for finally calling the operating system kernel. In the early stage of the operating system startup, the boot loader 115 can respond to the request of the startup management module 135 to start the kernel.

[0067] Figure 3 The flowchart of the operating system switching method 300 according to an embodiment of the present invention is shown. The method 300 is suitable for execution in the computing device 100. Among them, during the operation of the operating system of the computing device 100, the computing device 100 can perform instant switching between different operating systems by executing the operating system switching method 300 according to the present invention. For example, it can switch the first operating system to the second operating system, so that the operating system instantaneously switches from the first operating system to the operating mode of the second operating system.

[0068] It should be noted that the first operating system and the second operating system can be any one of the general-purpose operating system and the real-time operating system respectively. The first operating system corresponds to the first kernel mode, and the second operating system corresponds to the second kernel mode.

[0069] Among them, when the first operating system is a general-purpose operating system (the corresponding first kernel mode is the general-purpose kernel mode), the second operating system is a real-time operating system (the corresponding second kernel mode is the real-time kernel mode). When the first operating system is a real-time operating system (the corresponding first kernel mode is the real-time kernel mode), the second operating system is a general-purpose operating system (the corresponding second kernel mode is the general-purpose kernel mode).

[0070] As Figure 3 shown, the method 300 includes steps S310 to S330.

[0071] In step S310, during the operation of the first operating system, in response to a user request to switch to the second operating system, the kernel is switched from the first kernel mode corresponding to the first operating system to the second kernel mode corresponding to the second operating system.

[0072] Specifically, the operation status control module 136 may receive a user request to switch the currently operating first operating system to the second operating system, and in response to the user request to switch to the second operating system, notify the kernel to switch the current first operating system to the second operating system. Then, the kernel is switched from the first kernel mode corresponding to the first operating system to the second kernel mode corresponding to the second operating system. After the kernel switch operation is completed, the kernel notifies the operation status control module 136 that the kernel switch operation is completed.

[0073] Subsequently, in step S320, the second middleware service program corresponding to the second operating system is started.

[0074] Specifically, after receiving the notification that the kernel switch operation is completed, the operation status control module 136 notifies the second middleware service program corresponding to the second operating system to start, so as to start the second middleware service program corresponding to the second operating system. After the second middleware service program is started, the switching operation from the first middleware service program corresponding to the first operating system to the second middleware service program is completed. Subsequently, it notifies the operation status control module 136 that the middleware service program switching operation is completed.

[0075] Finally, in step S330, the second middleware running environment module corresponding to the second operating system is started to start the second operating system.

[0076] Specifically, after receiving the notification that the middleware service program switching operation is completed, the operation status control module 136 notifies the second middleware running environment module corresponding to the second operating system to start, so as to start the second middleware running environment module corresponding to the second operating system. After the second middleware running environment module is started, the switching operation from the first middleware running environment module corresponding to the first operating system to the second middleware running environment module corresponding to the second operating system is completed. Subsequently, it notifies the operation status control module 136 that the middleware running environment switching operation is completed.

[0077] Thus, the switching operation from the first operating system to the second operating system is completed. In this way, according to the user's requirements, the operating system is instantaneously switched from the first operating system to the operating mode of the second operating system.

[0078] According to an embodiment of the present invention, the first operating system and the second operating system are a general operating system and a real-time operating system respectively. The first kernel mode and the second kernel mode are a general kernel mode and a real-time kernel mode respectively. Correspondingly, the first middleware corresponding to the first operating system is general middleware, and the first middleware service program is a general middleware service program; the second middleware corresponding to the second operating system is real-time middleware, and the second middleware service program is a real-time middleware service program. In this way, by executing the method 300 of the present invention, it is possible to switch from the current general operating system to the real-time operating system, so that the operating system switches from the general operating system to the operating mode of the real-time operating system, meeting the user's requirements for the real-time environment.

[0079] In addition, after starting the second middleware runtime environment module corresponding to the second operating system, one or more application programs running based on the second operating system can be started.

[0080] In an embodiment, when the first operating system and the second operating system are a general operating system and a real-time operating system respectively, one or more application programs running based on the second operating system (real-time operating system) are real-time application programs with real-time requirements for the operating environment.

[0081] It should be noted that the middleware is connected between the operating system and the application to enable communication between the operating system and the application. In the technical solution of the present invention, the second middleware corresponding to the second operating system is software that is connected between the second operating system and the application and is used for communication between the second operating system and the application.

[0082] In an embodiment of the present invention, the middleware includes an interface, a runtime library, an application domain management module 126, a domain resource management service program 125, a real-time running component 1233, a real-time scheduling service program 1232, a fast interrupt service program 1231, a general running component 1243, a general scheduling service program 1242, and a threaded interrupt service program 1241.

[0083] In an embodiment of the present invention, the middleware is differentiated for the real-time operating system and the general operating system. Specifically, the real-time middleware corresponding to the real-time operating system includes an interface, a runtime library, an application domain management module 126, a domain resource management service program 125, a real-time running component 1233, a real-time scheduling service program 1232, and a fast interrupt service program 1231. The real-time middleware service program corresponding to the real-time operating system includes an application domain management module 126, a domain resource management service program 125, a real-time running component 1233, a real-time scheduling service program 1232, and a fast interrupt service program 1231. That is to say, the real-time middleware includes an interface, a runtime library, and the real-time middleware service program.

[0084] The general middleware corresponding to the general operating system includes an interface, a runtime library, an application domain management module 126, a domain resource management service program 125, a general running component 1243, a general scheduling service program 1242, and a threaded interrupt service program 1241. The general middleware service program corresponding to the general operating system includes an application domain management module 126, a domain resource management service program 125, a general running component 1243, a general scheduling service program 1242, and a threaded interrupt service program 1241. That is to say, the general middleware includes an interface, a runtime library, and the general middleware service program.

[0085] It can be understood that the common middleware shared by the real-time middleware and the general middleware includes an interface, a runtime library, an application domain management module 126, and a domain resource management service program 125.

[0086] It should be noted that for the specific execution logics of each middleware and middleware service program, please refer to the description in the computing device 100 above, which will not be elaborated here.

[0087] It should be noted that the middleware runtime environment module includes underlying dependency libraries (shared libraries). For example, the general middleware runtime environment module includes general dependency libraries (without real-time performance), and the real-time middleware runtime environment module includes corresponding real-time dependency libraries (with real-time performance). When switching the operating system, it is necessary to switch the middleware runtime environment module accordingly, that is, start the second middleware runtime environment module corresponding to the second operating system, specifically including: starting the underlying dependency libraries corresponding to the second middleware. Among them, the dependency libraries include, for example, dependency libraries for memory management, dependency libraries for inter-process communication, and dependency libraries for network communication.

[0088] In one embodiment, the first operating system is a general operating system, the second operating system is a real-time operating system. Correspondingly, the second middleware is real-time middleware, and the dependency libraries corresponding to the real-time middleware are real-time dependency libraries. In this embodiment, starting the second middleware runtime environment module (real-time middleware runtime environment module) corresponding to the second operating system (real-time operating system) specifically includes: starting the real-time dependency libraries corresponding to the real-time middleware, so as to replace the general dependency libraries with real-time dependency libraries that meet the real-time performance requirements, so that after starting the real-time operating system, it can meet the real-time requirements during task operation, and can access memory in real time and perform inter-process communication in real time.

[0089] In one embodiment, during the operation of both the real-time operating system and the general operating system, general service programs are running in the operating system. The second middleware service program corresponding to the second operating system can be started through the general service programs. Here, the general service programs of the operating system can include, for example, a login service program, a scheduled task service program, a network service program, etc.

[0090] Figure 4 The flowchart of the switching method 400 of the operating system according to an embodiment of the present invention is shown. The method 400 is adapted to be executed in the computing device 100. During the operation of the operating system of the computing device 100, the computing device 100 can switch the second operating system to the first operating system by executing the switching method 400 of the operating system according to the present invention, so that the operating system can be instantaneously switched from the second operating system to the operating mode of the first operating system.

[0091] In one embodiment, the first operating system is a general operating system, and the second operating system is a real-time operating system. In this way, by executing the switching method 400 of the operating system according to the present invention, it is possible to switch from the real-time operating system to the general operating system.

[0092] As Figure 4 shown, the method 400 starts from step S410.

[0093] In step S410, during the operation of the second operating system, in response to a user's request to switch to the first operating system (i.e., close the second operating system), one or more applications running based on the second operating system can be closed first. Then, the second middleware runtime environment module corresponding to the second operating system is closed.

[0094] Specifically, after receiving the user's request to close the second operating system, the running state control module, in response to the user's request to switch to the first operating system and close, notifies the second middleware runtime environment module corresponding to the second operating system to close to switch to the first operating system, so as to close one or more applications running based on the second operating system, and then closes the second middleware runtime environment module corresponding to the second operating system. After the second middleware runtime environment module corresponding to the second operating system is closed, the switching operation from the second middleware runtime environment module corresponding to the second operating system to the first middleware runtime environment module corresponding to the first operating system is completed. Subsequently, it notifies the running state control module 136 to complete the switching operation of the middleware runtime environment.

[0095] Next, in step S420, the second middleware service program corresponding to the second operating system is closed.

[0096] Specifically, after receiving the notification that the switching operation of the middleware running environment is completed, the running state control module 136 notifies the second middleware service program corresponding to the second running system to be shut down, so as to shut down the second middleware service program corresponding to the second running system and stop the second middleware service. After the second middleware service program is shut down, the switching operation from the second middleware service program corresponding to the second running system to the first middleware service program is completed. Subsequently, the running state control module 136 is notified to complete the switching operation of the middleware service program.

[0097] Finally, in step S430, the kernel is switched from the second kernel mode corresponding to the second running system to the first kernel mode corresponding to the first running system.

[0098] Specifically, after receiving the notification that the switching operation of the middleware service program is completed, the running state control module 136 notifies the kernel to switch the second running system to the first running system. Then, the kernel switches from the second kernel mode corresponding to the second running system to the first kernel mode corresponding to the first running system. After the kernel switching operation is completed, the kernel notifies the running state control module 136 to complete the kernel switching operation.

[0099] Thus, the shutdown operation of the second running system is completed, that is, the switching operation from the second running system to the first running system is completed. In this way, according to the user's requirements, the operating system is instantaneously switched from the second running system to the running mode of the first running system.

[0100] According to an embodiment of the present invention, the first running system and the second running system are a general running system and a real-time running system respectively. The first kernel mode and the second kernel mode are a general kernel mode and a real-time kernel mode respectively.

[0101] In this way, by performing the method 300 of the present invention, the real-time running system is shut down through the above steps, and it is possible to switch from the currently running real-time running system to the general running system, so that the operating system is switched from the real-time running system to the running mode of the general running system, meeting the user's requirements for the real-time environment.

[0102] According to the technical solution of the present invention, the operating system is a hybrid operating system including a real-time operating system and a general-purpose operating system. According to the operating system switching method 300 of the present invention, during the operation of the operating system, the operation state control module can, in response to a user's request, switch the currently running general-purpose operating system to the real-time operating system. Specifically, the kernel is switched from the general kernel mode to the real-time kernel mode, the real-time middleware service program corresponding to the real-time operating system is started, and the real-time middleware operating environment module corresponding to the real-time operating system is started, so as to switch to the real-time operating system, enabling the operating system to switch from the general-purpose operating system to the operating mode of the real-time operating system, so as to run real-time application programs on the real-time operating system and meet the real-time requirements of the application programs. And, in the operating mode of the real-time operating system, by performing a shutdown operation on the real-time operating system, it is possible to switch the current real-time operating system to the general-purpose operating system. In this way, the present invention can achieve instant switching between the general-purpose operating system and the real-time operating system during the operation of the operating system, so as to meet the real-time requirements when performing tasks in different application scenarios.

[0103] Figure 5 FIG. shows a schematic hardware structure diagram of a computing device 100 according to an embodiment of the present invention. As Figure 5 shown, the computing device 100 may include an input device 90, a processor 91, an output device 92, a memory 93, and at least one communication bus 94. The communication bus 94 is used to implement communication connections between components. The memory 93 may include high-speed RAM memory and may also include non-volatile storage NVM, such as at least one disk memory. Various program instructions may be stored in the memory 93 for completing various processing functions and implementing the operating system switching method in the embodiments of the present invention.

[0104] Optionally, the above-mentioned processor 91 may be implemented, for example, by a central processing unit (CPU), an application-specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field programmable gate array (FPGA), a controller, a microcontroller, a microprocessor, or other electronic components. The processor 91 is coupled to the above-mentioned input device 90 and output device 92 through a wired or wireless connection.

[0105] Optionally, the above input device 90 may include a variety of input devices, for example, it may include at least one of a user interface facing the user, a device interface facing the device, a programmable interface of software, a camera, and a sensor. Optionally, the device interface facing the device may be a wired interface for data transmission between devices, or may also be a hardware insertion interface for data transmission between devices (such as a USB interface, a serial port, etc.); Optionally, the user interface facing the user may be, for example, a control button facing the user, a voice input device for receiving voice input, and a touch sensing device for receiving user touch input (such as a touch screen with touch sensing function, a touchpad, etc.); Optionally, the above programmable interface of software may be, for example, an entry for the user to edit or modify a program, such as an input pin interface or an input interface of a chip, etc.; Optionally, the above transceiver may be a radio frequency transceiver chip with communication function, a baseband processing chip, and a transceiver antenna, etc. An audio input device such as a microphone can receive voice data. The output device 92 may include output devices such as a display and a speaker.

[0106] In an embodiment of the present invention, the computing device 100 includes one or more processors and one or more readable storage media storing program instructions. When the program instructions are configured to be executed by one or more processors, the computing device is caused to execute the switching method of the operating system in the embodiments of the present invention.

[0107] The various technologies described herein can be implemented in combination with hardware or software, or a combination thereof. Thus, the method and device of the present invention, or certain aspects or portions of the method and device of the present invention, may take the form of program code (i.e., instructions) embedded in a tangible medium, such as a removable hard disk, a USB flash drive, a floppy disk, a CD-ROM, or any other machine-readable storage medium, wherein when the program is loaded into a machine such as a computer and executed by the machine, the machine becomes a device for practicing the present invention.

[0108] In the case where the program code is executed on a programmable computer, the mobile terminal generally includes a processor, a processor-readable storage medium (including volatile and non-volatile memories and / or storage elements), at least one input device, and at least one output device. Among them, the memory is configured to store the program code; the processor is configured to execute the switching method of the operating system of the present invention according to the instructions in the program code stored in the memory.

[0109] By way of example and not limitation, a readable medium includes a readable storage medium and a communication medium. The readable storage medium stores information such as computer readable instructions, data structures, program modules or other data. The communication medium generally embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism, and includes any information delivery medium. A combination of any of the above is also included within the scope of the readable medium.

[0110] In the specification provided herein, the algorithms and displays are not inherently related to any particular computer, virtual system, or other device. A variety of general purpose systems may also be used in conjunction with the examples of the present invention. The structure required to construct such systems will be apparent from the above description. Additionally, the present invention is not directed to any particular programming language. It should be understood that various programming languages may be used to implement the content of the present invention described herein, and the description of a particular language above is for the purpose of disclosing the best mode of the present invention.

[0111] In the specification provided herein, numerous specific details are set forth. However, it is understood that embodiments of the present invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure an understanding of this specification.

[0112] Similarly, it should be understood that in order to streamline this disclosure and assist in understanding one or more of the various inventive aspects, in the foregoing description of the exemplary embodiments of the present invention, the various features of the present invention are sometimes grouped together in a single embodiment, figure, or description thereof. However, the disclosed method should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Thus, the claims following the detailed description are hereby expressly incorporated into the detailed description, with each claim standing on its own as a separate embodiment of the present invention.

[0113] Those skilled in the art should understand that the modules or units or components of the devices in the examples disclosed herein may be arranged in the devices as described in the embodiments, or alternatively may be located in one or more devices different from those in the examples. The modules in the foregoing examples may be combined into one module or further divided into multiple sub-modules.

[0114] Those skilled in the art can understand that the modules in the devices in the embodiments can be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments can be combined into one module or unit or component, and in addition, they can be divided into multiple sub-modules or sub-units or sub-components. Except that at least some of such features and / or processes or units are mutually exclusive, any combination can be adopted for all the features disclosed in this specification (including the accompanying claims, abstract and drawings) and all the processes or units of any method or device so disclosed. Unless otherwise explicitly stated, each feature disclosed in this specification (including the accompanying claims, abstract and drawings) can be replaced by an alternative feature that provides the same, equivalent or similar purpose.

[0115] In addition, those skilled in the art can understand that although some of the embodiments described herein include certain features included in other embodiments rather than other features, the combination of features of different embodiments means that it is within the scope of the present invention and forms different embodiments. For example, in the following claims, any one of the claimed embodiments can be used in any combination.

[0116] In addition, some of the embodiments herein are described as a combination of methods or method elements that can be implemented by a processor of a computer system or by other devices performing the functions. Therefore, a processor having the necessary instructions for implementing the method or method element forms a device for implementing the method or method element. In addition, the elements described herein in the device embodiments are examples of such devices: the device is used to implement the functions performed by the elements for the purpose of implementing the invention.

[0117] As used herein, unless otherwise specified, the use of ordinal numbers "first", "second", "third", etc. to describe ordinary objects only indicates different instances of similar objects and does not intend to imply that the objects so described must have a given order in terms of time, space, sorting, or in any other way.

[0118] Although the present invention has been described in terms of a limited number of embodiments, those skilled in the art will appreciate, in light of the above description, that other embodiments can be contemplated within the scope of the invention as thus described. Additionally, it should be noted that the language used in this specification has been principally selected for readability and instructional purposes rather than for the purpose of explaining or limiting the subject matter of the invention. Accordingly, many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the appended claims. For the scope of the present invention, the disclosure of the invention is illustrative and not restrictive, and the scope of the invention is defined by the appended claims.

Claims

1. A method for switching operating systems, which is executed during the operation of an operating system. The operating system includes a kernel, a general-purpose operating system, and a real-time operating system. The kernel is a fused kernel formed by fusing a real-time kernel and a general-purpose kernel. The method includes the following steps: During the operation of the general-purpose operating system, in response to a request to switch to the real-time operating system, switch the kernel from the general-purpose kernel mode corresponding to the general-purpose operating system to the real-time kernel mode corresponding to the real-time operating system; Start the real-time middleware service program corresponding to the real-time operating system. The real-time middleware service program includes: a fast interrupt service program, which is suitable for interrupting the currently executing real-time task and performing interrupt processing when receiving an interrupt signal; a real-time scheduling service program, which is suitable for using a real-time scheduling algorithm to obtain the most urgent real-time task from the real-time task queue so as to immediately execute the most urgent real-time task; a real-time operation component, which is suitable for providing memory management services for the most urgent real-time task; Start the real-time middleware operating environment module corresponding to the real-time operating system, including starting the dependency library corresponding to the real-time middleware to replace the dependency library corresponding to the general middleware, so as to start the real-time operating system. The dependency library includes a dependency library for memory management, a dependency library for inter-process communication, and a dependency library for network communication; Start one or more applications running based on the real-time operating system; During the operation of the real-time operating system, in response to a request to switch to the general-purpose operating system, close one or more applications running based on the real-time operating system, and close the real-time middleware operating environment module corresponding to the real-time operating system; Close the real-time middleware service program corresponding to the real-time operating system; Switch the kernel from the real-time kernel mode corresponding to the real-time operating system to the general-purpose kernel mode corresponding to the general-purpose operating system.

2. The method according to claim 1, wherein There is a running state control module deployed on the operating system. The step of switching the kernel from the general-purpose kernel mode corresponding to the general-purpose operating system to the real-time kernel mode corresponding to the real-time operating system in response to a request to switch to the real-time operating system includes: The running state control module, in response to a request to switch to the real-time operating system, notifies the kernel to switch the general-purpose operating system to the real-time operating system; The kernel switches from the general-purpose kernel mode corresponding to the general-purpose operating system to the real-time kernel mode corresponding to the real-time operating system.

3. The method according to claim 1 or 2, wherein After switching the kernel from the general-purpose kernel mode corresponding to the general-purpose operating system to the real-time kernel mode corresponding to the real-time operating system, it includes the following steps: The kernel notifies the running state control module that the switching operation is completed; The running state control module notifies the real-time middleware service program corresponding to the real-time operating system to start.

4. The method according to claim 1 or 2, wherein The general middleware service program corresponding to the general-purpose operating system includes: A general scheduling service program, which is suitable for using a fair scheduling algorithm to obtain the highest-priority computational task from the computational task queue when receiving an interrupt signal so as to immediately execute the highest-priority computational task; A threaded interrupt service program, which is suitable for interrupting low-priority computational tasks and performing interrupt processing; A general operation component, adapted to provide memory management services for the highest-priority computing tasks.

5. A computing device, comprising: At least one processor; And A memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, and the program instructions include instructions for performing the method according to any one of claims 1-4.

6. A readable storage medium storing program instructions, which when read and executed by a computing device, cause the computing device to perform the method according to any one of claims 1-4.

Citation Information

Patent Citations

  • Real-time Linux operating system

    CN101894045A

  • Method and system for improving real-time performance of non-real-time operating system

    CN109522099A