Device hibernation method, wireless device, computer device, and storage medium
By configuring delayed sleep times and stop callback interfaces for the service operation events of wireless devices, the problem of high power consumption of the devices is solved, and stable operation of the devices in a low-power state is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHEJIANG DAHUA TECH CO LTD
- Filing Date
- 2026-03-03
- Publication Date
- 2026-06-09
Smart Images

Figure CN122179869A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of device hibernation control, and in particular to device hibernation methods, wireless devices, computer devices, and storage media. Background Technology
[0002] In current monitoring environments in industries such as power, energy, and water conservancy, due to the working environment and power supply conditions of the equipment, it is often required that the equipment can wirelessly transmit data and has low power consumption characteristics.
[0003] To meet low power consumption requirements, related technologies control the device's main controller to enter sleep or power-off state when there are no complex tasks, with only the device modules maintaining signaling interactions with external platforms, such as registration and keep-alive, via wireless transmission. If the device modules have no pending tasks for a certain period, they will also enter a shallow sleep state to reduce power consumption. However, even with this setup, the problem of high power consumption during device operation still exists.
[0004] There is currently no effective solution to the problem of high power consumption in wireless devices in related technologies. Summary of the Invention
[0005] Therefore, it is necessary to provide a device hibernation method, wireless device, computer device, and storage medium that can solve the problem of high power consumption during device operation, in response to the above-mentioned technical problems.
[0006] Firstly, this embodiment provides a device sleep mode method, the method comprising:
[0007] Configure a delayed sleep time for business operation events;
[0008] If the service operation event stops running, the service operation event will be transferred from the service operation event set to the delayed sleep queue;
[0009] If the stop time of the service operation event reaches the delayed sleep time, the service operation event will be removed from the delayed sleep queue.
[0010] When the delayed sleep queue and the service operation event set are empty, the main controller and / or module running the service operation event in the control device enters a sleep state.
[0011] In some embodiments, the method further includes:
[0012] Configure the service stop callback interface and runtime timeout for service operation events;
[0013] If the execution time of the business operation event reaches the execution timeout period, and / or if abnormal information is generated during the execution of the business operation event, the business stop callback interface is invoked to stop the business operation event.
[0014] In some embodiments, the service stop callback interface is configured with an interface timeout period, and after calling the service stop callback interface, the method further includes:
[0015] Determine whether the business operation event has stopped running;
[0016] If the business operation event does not stop and the call time of the business stop callback interface is greater than or equal to the interface timeout time, the execution thread used to call the business stop callback interface shall be terminated.
[0017] In some embodiments, the method further includes, prior to configuring a delayed sleep time for service runtime events:
[0018] Determine the services executed by the service layer of the device, and create service execution events corresponding to the services in the application layer of the device.
[0019] In some embodiments, configuring a delayed sleep time for service operation events includes:
[0020] When the business operation event corresponds to a synchronous business, and the complexity of the execution process of the synchronous business reaches a preset level, the delayed sleep time is configured for the business operation event; and / or,
[0021] When the service operation event corresponds to a synchronous service, and the frequency at which the synchronous service is triggered reaches a preset frequency, the delayed sleep time is configured for the service operation event.
[0022] In some of these embodiments, a delayed sleep time is configured for service operation events, including:
[0023] When the business operation event corresponds to an asynchronous business, the delayed sleep time is configured for the business operation event.
[0024] In some embodiments, if a service operation event without a configured sleep delay time stops running, the service operation event without a configured sleep delay time is removed from the service operation event set.
[0025] Secondly, this embodiment provides a wireless device, the wireless device comprising:
[0026] The configuration module is used to configure the delay sleep time for business operation events;
[0027] The transfer module is used to record the stop time of the service operation event and transfer the service operation event from the service operation event set to the delayed sleep queue when the service operation event stops running.
[0028] The delay module is used to remove the service operation event from the delay sleep queue when the stop time of the service operation event reaches the delay sleep time;
[0029] The hibernation module is used to control the main controller and / or module running the service operation event in the device to enter a hibernation state when the delayed hibernation queue and the service operation event set are empty.
[0030] Thirdly, this embodiment provides a computer device including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the device hibernation method described in the first aspect above.
[0031] Fourthly, this embodiment provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the device hibernation method described in the first aspect above.
[0032] The aforementioned device hibernation method, wireless device, computer device, and storage medium configure a delayed hibernation time for service operation events. Service operation events with a set delayed hibernation time and that have stopped running are transferred from the service operation event set to a delayed hibernation queue. When the stop time of a service operation event reaches the delayed hibernation time, the service operation event is removed from the delayed hibernation queue. When both the delayed hibernation queue and the service operation event set are empty, the main control unit and / or module running the service operation event in the device are controlled to enter a hibernation state. This appropriately delays the time when the main control unit and / or module enters hibernation, reducing power consumption caused by frequent hibernation and wake-up, thereby achieving the effect of reducing the power consumption of the device during operation. Attached Figure Description
[0033] Figure 1 This is a hardware structure block diagram of the terminal for a device sleep method in one embodiment;
[0034] Figure 2 This is a flowchart illustrating a device hibernation method in one embodiment;
[0035] Figure 3 This is a schematic diagram of application layer business operation event management in one embodiment;
[0036] Figure 4 This is a flowchart illustrating the process of creating a business operation event in one embodiment;
[0037] Figure 5 This is a schematic diagram of the normal completion of a service in one embodiment;
[0038] Figure 6 This is a flowchart illustrating the process of handling service timeouts in one embodiment;
[0039] Figure 7 This is a schematic diagram of the service stop callback process in one embodiment;
[0040] Figure 8 This is a schematic diagram of the process of main control or module hibernation in one embodiment;
[0041] Figure 9 This is a block diagram of a wireless device in one embodiment;
[0042] Figure 10 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0043] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0044] During device operation, when a module receives a command from an external platform, it resumes from a shallow sleep state. If the processed service is complex and cannot be handled by the module itself, the module will wake up the main controller and transmit the command to it. The main controller then processes the service and transmits the service data to the external platform via the module. When the main controller's own scheduled task starts, it will also wake up based on the scheduled task and send the data that needs to be transmitted to the external platform to the module. If the module is in a shallow sleep state, it will resume normal operation, receiving data from the main controller and transmitting it to the platform. However, frequent sleep-wake cycles result in significant power consumption.
[0045] Based on this, in one embodiment, a device hibernation method is provided. The method embodiment provided in this embodiment can be executed in a terminal, computer, or similar computing device. For example, it can run on a terminal. Figure 1 This is a hardware structure block diagram of a terminal for a device sleep method according to an embodiment of this application. For example... Figure 1 As shown, a terminal may include one or more ( Figure 1Only one is shown in the diagram. A processor 102 and a memory 104 for storing data are also included. The processor 102 may be, but is not limited to, a microprocessor (MCU) or a programmable logic device (FPGA). The terminal may also include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that… Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the terminal described above. For example, the terminal may also include components that are larger than... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown are illustrated.
[0046] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the device hibernation method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, thereby implementing the above-described method. The memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0047] The transmission device 106 is used to receive or send data via a network. This network includes a wireless network provided by the terminal's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 can be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0048] like Figure 2 As shown, a device sleep method is provided, which is applied to... Figure 1 Taking the equipment in the example, the explanation includes the following steps:
[0049] Step S202: Configure a delayed sleep time for the service operation event.
[0050] Among them, each service operation event corresponds one-to-one with a service executed by the main controller and / or module in the device, and the service operation event is used to track and report the operation status of the service. In related technologies, if the main controller and / or module only runs a certain service, the main controller and / or module that runs the event can enter a sleep state when that service stops running.
[0051] The delayed sleep time is used to postpone the sleep time of the main controller and / or module that ran the service event after it stopped running. The delayed sleep time can be configured according to actual sleep requirements. Optionally, service events can be managed at the device application layer, and corresponding delayed sleep times can be configured for different service events.
[0052] Step S204: If a business operation event stops running, the business operation event is transferred from the business operation event set to the delayed sleep queue.
[0053] The service operation event set is the collection of events executed by the main controller and / or modules in the device. The delayed sleep queue is the collection of service operation events configured with a delayed sleep time, which have stopped running, and whose stop time has not yet reached the delayed sleep time.
[0054] If a business operation event stops running, it can be determined that the corresponding business operation has stopped running. Optionally, when the business layer executes business logic, it calls the application layer interface to create the corresponding business operation event and creates an execution thread for that event in the application layer. The execution thread then runs the corresponding business operation event. The execution status of the execution thread can be used to determine whether the business operation event has stopped running: if the execution thread has completed execution, the business operation event is considered stopped; if the execution thread has not completed execution, the business operation event is considered not stopped.
[0055] Step S206: If the stop time of a service operation event reaches the delayed sleep time, remove the service operation event from the delayed sleep queue.
[0056] The stop time of a service operation event is the length of time between the event stopping and the current moment. Optionally, when a service operation event stops running, the stop time is recorded, and the event is transferred from the service operation event set to a delayed sleep queue. It is then determined whether the stop time of each service operation event in the delayed sleep queue has reached its corresponding delayed sleep time. If yes, the service operation event is removed from the delayed sleep queue; otherwise, it is retained in the delayed sleep queue.
[0057] In step S208, when the delayed sleep queue and the service operation event set are empty, the main controller and / or module running the service operation events in the control device enters a sleep state.
[0058] Optionally, corresponding delayed sleep queues and service operation event sets can be configured for the main controller and modules in the device, respectively. When the delayed sleep queue and service operation event set corresponding to the main controller are empty, the main controller can be controlled to enter a sleep state; similarly, when the delayed sleep queue and service operation event set corresponding to the module are empty, the module can be controlled to enter a sleep state. When a service operation event set requires processing by both the main controller and the module, the service operation event can be added to both the service operation event set and the delayed sleep queue of the main controller and the module simultaneously.
[0059] Optionally, the main controller and modules in the device are configured with a unified delayed sleep queue and service operation event set. When the delayed sleep queue and service operation event set are empty, the main controller and modules of the control device are controlled to synchronously go into sleep.
[0060] Optionally, a sleep lock can be configured for the device's main controller and modules. If the delayed sleep queue is not empty or the service operation event set is not empty, the sleep lock is invoked to prevent the main controller and / or module corresponding to the invoked sleep lock from entering a sleep state. If the delayed sleep queue and the service operation event set are empty, the corresponding sleep lock is released to allow the main controller and / or module corresponding to that sleep lock to enter a sleep state.
[0061] In the aforementioned device hibernation method, by configuring a delayed hibernation time for service operation events, the main control unit and / or module running the corresponding service will not immediately enter hibernation mode after the service operation event stops running. Appropriately delaying the main control unit or module's entry into hibernation avoids repeated entry and exit from the service's running state, preventing frequent hibernation and wake-up of the main control unit and / or module running the service. This reduces power consumption caused by frequent hibernation and wake-up, thereby achieving the effect of reducing device operating power consumption.
[0062] In one embodiment, before configuring a delayed sleep time for a service execution event, the method further includes: determining the service executed by the service layer of the device, and creating a service execution event corresponding to the service in the application layer of the device.
[0063] Service operation events are used to track the operational status of services. When the device is operating normally, the operational status of service operation events responds to changes in the service's operational status. Optionally, service operation events corresponding to services are created at the device application layer using unique identifiers. Service operation events at the application layer allow for the management of services executed by the device.
[0064] In this embodiment, corresponding service operation events are created based on the services executed by the service layer, ensuring that the operation and management of each service running in the device can be performed.
[0065] Furthermore, in one embodiment, configuring a service delay sleep time for a service operation event includes: configuring a delay sleep time for the service operation event when the service operation event corresponds to an asynchronous service.
[0066] The delayed sleep time can be obtained by comparing the time it takes for a business operation event to send a business request to an external platform with the time it takes to receive the data returned by the external platform in response to the business request.
[0067] When the service is asynchronous, it may be in a stopped state while waiting for an external response; after receiving the response, the service will enter the running state. Asynchronous services may repeatedly enter and exit the running state in a short period of time, so the main control and / or module of the device running the service may be frequently woken up.
[0068] In this embodiment, a delayed sleep time is configured for the business operation events corresponding to asynchronous business. This can effectively prevent the main control unit and / or module of the device from frequently sleeping or waking up before and after the business waits for the caller to return the call result, thereby reducing the power consumption of the device.
[0069] In one embodiment, configuring a service stop callback interface and a running timeout for a service operation event includes: configuring a stop callback interface and a running timeout for the service operation event when the service operation event corresponds to a synchronous service and the complexity of the execution process of the synchronous service reaches a preset level; and / or configuring a delayed sleep time for the service operation event when the service operation event corresponds to a synchronous service and the frequency at which the synchronous service is triggered reaches a preset frequency.
[0070] When the business is synchronous, after initiating a business request, the business must wait for the caller to return the call result before executing the subsequent operation process.
[0071] Optionally, the complexity of a business execution process can be characterized by at least one of the following dimensions: the number of execution steps in the process, the number of business scheduling operations, and the number of interactions between the business execution device and external platforms or services. When any one or more dimensions reach the corresponding complexity threshold, the complexity of the business execution process can be considered to have reached a preset level.
[0072] Optionally, the frequency at which synchronous services are triggered is the number of times the service process is activated or executed per unit of time. The preset number of times can be set according to requirements.
[0073] For synchronous services, when the complexity of the execution process of the synchronous service reaches a preset level, and / or when the service operation event corresponds to the synchronous service and the frequency of the synchronous service being triggered reaches a preset frequency, after the service ends, there is a high probability that it will repeatedly enter and exit the running state in a short period of time. Configuring a delayed sleep time for the service operation events corresponding to this type of service can effectively prevent the service operation events from being frequently triggered and effectively reduce the power consumption caused by the device's frequent sleep and wake-up.
[0074] Furthermore, a stop callback interface and a timeout can be configured for at least the following types of business operation events: the business operation event corresponds to a synchronous business and the complexity of the synchronous business execution process reaches a preset level; the business operation event corresponds to a synchronous business and the frequency at which the synchronous business is triggered reaches a preset frequency; the business operation event corresponds to an asynchronous business.
[0075] When the complexity of synchronous business execution processes reaches a preset level, it is easy to cause faults such as process abnormalities, inconsistent states, or execution failures, which may lead to the inability to end the business. Synchronous business processes that are triggered at a preset frequency are repeatedly executed, which has a high probability of abnormality. The operation of asynchronous business processes has uncertain timing and usually involves state changes at multiple points in time. Business abnormalities may easily lead to the inability to end the business. By configuring stop callback interfaces and running timeouts for the business operation events corresponding to these specific business processes, the situation of increased device power consumption caused by the inability to end the business can be avoided.
[0076] In one embodiment, the device hibernation method further includes: configuring a service stop callback interface and a running timeout for the service running event; and calling the service stop callback interface to stop the service running event when the running time of the service running event reaches the running timeout, and / or when abnormal information is generated during the running of the service running event.
[0077] The stop callback interface is used to safely stop services that have timed out. Optionally, a service stop callback interface can be set at the device's service layer. Optionally, calling the service stop callback interface includes: creating an execution thread in an asynchronous thread pool, and then using the execution thread to call the service stop callback interface to safely stop the service execution event. For example, the service stop callback interface set at the service layer can be called through an asynchronous Leader-Follower thread pool.
[0078] The runtime timeout can be set based on the runtime required for a business event to run normally. Optionally, the runtime of the business event is obtained, and if the runtime of the business event is greater than or equal to the runtime timeout, it is determined that the business event has timed out, and the business operation needs to be stopped through the business stop callback interface.
[0079] Exception information is generated and pushed to the application layer by the underlying code corresponding to the business during business operation after it detects an exception in the business operation event.
[0080] If a service fails to stop within the timeout period due to system resource usage errors or other software malfunctions, the device will remain in standby mode for an extended period, consuming excessive power and preventing the main control unit or module from entering sleep mode. In this embodiment, the corresponding service is stopped via a stop callback interface, promptly ending the abnormal service and minimizing device power consumption. Simultaneously, the stop callback interface ensures a safer service exit, reducing the likelihood of data corruption or device malfunctions due to unsafe exits.
[0081] In one embodiment, the business stop callback interface is configured with an interface timeout. After calling the business stop callback interface, the method further includes: determining whether the business running event has stopped running; if the business running event has not stopped and the interface call time of the business stop callback interface is greater than or equal to the interface timeout, terminating the execution thread used to call the business stop callback interface.
[0082] The API call time is the time elapsed from the start of the call to the business stop callback API until a complete response is received. If the business stop callback API remains unresponsive, the call time will continue to increase.
[0083] Different service stop callback interfaces can be configured with different timeout periods. The interface timeout period is used to indicate whether the call to the service stop callback interface has taken too long. The interface timeout period can be set according to the length of time between the start of the call to the service stop callback interface and the stop of the service operation event.
[0084] If the API call time for the business stop callback interface is greater than or equal to the interface timeout time, the business stop callback interface can be considered abnormal. It is understood that if the business execution event stops running, there is no need to terminate the execution thread used to call the aforementioned business stop callback interface.
[0085] In this embodiment, by terminating the execution thread used to call the service stop callback interface for the service running event, the continuous operation of the service stop callback interface and its corresponding service is prevented, which would cause the device's main control and / or module to be unable to enter the sleep state and increase the device's power consumption.
[0086] In one embodiment, if a service running event without a configured sleep delay time stops running, that service running event is removed from the service running event set. Optionally, the service running event without a configured sleep delay time can be a synchronous service that does not require receiving data from an external platform. It is understood that a sleep delay time can be selectively configured for service running events based on application requirements.
[0087] In this embodiment, by directly removing service operation events that have stopped running and have not been configured with a sleep delay time from the service operation event set, the current operation status of the service operation events can be obtained in real time through the service operation event set, thus avoiding the situation where services are still running when the device enters sleep mode.
[0088] In one embodiment, the device sleep method can be applied to a wireless device.
[0089] Specifically, a sleep method for wireless low-power devices is provided. With the main control unit and module providing sleep locks, the application layer provides a way to manage service operation events for the service layer, and performs sleep control operations on the main control unit and module. Figure 3 A schematic diagram of application-layer business operation event management is provided, such as Figure 3 As shown, the application layer can simultaneously manage business operation events 1, 2, ..., N, where N is greater than or equal to 1. At the application layer, each business operation event can be configured with: a unique ID, a timeout period, a service stop callback interface, and a delayed sleep period. The application layer can create, modify, run, and terminate each business operation event. It can also manage collections of business operation events, handle service timeout callbacks, and manage delayed sleep queues; and invoke the sleep lock of the device master controller and / or module through call operations.
[0090] Specifically, the business layer can create corresponding runtime events at the application layer through operation interfaces, based on specific business requirements. These operation interfaces can preset reasonable runtime timeouts for the business runtime events, optionally including settings for a business stop callback interface, a stop callback interface timeout, and a delayed sleep time. If a business stop callback interface timeout is set, a corresponding delayed sleep time can be set, and the delayed sleep time must be greater than or equal to the business stop callback interface timeout.
[0091] For example, the application layer can predefine the runtime time and delayed sleep time of the corresponding service operation events for known services; the application layer manages each service operation event and determines whether the service operation has timed out or is abnormal by comparing the runtime and runtime time of each service operation event. Figure 4 A flowchart illustrating the creation of business execution events is provided, such as... Figure 4 As shown, it includes:
[0092] Step S401: The business layer executes the business logic.
[0093] Step S402: Create the corresponding business operation event at the application layer;
[0094] Step S403: Preset the runtime timeout for the business operation event;
[0095] Step S404: Set the service stop callback interface, interface timeout time, and delayed sleep time.
[0096] Depending on the type of business logic executed by the business layer, it is also possible to omit the business stop callback interface, the stop callback interface timeout, and the delayed sleep time, i.e., step S404 is not executed. The delayed sleep time is greater than or equal to the timeout of the corresponding business stop callback interface.
[0097] If the business layer stops the business, the corresponding business operation event is removed from the business operation event set. If the business layer sets a delayed sleep time, the stop time of the business operation event is recorded, and the stopped business operation event is transferred to the delayed sleep queue. Figure 5 A flowchart illustrating the normal completion of a business process is provided, such as... Figure 5 As shown, it includes:
[0098] Step S501: The business layer stops the business and finds the corresponding business operation event in the application layer's business operation event set by using the business operation event ID.
[0099] Step S502: Determine whether a delayed sleep time has been set for the business operation event; if not, proceed to step S503; if yes, proceed to step S504.
[0100] Step S503: Remove the business operation event from the business operation event set, and the process ends.
[0101] Step S504: Record the stop time of the business operation event, transfer the business operation event to the delayed sleep queue, and end.
[0102] If the business layer fails to stop the business in a timely manner, when a business operation event times out or an exception occurs, if the business layer has set a business stop interface, the business stop callback interface set by the business layer will be called through the asynchronous Leader-Follower thread pool to safely stop the timed-out or exception-prone business. Figure 6 A flowchart illustrating the process of handling business timeouts is provided, such as... Figure 6 As shown, it includes:
[0103] Step S601: Business operation event timeout or exception.
[0104] Step S602: Determine whether a service stop callback interface has been set for the service operation event; if yes, proceed to step S603; if no, proceed to step S604.
[0105] Step S603: Call the business stop callback interface through the asynchronous Leader-Follower thread pool;
[0106] Step S604: Determine whether a delayed sleep time has been set for the business operation event; if not, proceed to step S605; if yes, proceed to step S606.
[0107] Step S605: Remove the business operation event from the business operation event set.
[0108] Step S606: Record the stop time of the business operation event and transfer the business operation event to the delayed sleep queue.
[0109] After transferring the business operation event to the delayed sleep queue, the application layer determines whether to remove the business operation event from the delayed sleep queue based on the stop time and delayed sleep time of the business operation event. Specifically, if the stop time of the business operation event reaches the delayed sleep time, the event is removed from the delayed sleep queue; if the stop time of the business operation event does not reach the delayed sleep time, the event will not be removed from the delayed sleep queue.
[0110] If the execution thread of the business stop callback interface does not terminate normally, the asynchronous Leader-Follower thread pool will determine whether to terminate the corresponding thread based on the interface call time of the business stop callback interface; at the same time, if the business layer sets a delayed sleep time, it will record the stop time of the business running event and transfer the stopped business running event to the delayed sleep queue. Figure 7 A flowchart illustrating the business stop callback process is provided, such as... Figure 7 As shown, it includes:
[0111] Step S701: The business operation event times out or is abnormal, and a business stop interface is set.
[0112] Step S702: Create an execution thread using an asynchronous Leader-Follower thread pool.
[0113] Step S703: The execution thread calls the business stop callback interface.
[0114] Step S704: Determine whether an interface timeout period for the business stop callback interface has been set; if yes, proceed to step S705; if no, proceed to step S708.
[0115] Step S705: Determine whether the call time of the business stop callback interface is greater than or equal to the interface timeout time; if yes, proceed to step S707; if no, proceed to step S706.
[0116] Step S706: Determine whether the service stop callback interface has ended normally; if yes, proceed to step S707; otherwise, proceed to step S705.
[0117] Step S707: Destroy the execution thread.
[0118] Step S708: The execution thread terminates and exits normally.
[0119] When the set of business operation events is empty and the delayed sleep queue is empty, it means that no business is running in the current business layer and has been delayed according to the requirements of each business. At this time, the main controller and / or module can enter the sleep state. Figure 8 A flowchart illustrating the process of main controller or module hibernation is provided, such as... Figure 8 As shown, it includes:
[0120] Step S801: Determine if the set of running events is empty. If yes, proceed to step S802; otherwise, continue waiting for further determination.
[0121] Step S802: Determine if the delayed sleep queue is empty. If yes, proceed to step S803; otherwise, proceed to step S801.
[0122] Step S803: The main controller or module can enter sleep mode, and the process ends.
[0123] By providing a sleep lock in the module, and combining it with specific business operations, the corresponding business operation events are managed to prevent the main controller or module from being unable to enter sleep mode due to errors in system resource usage or other software errors. At the same time, the business can exit as safely as possible and reduce power consumption caused by frequent sleep and wake-up, thereby reducing the overall power consumption of the main controller and module.
[0124] Based on the same inventive concept, this application also provides a wireless device for implementing the device sleep method described above. The solution provided by this wireless device is similar to the implementation described in the above method; therefore, the specific limitations in one or more wireless device embodiments provided below can be found in the limitations of the device sleep method described above, and will not be repeated here.
[0125] In one embodiment, such as Figure 9 As shown, a wireless device is provided, comprising:
[0126] The configuration module is used to configure the delay sleep time for business operation events;
[0127] The transfer module is used to record the stop time of a business operation event and transfer the business operation event from the business operation event set to the delayed sleep queue when the business operation event stops running.
[0128] The delay module is used to remove business operation events from the delayed sleep queue when the stop time of the business operation event reaches the delayed sleep time.
[0129] The hibernation module is used to control the main controller and / or modules running business operation events in the device to enter hibernation state when the delayed hibernation queue and the business operation event set are empty.
[0130] In one embodiment, the wireless device further includes a stop module, which is used to configure a service stop callback interface and a running timeout for the service running event; when the running time of the service running event reaches the running timeout, and / or when abnormal information is generated during the running of the service running event, the service stop callback interface is called to stop the service running event.
[0131] In one embodiment, the business stop callback interface is configured with an interface timeout. After calling the business stop callback interface, the stop module is also used to determine whether the business running event has stopped running. If the business running event has not stopped and the interface call time of the business stop callback interface is greater than or equal to the interface timeout, the execution thread used to call the business stop callback interface is terminated.
[0132] In one embodiment, before configuring a delayed sleep time for a service operation event, the configuration module is also used to: determine the service executed by the device's service layer, and create a service operation event corresponding to the service in the device's application layer.
[0133] Optionally, the configuration module configures a delayed sleep time for the business operation event, including: configuring a delayed sleep time for the business operation event when the business operation event corresponds to an asynchronous business.
[0134] Optionally, the configuration module configures a delayed sleep time for the service operation event, including: configuring a delayed sleep time for the service operation event when the service operation event corresponds to a synchronous service and the complexity of the execution process of the synchronous service reaches a preset level; and / or configuring a delayed sleep time for the service operation event when the service operation event corresponds to a synchronous service and the frequency at which the synchronous service is triggered reaches a preset frequency.
[0135] In one embodiment, the delay module is further configured to remove the service operation event without configured delay sleep time from the service operation event set when the service operation event without configured delay sleep time stops running.
[0136] Each module in the aforementioned wireless device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0137] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 10 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data related to operational events. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When executed by the processor, the computer program implements a device hibernation method.
[0138] Those skilled in the art will understand that Figure 10 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0139] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0140] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above method embodiments.
[0141] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0142] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0143] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are 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.
[0144] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for putting a device into sleep mode, characterized in that, The method includes: Configure a delayed sleep time for business operation events; If the service operation event stops running, the service operation event will be transferred from the service operation event set to the delayed sleep queue; If the stop time of the service operation event reaches the delayed sleep time, the service operation event will be removed from the delayed sleep queue. When the delayed sleep queue and the service operation event set are empty, the main controller and / or module running the service operation event in the control device enters a sleep state.
2. The method according to claim 1, characterized in that, The method further includes: Configure the service stop callback interface and runtime timeout for service operation events; If the execution time of the business operation event reaches the execution timeout period, and / or if abnormal information is generated during the execution of the business operation event, the business stop callback interface is invoked to stop the business operation event.
3. The method according to claim 2, characterized in that, The service stop callback interface is configured with an interface timeout period. After calling the service stop callback interface, the method further includes: Determine whether the business operation event has stopped running; If the business operation event does not stop and the call time of the business stop callback interface is greater than or equal to the interface timeout time, the execution thread used to call the business stop callback interface shall be terminated.
4. The method according to claim 1, characterized in that, Before configuring a delayed sleep time for business operation events, the method further includes: Determine the services executed by the service layer of the device, and create service execution events corresponding to the services in the application layer of the device.
5. The method according to claim 1 or 4, characterized in that, Configuring a delayed sleep time for service operation events includes: When the business operation event corresponds to a synchronous business, and the complexity of the execution process of the synchronous business reaches a preset level, the delayed sleep time is configured for the business operation event; and / or, When the service operation event corresponds to a synchronous service, and the frequency at which the synchronous service is triggered reaches a preset frequency, the delayed sleep time is configured for the service operation event.
6. The method according to claim 1 or 4, characterized in that, Configuring a delayed sleep time for service operation events includes: When the business operation event corresponds to an asynchronous business, the delayed sleep time is configured for the business operation event.
7. The method according to claim 1, characterized in that, The method further includes: If a service operation event without a configured sleep delay time stops running, the service operation event without a configured sleep delay time will be removed from the service operation event set.
8. A wireless device, characterized in that, The wireless device includes: The configuration module is used to configure the delay sleep time for business operation events; The transfer module is used to record the stop time of the service operation event and transfer the service operation event from the service operation event set to the delayed sleep queue when the service operation event stops running. The delay module is used to remove the service operation event from the delay sleep queue when the stop time of the service operation event reaches the delay sleep time; The hibernation module is used to control the main controller and / or module running the service operation event in the device to enter a hibernation state when the delayed hibernation queue and the service operation event set are empty.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.