Operating system switching method, terminal equipment and storage medium

By responding to the first upper-layer switching operation in the terminal device and performing front- and back-end switching, the problem of long switching of the operating system is solved, and faster switching and better user experience is achieved.

CN120010930APending Publication Date: 2025-05-16TD TECH LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311517296.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-14
Publication Date
2025-05-16

AI Technical Summary

Technical Problem

In the prior art, the terminal device has a long wait time when switching the operating system, resulting in poor user experience.

Method used

The kernel responds to the first upper layer switching operation, unblocks, and performs front- and back-end switching with the second upper layer without releasing the peripheral resources, and then releases the resources in the background, and the second upper layer associates the resources in the foreground.

Benefits of technology

It greatly reduces the switching time of the operating system and improves the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120010930A_ABST
    Figure CN120010930A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an operating system switching method, terminal equipment and a storage medium, relates to the field of operating systems, and is applied to the terminal equipment, the terminal equipment runs a first operating system and a second operating system, the first operating system and the second operating system share a kernel, and a first upper layer of the first operating system runs in a foreground. A second upper layer of the second operating system runs in the background, and the method comprises the steps that the kernel responds to a monitored first upper layer switching operation, and blockage of a first target node of the first upper layer is relieved; the first upper layer performs foreground and background switching with the second upper layer under the condition that the occupied peripheral resources of the terminal equipment are not released; the first upper layer releases the occupied peripheral resources of the terminal equipment in the background; the second upper layer is associated with peripheral resources of the terminal equipment at the foreground. The switching time of foreground and background operating systems of the terminal equipment can be shortened, and the use experience of a user is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of operating systems, and in particular to an operating system switching method, a terminal device, and a storage medium. Background Art

[0002] With the development of terminal devices, many terminal devices are capable of running multiple operating systems, for example, running two Android operating systems on a mobile phone.

[0003] Currently, when a user switches an operating system in a terminal device, the waiting time for switching is long, and the user experience is poor. Summary of the invention

[0004] The embodiments of the present application provide an operating system switching method, a terminal device, and a storage medium, which can reduce the operating system switching time and improve the user experience.

[0005] In a first aspect, an embodiment of the present application provides an operating system switching method, which is applied to a terminal device, wherein the terminal device runs a first operating system and a second operating system, the first operating system and the second operating system share a kernel, a first upper layer of the first operating system runs in the foreground, and a second upper layer of the second operating system runs in the background, the method comprising:

[0006] The kernel, in response to the monitored first upper layer switching operation, unblocks the first target node of the first upper layer;

[0007] The first upper layer switches between the foreground and background with the second upper layer without releasing the peripheral resources of the terminal device occupied;

[0008] The first upper layer releases the occupied peripheral resources of the terminal device in the background;

[0009] The second upper layer is associated with the peripheral resources of the terminal device in the foreground.

[0010] In some embodiments, before performing the foreground-background switching with the second upper layer, the method further includes:

[0011] The first upper layer sets the state node of the associated peripheral resource to an idle state;

[0012] When the kernel monitors that the state node of the peripheral resource is in an idle state, the blocking of the second target node of the second upper layer is unblocked.

[0013] In some embodiments, the method further comprises:

[0014] When the first upper layer receives the first target message sent by the second upper layer, the first upper layer releases the occupied peripheral resources in the background.

[0015] In some embodiments, the method further comprises:

[0016] The second upper layer sends the first target message to the first upper layer through a root domain.

[0017] In some embodiments, the method further comprises:

[0018] When the first upper layer completes releasing the peripheral resource, sending a second target message to the second upper layer through the root domain;

[0019] When the second upper layer receives the second target message, it associates the peripheral resource in the foreground and updates the state node of the peripheral resource to the running state.

[0020] In some embodiments, the HAL service is run in the root domain, and the method further includes:

[0021] The root domain forwards messages between the first upper layer and the second upper layer through the HAL service.

[0022] In some embodiments, before the first upper layer sets the status node of the associated peripheral resource to an idle state, the method further includes:

[0023] The first upper layer determines that the state node of the peripheral resource is an unexecuted state transition.

[0024] In a second aspect, an embodiment of the present application provides a terminal device, wherein the terminal device runs a first operating system and a second operating system, wherein the first operating system and the second operating system share a kernel, a first upper layer of the first operating system runs in the foreground, and a second upper layer of the second operating system runs in the background;

[0025] The kernel is configured to unblock the first target node of the first upper layer in response to the monitored first operating system switching operation;

[0026] The first upper layer is used to switch between the foreground and background with the second upper layer without releasing the occupied peripheral resources of the terminal device, and to release the occupied peripheral resources of the terminal device in the background;

[0027] The second upper layer is used to associate the peripheral resources of the terminal device in the foreground.

[0028] In a third aspect, an embodiment of the present application provides a terminal device, including: a memory and a processor;

[0029] The memory is used to store computer instructions; the processor is used to execute the computer instructions stored in the memory to implement any method in the first aspect.

[0030] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and the computer program is executed by a processor to implement any one of the methods in the first aspect.

[0031] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which implements any method in the first aspect when executed by a processor.

[0032] The embodiment of the present application provides an operating system switching method, a terminal device and a storage medium, wherein the kernel responds to the monitored first upper layer switching operation to unblock the first target node of the first upper layer; the first upper layer switches between the foreground and background with the second upper layer without releasing the occupied peripheral resources of the terminal device; the first upper layer releases the occupied peripheral resources of the terminal device in the background; the second upper layer associates the peripheral resources of the terminal device in the foreground. In the switching process, the first upper layer no longer executes the release of the associated peripheral resources, and the first upper layer and the second upper layer can quickly complete the switching operation, greatly reducing the switching time of the foreground and background operating systems. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] Figure 1 A schematic diagram of a terminal device provided in an embodiment of the present application;

[0034] Figure 2 Schematic diagram of the operating system switching method provided in the embodiment of the present application Figure 1 ;

[0035] Figure 3 Schematic diagram of the operating system switching method provided in the embodiment of the present application Figure 2 ;

[0036] Figure 4 A schematic diagram of the structure of a terminal device provided in an embodiment of the present application;

[0037] Figure 5 A schematic diagram of the structure of another terminal device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0038] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0039] In the embodiments of the present application, words such as "first" and "second" are used to distinguish the same or similar items with substantially the same functions and effects, and do not limit their order. Those skilled in the art can understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit them to be different.

[0040] It should be noted that in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0041] With the development of terminal devices, many terminal devices are capable of running multiple operating systems, for example, running two Android operating systems on a mobile phone.

[0042] Combine the following Figure 1 The architecture of the terminal device involved in the embodiments of the present application is introduced.

[0043] Figure 1 The schematic diagram of the architecture of the terminal device provided in the embodiment of the present application is as follows: Figure 1 As shown, a first operating system 110 and a second operating system 120 are running in the terminal device 100 .

[0044] One of the first operating system 110 and the second operating system 120 is a foreground operating system, and the other is a background operating system. The first operating system 110 and the second operating system 120 share an operating system kernel (kernel for short) 130 .

[0045] The first operating system 110 includes a first upper layer 111 and a common operating system kernel 130. The first operating system 120 includes a second upper layer 121 and a common operating system kernel 130. The first upper layer and the second upper layer may be referred to as a first upper layer space and a second upper layer space.

[0046] Among them, the first upper layer in the foreground can also be called the foreground domain, and the second upper layer in the background can also be called the background domain.

[0047] In some embodiments, the upper layer may include an application layer, an application framework layer, a system library, etc. The upper layer space and the operating system kernel together constitute an operating system.

[0048] In some embodiments, the terminal device 100 also includes peripheral resources 140 .

[0049] The peripheral resources 140 may be hardware resources of the terminal device 100 , such as a Bluetooth module, a Wireless Fidelity (WiFi) module, a Global Positioning System (GPS) module, a Near Field Communication (NFC) module, and other hardware resources.

[0050] The upper space of the operating system is associated with the peripheral resources of the terminal device through the kernel's hardware driver, jointly realizing the user's control over the terminal device.

[0051] It should be noted that the terminal device 110 can be a mobile phone, a tablet computer, a desktop computer, a portable notebook computer or a car computer, etc., and the embodiments of the present application do not specifically limit this. In addition, the first operating system and the second operating system can be an Android operating system, a Hongmeng operating system or other appropriate operating systems, and the embodiments of the present application also do not specifically limit this.

[0052] Depend on Figure 1 It can be seen that for terminal devices running dual operating systems, there is only one set of actual physical devices, firmware, drivers, etc., but there are two operating systems in the upper user space, one operating system running in the foreground and the other operating system running in the background.

[0053] When switching operating systems, the operating system in the foreground releases the peripheral resources of the associated terminal device. After the peripheral resources are released, the operating system in the foreground switches with the operating system in the background. When the operating system in the background switches to the foreground, the peripheral resources of the terminal device are associated to complete the switching of the operating systems.

[0054] However, the above process takes a long time and the user experience is not good.

[0055] In view of this, the embodiments of the present application provide an operating system switching method, system, electronic device and storage medium, which can reduce the operating system switching time and improve the user experience.

[0056] The following specific embodiments are used to describe in detail the technical solution of the present application and how the technical solution of the present application solves the above technical problems. The following specific embodiments can be implemented independently or in combination with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.

[0057] Combine the following Figure 1 The operating system switching method provided in the embodiment of the present application is described.

[0058] Figure 2 A flowchart of the operating system switching method provided in the embodiment of the present application is shown in FIG. Figure 1 As shown, including:

[0059] S201. In response to a monitored first upper layer switching operation, the kernel unblocks a first target node of the first upper layer.

[0060] In the embodiment of the present application, the first target node is used to control whether the first upper layer remains in the foreground.

[0061] Exemplarily, the first target node may be a / proc / dev_ns / wait_for_early_deactivate node, and when the first upper layer is blocked at the / proc / dev_ns / wait_for_early_deactivate node, the first upper layer remains in the foreground.

[0062] In the embodiment of the present application, the kernel can monitor the system switching event of the first upper layer in the foreground through the monitoring thread. The system switching event represents the event of the user switching the operating system, such as the event of the user clicking the switching icon in the system switching application.

[0063] In the embodiment of the present application, unblocking the first target node of the first upper layer may be changing the state of the first target node.

[0064] In some embodiments, the state of the first target node can be represented by numbers, characters, etc.

[0065] Taking the use of numbers to represent the state of the first target node as an example, the first target node can use 0 and 1 to represent the blocking state and the non-blocking state. When the kernel monitors the switching operation, it can change the state of the first target node from 0 to 1, thereby unblocking the first target node.

[0066] S202: The first upper layer switches between foreground and background with the second upper layer without releasing the occupied peripheral resources of the terminal device.

[0067] In the embodiment of the present application, when the first upper layer monitors through the monitoring thread that the state of the first target node is a non-blocking state, the foreground and background switching process can be entered.

[0068] It can be understood that the first upper layer entering the foreground and background switching process can be executed by the corresponding switching thread.

[0069] In some embodiments, when the second upper layer is in the background, similar to the first upper layer, a corresponding target node is in a blocked state to keep the second upper layer in the background.

[0070] In some embodiments, when performing the foreground and background switching process, the kernel also needs to determine that the status node of the associated peripheral resource is in an idle state, and unblock the target node corresponding to the second upper layer.

[0071] Exemplarily, the first upper layer sets the status node of the associated peripheral resource to an idle state; when the kernel monitors that the status node of the peripheral resource is in an idle state, the kernel unblocks the second target node of the second upper layer.

[0072] In an embodiment of the present application, the second target node may be a / proc / dev_ns / wait_for_switch node.

[0073] When the first upper layer determines that the first target node is unblocked, it can directly change the state node of the associated peripheral resource and change the running state to the idle state. The running state can also be called a busy state.

[0074] Exemplarily, taking the Bluetooth module as an example, when associating with the first upper layer, the running state of the state node of the Bluetooth module can be represented by 1, and the first upper layer can change the state of the state node from 1 to 0, from the running state to the idle state.

[0075] Optionally, the state of the peripheral resource may also be set by the peripheral resource itself after receiving a notification from the first upper layer.

[0076] When the kernel monitors the peripheral resource state node as idle through the monitoring thread, the second upper layer can unblock the second target node. When the second upper layer determines that the second target node is unblocked, the second upper layer enters the foreground and background switching process.

[0077] In the embodiment of the present application, unblocking the second target node of the second upper layer may also be changing the state of the second target node, and the state of the second target node may also be represented by numbers, characters, etc.

[0078] The manner of unblocking the second target node of the second upper layer is similar to the manner of unblocking the first target node of the first upper layer, and will not be described in detail here.

[0079] When the first upper layer and the second upper layer enter the foreground and background switching process, the foreground and background switching is performed. Since the foreground no longer releases the associated peripheral resources during the switching process, the first upper layer and the second upper layer can quickly complete the switching operation, greatly reducing the switching time of the foreground and background operating systems. From the user's perspective, the switching of the foreground and background operating systems is very fast, thereby improving the user's experience.

[0080] S203: The first upper layer releases the occupied peripheral resources of the terminal device in the background.

[0081] In an embodiment of the present application, when the first upper layer switches to the background, it can release the occupied peripheral resources of the terminal device.

[0082] Releasing the occupied peripheral resources of the terminal device may be by disconnecting the thread interaction with the peripheral resources. For specific implementation methods, reference may be made to the implementation methods in the prior art, which will not be elaborated in the embodiments of the present application.

[0083] S204: The second upper layer associates the peripheral resources of the terminal device in the foreground.

[0084] In the embodiment of the present application, when the second upper layer switches to the foreground, after determining that the first upper layer releases the peripheral resources of the terminal device occupied, the second upper layer associates the peripheral resources of the terminal device in the foreground. The method of associating the peripheral resources is similar to the method of releasing the peripheral resources, which will not be repeated here.

[0085] The operating system switching method provided by the embodiment of the present application is to unblock the first target node of the first upper layer by the kernel in response to the monitored switching operation of the first upper layer; the first upper layer switches between the foreground and the background with the second upper layer without releasing the occupied peripheral resources of the terminal device; the first upper layer releases the occupied peripheral resources of the terminal device in the background; the second upper layer associates the peripheral resources of the terminal device in the foreground. In the switching process, the first upper layer no longer executes the release of the associated peripheral resources, and the first upper layer and the second upper layer can quickly complete the switching operation, greatly reducing the switching time of the foreground and background operating systems.

[0086] Based on the above embodiments, Figure 3 The operating system switching method provided in the embodiment of the present application is further explained.

[0087] Figure 3 Schematic diagram of the operating system switching method provided in the embodiment of the present application Figure 2 ,like Figure 3 As shown, including:

[0088] S301. In response to a monitored first upper layer switching operation, the kernel unblocks a first target node of a first upper layer.

[0089] S302: The first upper layer sets the state node of the associated peripheral resource to an idle state.

[0090] In the embodiment of the present application, the specific implementation method shown in S301 and S302 is the same as Figure 2 The specific implementation method of the illustrated embodiment is similar and will not be repeated here.

[0091] In some embodiments, before the first upper layer sets the status node of the associated peripheral resource to an idle state, the first upper layer further includes the following steps:

[0092] Exemplarily, the first upper layer determines that the state node of the peripheral resource is an unexecuted state transition.

[0093] Taking the Bluetooth module as an example, the corresponding states may include open, closed, opening, closing, opening, and closing. The state of the corresponding state node can be an execution state transition. When the first upper layer changes the execution state node, it can wait for the execution state transition to be completed, that is, wait for the peripheral resources to process in a steady state.

[0094] S303: When the kernel monitors that the status node of the peripheral resource is in an idle state, the second target node of the second upper layer is unblocked.

[0095] S304: The first upper layer and the second upper layer are switched between foreground and background.

[0096] In the embodiment of the present application, the specific implementation method shown in S303 and S304 is the same as Figure 2 The specific implementation method of the illustrated embodiment is similar and will not be repeated here.

[0097] S305. The second upper layer sends a first target message to the first upper layer.

[0098] S306: When the first upper layer receives the first target message sent by the second upper layer, the first upper layer releases the occupied peripheral resources in the background.

[0099] In this embodiment of the present application, the first target message is used to instruct the first upper layer to release occupied peripheral resources.

[0100] When the second upper layer switches to the foreground, it can send the first target message to the first upper layer.

[0101] In some embodiments, the second upper layer may send the first target message to the first upper layer by way of inter-domain communication.

[0102] Exemplarily, the second upper layer sends the first target message to the first upper layer through a root domain.

[0103] In the embodiment of the present application, the upper layer in the foreground can be called the foreground domain, and the upper layer in the background can be called the background domain.

[0104] When the terminal device is started, the foreground domain and the background domain establish an information transmission channel through the root domain. When the second upper layer switches to the foreground, a first target message can be generated and sent to the root domain. When the root domain receives the first target message, the first target message can be forwarded to the first upper layer through the transmission channel.

[0105] When the first upper layer receives the first target message forwarded by the root domain, it releases the occupied peripheral resources in the background.

[0106] S307: The first upper layer sends a second target message to the second upper layer.

[0107] S308. When the second upper layer receives the second target message sent by the first upper layer, it associates the peripheral resource in the foreground and updates the state node of the peripheral resource to the running state.

[0108] In an embodiment of the present application, when the first upper layer completes releasing the occupied peripheral resources, a second target message can be sent to the second upper layer through the root domain.

[0109] The second target message is used to instruct the second upper layer to associate with the peripheral resource. The first upper layer sends the second target message to the second upper layer through the root domain in a similar manner to the second upper layer sending the first target message to the first upper layer through the root domain.

[0110] In some embodiments, the root domain may forward messages between the first upper layer and the second upper layer by means of hyperlinks.

[0111] Exemplarily, a HAL service is run in the root domain, and the root domain forwards messages between the first upper layer and the second upper layer through the HAL service.

[0112] HAL is a simple format that provides a consistent and simple method to hyperlink between resources in an interface. By running HAL in the root domain, messages can be easily transmitted between the first upper layer and the second upper layer.

[0113] In an embodiment of the present application, when the second upper layer receives the second target message sent by the first upper layer, it starts to execute the operation of associating the peripheral resources in the foreground, and after associating the peripheral resources, updates the status node of the peripheral resources to the running state.

[0114] The operating system switching method provided in the embodiment of the present application changes the state node of the peripheral resources during the switching process, thereby converting the resource release process of the foreground operating system into resource release in the background after the system switching is completed. This can effectively improve the system switching speed and increase the system switching speed to sub-second level (650ms) under no-load conditions, greatly improving the user experience.

[0115] Based on the above embodiments, the embodiments of the present application also provide a terminal device.

[0116] Figure 4 A schematic diagram of the structure of the terminal device 40 provided in the embodiment of the present application is shown in FIG. Figure 4 As shown, the terminal device runs a first operating system and a second operating system, the first operating system and the second operating system share a kernel, the first upper layer of the first operating system runs in the foreground, and the second upper layer of the second operating system runs in the background:

[0117] The kernel 401 is configured to unblock the first target node of the first upper layer in response to a monitored first operating system switching operation.

[0118] The first upper layer 402 is used to switch between the foreground and the background with the second upper layer without releasing the occupied peripheral resources of the terminal device, and to release the occupied peripheral resources of the terminal device in the background.

[0119] The second upper layer 403 is used to associate the peripheral resources of the terminal device in the foreground.

[0120] Optionally, the first upper layer 402 is used to set the status node of the associated peripheral resource to an idle state.

[0121] Optionally, the kernel 401 is used to unblock the second target node of the second upper layer when it is detected that the status node of the peripheral resource is in an idle state.

[0122] Optionally, the first upper layer 402 is used to release the occupied peripheral resources in the background when receiving the first target message sent by the second upper layer.

[0123] Optionally, the system further includes: a root domain 404.

[0124] Optionally, the second upper layer 403 is used to send the first target message to the first upper layer through the root domain 404.

[0125] Optionally, the first upper layer 402 is used to send a second target message to the second upper layer through the root domain when the peripheral resource release is completed.

[0126] Optionally, the second upper layer 403 is used to associate the peripheral resource in the foreground when receiving the second target message, and update the state node of the peripheral resource to a running state.

[0127] Optionally, the root domain 404 is used to forward messages between the first upper layer and the second upper layer through the HAL service.

[0128] Optionally, the first upper layer 402 is used to determine that the state node of the peripheral resource is an unexecuted state transition.

[0129] The terminal device provided in the embodiment of the present application can execute the technical solution of the operating system switching method embodiment provided in any of the above embodiments, and its principles and technical effects are similar, which will not be repeated here.

[0130] An embodiment of the present application also provides a terminal device.

[0131] Figure 5 A schematic diagram of the structure of a terminal device 50 provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, including:

[0132] Processor 501.

[0133] The memory 502 is used to store executable instructions of the terminal device.

[0134] Specifically, the program may include program codes, and the program codes include computer operation instructions. The memory 502 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory.

[0135] The processor 501 is used to execute the computer-executable instructions stored in the memory 502 to implement the technical solution of the operating system switching method embodiment described in the aforementioned method embodiment.

[0136] The processor 501 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application.

[0137] Optionally, the electronic device 50 may further include a communication interface 503, so that communication interaction can be performed with an external device through the communication interface 503. The external device may be, for example, a user terminal (e.g., a mobile phone, a tablet). In a specific implementation, if the communication interface 503, the memory 502, and the processor 501 are implemented independently, the communication interface 503, the memory 502, and the processor 501 may be interconnected through a bus and communicate with each other.

[0138] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc., but it does not mean that there is only one bus or one type of bus.

[0139] Optionally, in a specific implementation, if the communication interface 503, the memory 502 and the processor 501 are integrated on a chip, the communication interface 503, the memory 502 and the processor 501 can communicate through an internal interface.

[0140] In an embodiment of the present application, a computer-readable storage medium is also provided, on which a computer program is stored. When the computer program is executed by a processor, the technical solution of the above-mentioned operating system switching method embodiment is implemented. The implementation principle and technical effect are similar and will not be repeated here.

[0141] In one possible implementation, a computer-readable medium may include a random access memory (RAM), a read-only memory (ROM), a compact disc read-only memory (CD-ROM) or other optical disk storage, a magnetic disk storage or other magnetic storage device, or any other medium that is intended to carry or store the required program code in the form of instructions or data structures and can be accessed by a computer. Moreover, any connection is appropriately referred to as a computer-readable medium. For example, if the software is transmitted from a website, server or other remote source using a coaxial cable, a fiber optic cable, a twisted pair, a digital subscriber line (DSL) or wireless technologies such as infrared, radio and microwave, then the coaxial cable, fiber optic cable, twisted pair, DSL or wireless technologies such as infrared, radio and microwave are included in the definition of the medium. Disks and optical disks as used herein include optical disks, laser disks, optical disks, digital versatile disks (DVDs), floppy disks and Blu-ray disks, where disks usually reproduce data magnetically, while optical disks reproduce data optically using lasers. Combinations of the above should also be included within the scope of computer-readable media.

[0142] A computer program product is also provided in an embodiment of the present application, including a computer program. When the computer program is executed by a processor, the technical solution of the above-mentioned operating system switching method embodiment is implemented. The implementation principle and technical effect are similar and will not be repeated here.

[0143] In the specific implementation of the above-mentioned terminal device or server, it should be understood that the processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. The general-purpose processor can be a microprocessor or the processor can be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as being executed by a hardware processor, or can be executed by a combination of hardware and software modules in the processor.

[0144] Those skilled in the art will appreciate that all or part of the steps of any of the above method embodiments may be completed by hardware associated with program instructions. The aforementioned program may be stored in a computer-readable storage medium, and when the program is executed, all or part of the steps of the above method embodiments are executed.

[0145] If the technical solution of the present application is implemented in the form of software and sold or used as a product, it can be stored in a computer-readable storage medium. Based on such an understanding, all or part of the technical solution of the present application can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a computer program or several instructions. The computer software product enables a computer device (which can be a personal computer, a server, a network device, or a similar electronic device) to perform all or part of the steps of the method described in the embodiment of the present application.

[0146] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required by the present application.

[0147] It should be further noted that, although the various steps in the flowchart are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowchart may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of the sub-steps or stages of other steps.

[0148] It should be understood that the above system embodiments are only illustrative, and the system of the present application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units, modules or components can be combined, or can be integrated into another system, or some features can be ignored or not executed.

[0149] In addition, unless otherwise specified, each functional unit / module in each embodiment of the present application may be integrated into one unit / module, each unit / module may exist physically separately, or two or more units / modules may be integrated together. The above-mentioned integrated unit / module may be implemented in the form of hardware or in the form of a software program module.

[0150] If the integrated unit / module is implemented in the form of hardware, the hardware may be a digital circuit, an analog circuit, etc. The physical implementation of the hardware structure includes but is not limited to transistors, memristors, etc. If not specifically stated, the processor may be any appropriate hardware processor, such as a CPU, a GPU, an FPGA, a DSP, an ASIC, etc. If not specifically stated, the storage unit may be any appropriate magnetic storage medium or magneto-optical storage medium, such as a resistive random access memory RRAM (Resistive Random Access Memory), a dynamic random access memory DRAM (Dynamic Random Access Memory), a static random access memory SRAM (Static Random-Access Memory), an enhanced dynamic random access memory EDRAM (Enhanced Dynamic Random Access Memory), a high-bandwidth memory HBM (High-Bandwidth Memory), a hybrid memory cube HMC (Hybrid Memory Cube), etc.

[0151] If the integrated unit / module is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.

[0152] In the above embodiments, the description of each embodiment has its own emphasis. For the part not described in detail in a certain embodiment, please refer to the relevant description of other embodiments. The technical features of the above embodiments can be combined arbitrarily. In order to make the description concise, all possible combinations of the technical features in the above embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0153] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. A method for switching an operating system, characterized in that: Applied to a terminal device, the terminal device runs a first operating system and a second operating system, the first operating system and the second operating system share a kernel, a first upper layer of the first operating system runs in the foreground, and a second upper layer of the second operating system runs in the background, the method includes: The kernel, in response to the monitored first upper layer switching operation, unblocks the first target node of the first upper layer; The first upper layer switches between the foreground and background with the second upper layer without releasing the peripheral resources of the terminal device occupied; The first upper layer releases the occupied peripheral resources of the terminal device in the background; The second upper layer is associated with the peripheral resources of the terminal device in the foreground.

2. The method according to claim 1, characterized in that Before performing the foreground and background switching with the second upper layer, the method further includes: The first upper layer sets the state node of the associated peripheral resource to an idle state; When the kernel monitors that the state node of the peripheral resource is in an idle state, the blocking of the second target node of the second upper layer is unblocked.

3. The method according to claim 2, characterized in that The method further comprises: When the first upper layer receives the first target message sent by the second upper layer, the first upper layer releases the occupied peripheral resources in the background.

4. The method according to claim 3, characterized in that: The method further comprises: The second upper layer sends the first target message to the first upper layer through a root domain.

5. The method according to claim 4, characterized in that The method further comprises: When the first upper layer completes releasing the peripheral resource, sending a second target message to the second upper layer through the root domain; When the second upper layer receives the second target message, it associates the peripheral resource in the foreground and updates the state node of the peripheral resource to the running state.

6. The method according to any one of claims 3 to 5, characterized in that: The HAL service is run in the root domain, and the method further comprises: The root domain forwards messages between the first upper layer and the second upper layer through the HAL service.

7. The method according to claim 2, characterized in that: Before the first upper layer sets the state node of the associated peripheral resource to an idle state, the method further includes: The first upper layer determines that the state node of the peripheral resource is an unexecuted state transition.

8. A terminal device, characterized in that: The terminal device runs a first operating system and a second operating system, the first operating system and the second operating system share a kernel, a first upper layer of the first operating system runs in the foreground, and a second upper layer of the second operating system runs in the background; The kernel is configured to unblock the first target node of the first upper layer in response to the monitored first operating system switching operation; The first upper layer is used to switch between the foreground and background with the second upper layer without releasing the occupied peripheral resources of the terminal device, and to release the occupied peripheral resources of the terminal device in the background; The second upper layer is used to associate the peripheral resources of the terminal device in the foreground.

9. A terminal device, characterized in that: include: Memory for storing computer programs; A processor, configured to execute the computer program to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and the computer program is executed by a processor to implement the method according to any one of claims 1 to 7.