CN117093278B - Kernel shutdown method, electronic device and storage medium - Google Patents

Kernel shutdown method, electronic device and storage medium Download PDF

Info

Publication number
CN117093278B
CN117093278B CN202311330202.8A CN202311330202A CN117093278B CN 117093278 B CN117093278 B CN 117093278B CN 202311330202 A CN202311330202 A CN 202311330202A CN 117093278 B CN117093278 B CN 117093278B
Authority
CN
China
Prior art keywords
module
kernel
shutdown
battery
functional module
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202311330202.8A
Other languages
Chinese (zh)
Other versions
CN117093278A (en
Inventor
杜凡起
戚艳刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Honor Device Co Ltd
Original Assignee
Honor Device Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Honor Device Co Ltd filed Critical Honor Device Co Ltd
Priority to CN202311330202.8A priority Critical patent/CN117093278B/en
Publication of CN117093278A publication Critical patent/CN117093278A/en
Application granted granted Critical
Publication of CN117093278B publication Critical patent/CN117093278B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/442Shutdown
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/26Power supply means, e.g. regulation thereof
    • G06F1/263Arrangements for using multiple switchable power supplies, e.g. battery and AC
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/26Power supply means, e.g. regulation thereof
    • G06F1/32Means for saving power
    • G06F1/3203Power management, i.e. event-based initiation of a power-saving mode
    • G06F1/3206Monitoring of events, devices or parameters that trigger a change in power modality
    • G06F1/3212Monitoring battery levels, e.g. power saving mode being initiated when battery voltage goes below a certain level

Abstract

The application provides a kernel shutdown method, electronic equipment and a storage medium. The method is applied to the battery-powered electronic equipment, when the battery enters a low-voltage and low-voltage state, if the target functional module determines that the triggering condition of the kernel shutdown module is met currently, the target functional module applies for a thread lock of the kernel shutdown module, and the target functional module can trigger the kernel shutdown module to execute the kernel shutdown process only when the thread lock of the kernel shutdown module is successfully held. Therefore, the Linux kernel shutdown process of the electronic device cannot generate the reentry problem, and the electronic device cannot generate the panic problem in a low-voltage and low-voltage state due to the reentry of the Linux kernel shutdown process.

Description

Kernel shutdown method, electronic device and storage medium
Technical Field
The application relates to the technical field of intelligent terminals, in particular to a kernel shutdown method, electronic equipment and a storage medium.
Background
Under the condition that the electronic equipment such as a mobile phone, a tablet and the like is not connected with a charger for charging, when the equipment electric quantity is lower than a preset electric quantity, for example, the equipment electric quantity is lower than 2%, the electronic equipment enters a low-electric state. Subsequently, the machine is automatically turned off after a short period of time, for example, after 30 seconds.
In the process of automatic shutdown of the device, a Linux Kernel (Kernel) is a process that needs to be executed for security of a device system. Once the shutdown flow of the Linux kernel is abnormal, the device is restarted abnormally (panic), and the stability of the whole device is affected.
Disclosure of Invention
In view of this, the present application provides a kernel shutdown method, an electronic device, and a storage medium. The method can avoid the problem of abnormal restarting (panic) of the electronic equipment in a low-power state due to reentry of the shutdown process of the Linux kernel, and improves the shutdown stability of the electronic equipment in the low-power state.
In a first aspect, an embodiment of the present application provides a kernel shutdown method. The method is applied to the electronic equipment, and the electronic equipment is powered by a battery. Wherein the method comprises the following steps:
when the battery meets the low-voltage and low-voltage condition, a first functional module of the electronic equipment determines that a first triggering condition of a kernel shutdown module is met currently; the first functional module applies for a thread lock of the kernel shutdown module, and the application result is that the thread lock is successfully held; the first functional module triggers the kernel shutdown module to execute a kernel shutdown process.
For example, the low voltage condition may be that the remaining capacity of the battery is less than a preset threshold.
As another example, the low voltage condition may be that the remaining percentage of the battery is not greater than a preset percentage, such as 2%.
In this embodiment, the kernel shutdown module is configured to implement a Linux kernel shutdown procedure. In one particular implementation, the Kernel shutdown module is configured to execute a kernel_power_off function.
In this embodiment, the thread lock of the kernel shutdown module is configured to provide a mechanism for ensuring that only one thread accesses or triggers the kernel shutdown module to execute the kernel shutdown procedure at the same time.
In this way, by setting the thread lock of the kernel shutdown module, only one functional module can trigger the kernel shutdown module to execute the kernel shutdown process, so that the problem of abnormal restarting (panic) of the electronic equipment due to reentry of the Linux kernel shutdown process in a low-power state is avoided, and the shutdown stability of the electronic equipment in the low-power state is improved.
According to a first aspect, a first functional module of an electronic device determines, at a first time, that a first trigger condition of a kernel shutdown module is currently satisfied. Wherein the method further comprises:
after the electric quantity of the battery is lower than a first threshold value, a second functional module of the electronic equipment determines that a second triggering condition of the kernel shutdown module is met at a second moment; the first moment is earlier than the second moment, and the time interval between the first moment and the second moment is smaller than a preset threshold value; the second functional module applies for a thread lock of the kernel shutdown module, and the application result is that the thread lock is failed to be held; the process flow of the second functional module ends.
Therefore, by setting the thread lock of the kernel shutdown module, only one functional module can trigger the kernel shutdown module to execute the kernel shutdown process. If the second functional module cannot apply for the thread lock of the kernel shutdown module, the fact that other functional modules trigger the kernel shutdown module is indicated, the processing flow of the second functional module is ended, and the problem that the electronic equipment is abnormally restarted (panic) due to the fact that the Linux kernel shutdown flow is restarted in a low-power state is avoided.
According to a first aspect, or any implementation manner of the first aspect, the first functional module is a functional module in an application framework layer, and the second functional module is a functional module in a kernel layer.
Illustratively, the first functional module is a battery service in the application framework layer and the second functional module is an ADSP functional module in the kernel layer.
Therefore, the kernel shutdown module can be prevented from being triggered repeatedly by the application program framework layer functional module and the kernel layer functional module, the problem that the Linux kernel shutdown process is repeatedly entered is avoided, and the shutdown stability of the electronic equipment in a low-power state is improved.
According to the first aspect, or any implementation manner of the first aspect, after the electric quantity of the battery is lower than a first threshold, the first function module of the electronic device determines, at a first time, that a first trigger condition of the kernel shutdown module is currently met, including:
After the electric quantity of the battery is lower than a first threshold value, the first functional module broadcasts a shutdown event, and the shutdown event is used for indicating each device module in the electronic equipment to execute a power-down operation;
the method comprises the steps that powering-off operation is completed for each device module in the electronic equipment at a first moment, and a first functional module determines that a first triggering condition of a kernel shutdown module is met at present at the first moment;
after the electric quantity of the battery is lower than the first threshold value, the second functional module of the electronic equipment determines that the second triggering condition of the kernel shutdown module is met at the second moment, and the method comprises the following steps:
after the electric quantity of the battery is lower than a first threshold value, the second functional module starts a delay operation, and the delay operation is used for triggering the kernel shutdown module to execute a kernel shutdown process when the delay timing is finished;
and when the delay time of the delay operation at the second moment is ended, the second functional module determines that the second triggering condition of the kernel shutdown module is met at the second moment.
In this way, in order to ensure the integrity of the mobile phone shutdown process, when the time-out abnormality occurs in the upper shutdown process, the delay operation started by the kernel layer functional module is used as a standby to trigger the kernel shutdown module. Even if the time when the kernel layer functional module and the application program framework layer functional module need to trigger the kernel shutdown module is close, the Linux kernel shutdown process cannot be repeatedly entered, so that the probability of the panic of the electronic equipment under the condition of low voltage is greatly reduced, and the overall stability of the electronic equipment is improved.
According to a first aspect, or any implementation manner of the first aspect, the first functional module is a functional module in a kernel layer, and the second functional module is a functional module in an application framework layer.
Illustratively, the first functional module is an ADSP functional module in the kernel layer and the second functional module serves the battery in the application framework layer.
According to the first aspect, or any implementation manner of the first aspect, after the electric quantity of the battery is lower than a first threshold, the first function module of the electronic device determines, at a first time, that a first trigger condition of the kernel shutdown module is currently met, including:
after the electric quantity of the battery is lower than a first threshold value, the first functional module starts a delay operation, and the delay operation is used for triggering the kernel shutdown module to execute a kernel shutdown process when the delay timing is finished;
the method comprises the steps that when delay timing of delay operation at a first moment is finished, a first functional module determines that a first triggering condition of a kernel shutdown module is met at the first moment;
after the electric quantity of the battery is lower than the first threshold value, the second functional module of the electronic equipment determines that the second triggering condition of the kernel shutdown module is met at the second moment, and the method comprises the following steps:
After the electric quantity of the battery is lower than a first threshold value, the second functional module broadcasts a shutdown event, and the shutdown event is used for indicating each device module in the electronic equipment to execute a power-down operation;
and the second functional module determines that the second triggering condition of the kernel shutdown module is met at the second moment.
In accordance with the first aspect, or any implementation of the first aspect above, the thread lock is an atomic lock.
In a second aspect, embodiments of the present application provide an electronic device. The electronic device includes: one or more processors; a memory; and one or more computer programs, wherein the one or more computer programs are stored on the memory, which when executed by the one or more processors, cause the electronic device to perform the kernel shutdown method of any of the first aspect and the first aspect.
Any implementation manner of the second aspect and the second aspect corresponds to any implementation manner of the first aspect and the first aspect, respectively. The technical effects corresponding to the second aspect and any implementation manner of the second aspect may be referred to the technical effects corresponding to the first aspect and any implementation manner of the first aspect, which are not described herein.
In a third aspect, embodiments of the present application provide a computer-readable storage medium. The computer readable storage medium comprises a computer program which, when run on an electronic device, causes the electronic device to perform the first aspect and the kernel shutdown method of any of the first aspects.
Any implementation manner of the third aspect and any implementation manner of the third aspect corresponds to any implementation manner of the first aspect and any implementation manner of the first aspect, respectively. The technical effects corresponding to the third aspect and any implementation manner of the third aspect may be referred to the technical effects corresponding to the first aspect and any implementation manner of the first aspect, which are not described herein.
In a fourth aspect, embodiments of the present application provide a computer program product comprising a computer program which, when executed, causes a computer to perform the kernel shutdown method of any of the first aspect or the first aspect.
Any implementation manner of the fourth aspect and any implementation manner of the fourth aspect corresponds to any implementation manner of the first aspect and any implementation manner of the first aspect, respectively. Technical effects corresponding to any implementation manner of the fourth aspect may be referred to the technical effects corresponding to any implementation manner of the first aspect, and are not described herein.
In a fifth aspect, the present application provides a chip comprising processing circuitry, a transceiver pin. Wherein the transceiver pin and the processing circuit communicate with each other via an internal connection path, the processing circuit performing the kernel-down method as in the first aspect or any one of the first aspects to control the receiving pin to receive signals and to control the transmitting pin to transmit signals.
Any implementation manner of the fifth aspect and any implementation manner of the fifth aspect corresponds to any implementation manner of the first aspect and any implementation manner of the first aspect, respectively. Technical effects corresponding to any implementation manner of the fifth aspect may be referred to the technical effects corresponding to any implementation manner of the first aspect, and are not described herein.
Drawings
FIG. 1a is a schematic diagram illustrating a scenario in which an electronic device is automatically powered off due to a low power state;
FIG. 1b is a schematic diagram illustrating a scenario in which an electronic device is automatically powered off due to a low power state;
fig. 2 is a schematic diagram of a hardware structure of an exemplary electronic device;
FIG. 3 is a schematic diagram of a software architecture of an exemplary electronic device;
FIG. 4 is a trigger mode of a kernel shutdown procedure shown in an exemplary manner;
FIG. 5 is a diagram illustrating a kernel shutdown procedure re-triggered scenario;
FIG. 6 is a flowchart of a method for triggering a kernel shutdown procedure according to an exemplary embodiment of the present disclosure;
FIG. 7a is a trigger scenario of the core shutdown procedure illustratively shown;
fig. 7b is a trigger scenario of the core shutdown procedure exemplarily shown.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
The term "and/or" is herein merely an association relationship describing an associated object, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone.
The terms first and second and the like in the description and in the claims of embodiments of the present application are used for distinguishing between different objects and not necessarily for describing a particular sequential order of objects. For example, the first target object and the second target object, etc., are used to distinguish between different target objects, and are not used to describe a particular order of target objects.
In the embodiments of the present application, words such as "exemplary" or "such as" are used to mean serving as examples, illustrations, or descriptions. Any embodiment or design described herein as "exemplary" or "for example" should not be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "such as" is intended to present related concepts in a concrete fashion.
In the description of the embodiments of the present application, unless otherwise indicated, the meaning of "a plurality" means two or more. For example, the plurality of processing units refers to two or more processing units; the plurality of systems means two or more systems.
With the progress of the age, electronic devices such as mobile phones and tablet computers have become indispensable in daily life. Electronic devices such as a mobile phone, a tablet computer and the like provide convenient and quick services for people no matter communication, online shopping, music listening or game playing. However, electronic devices such as mobile phones and tablet computers can perform these functions, and their power supply modes are not separated.
The power supply modes of electronic equipment such as mobile phones, tablet computers and the like mainly comprise two modes, namely battery power supply and switch power supply. Battery powered is the way most electronic devices are currently employed. Generally, a lithium ion battery is adopted, and has the advantages of high energy density, no memory effect, low self-discharge rate and the like. With the use of users, the battery power of electronic devices such as mobile phones and tablet computers is gradually reduced, and the electronic devices are automatically powered off when the battery power of the devices is particularly low.
Taking a mobile phone as an example, fig. 1a illustrates a schematic view of a scenario in which an electronic device is automatically powered off due to a low power (or low battery) state. As shown in fig. 1a (1), the mobile phone display interface 101 includes 20% of the power prompt. With the use of the user, when the electric quantity is reduced from 20% to 2%, the mobile phone enters a low-power state, and at this time, reference can be made to (2) in fig. 1 a. As shown in fig. 1a (2), the mobile phone display interface 102 includes 2% of the power prompt. Because the mobile phone enters the low-power state, the mobile phone display interface 102 can pop up the prompt window 103, and the prompt window 103 is used for prompting the user that the mobile phone is about to be turned off after a short period of time, and the short period of time can be 30s, for example. Illustratively, the prompt message "power is exhausted" is displayed in the prompt window 103, and the handset will be powered off after 30s. Thus, after a short period of time (for example, 30 s) is over, the mobile phone can be automatically turned off so as to ensure the safety of the equipment. For example, after 30s is finished, the mobile phone is in a black screen state of the display screen shown in (3) in fig. 1a after being turned off.
Taking a mobile phone as an example, fig. 1b illustrates another scenario in which an electronic device is automatically powered off due to a low power (or low battery) state. As shown in (1) in fig. 1b, the mobile phone display interface 201 includes 20% of the power prompt. With the use of the user, when the electric quantity is reduced from 20% to 2%, the mobile phone enters a low-power state, and at this time, reference can be made to (2) in fig. 1 b. As shown in fig. 1b (2), the mobile phone display interface 202 includes 2% of the power prompt. When the mobile phone enters a low-power state, the mobile phone runs high-power consumption applications (such as camera applications, etc.), the electric quantity of the mobile phone is fast, and the mobile phone can be directly powered down and turned off and is in a display screen blackout state shown in (3) in fig. 1 b. In this case, the user cannot perceive a shutdown reminder, such as that shown in the reminder window 103 in fig. 1a (2).
The above-mentioned electronic device using battery power may be a mobile phone, a tablet computer, a wearable device, an in-vehicle device, an Augmented Reality (AR)/Virtual Reality (VR) device, a notebook computer, an ultra-mo bile personal computer (UMPC), a netbook, a personal digital assistant (personal digital assistant, PDA), or the like, and the present application does not impose any limitation on the specific type of electronic device.
Fig. 2 is a schematic structural diagram of the electronic device 100. Alternatively, the electronic device 100 may be a terminal, which may also be referred to as a terminal device, and the terminal may be a battery-powered device such as a cellular phone (cellular phone) or a tablet computer (pad), which is not limited in this application. It should be noted that the schematic structural diagram of the electronic device 100 may be applied to the mobile phone in fig. 1a to 1 b. It should be understood that the electronic device 100 shown in fig. 2 is only one example of an electronic device, and that the electronic device 100 may have more or fewer components than shown in the figures, may combine two or more components, or may have different component configurations. The various components shown in fig. 2 may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and/or application specific integrated circuits.
The electronic device 100 may include: processor 110, external memory interface 120, internal memory 121, fuel gauge register 122, universal serial bus (universal serial bus, USB) interface 130, charge management module 140, power management module 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headset interface 170D, sensor module 180, keys 190, motor 191, indicator 192, camera 193, display 194, and subscriber identity module (subscriber identification module, SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor, a gyroscope sensor, an acceleration sensor, a temperature sensor, a motion sensor, a barometric sensor, a magnetic sensor, a distance sensor, a proximity sensor, a fingerprint sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, etc.
The processor 110 may include one or more processing units, such as: the processor 110 may include an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a memory, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and/or a neural network processor (neural-network processing unit, NPU), etc. Wherein the different processing units may be separate devices or may be integrated in one or more processors.
In an embodiment of the present application, the DSP may include an ADSP (Audio digital signal processor ). The processing of the Sensor data may be performed on the ADSP side, for example, the ADSP function module may process the Sensor data in a gap of processing the audio data, so as to reduce power consumption of the main processor.
The controller may be a neural hub and a command center of the electronic device 100, among others. The controller can generate operation control signals according to the instruction operation codes and the time sequence signals to finish the control of instruction fetching and instruction execution.
A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory.
The electronic device 100 may record, via an electricity meter, battery parameters such as battery charge, battery voltage, battery current, battery temperature, etc., measured, counted, or converted by the electricity meter. In some embodiments, the fuel gauge registers may be separately set, as shown in FIG. 2. In other embodiments, the fuel gauge registers may be provided in the processor, such as in the ADSP.
The charge management module 140 is configured to receive a charge input from a charger. The charger can be a wireless charger or a wired charger. In some wired charging embodiments, the charge management module 140 may receive a charging input of a wired charger through the USB interface 130. In some wireless charging embodiments, the charge management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. The charging management module 140 may also supply power to the electronic device 100 through the power management module 141 while charging the battery 142.
The power management module 141 is used for connecting the battery 142, and the charge management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and/or the charge management module 140 and provides power to the processor 110, the internal memory 121, the external memory, the display 194, the camera 193, the wireless communication module 160, and the like. The power management module 141 may also be configured to monitor battery capacity, battery state of health (leakage, impedance), and other parameters. In other embodiments, the power management module 141 may also be provided in the processor 110. In other embodiments, the power management module 141 and the charge management module 140 may be disposed in the same device.
In some embodiments, an electricity meter is included in the power management module 141. The fuel gauge may also be referred to as a coulometer, battery monitor, etc. The fuel gauge may be used to measure, count and convert battery parameters. Battery parameters include, but are not limited to, charge (or residual), battery temperature, operating voltage, battery capacity, and number of charges.
The wireless communication function of the electronic device 100 may be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, a modem processor, a baseband processor, and the like.
The electronic device 100 implements display functions through a GPU, a display screen 194, an application processor, and the like. The GPU is a microprocessor for image processing, and is connected to the display 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
The display screen 194 is used to display images, videos, and the like. The display 194 includes a display panel. In some embodiments, the electronic device 100 may include 1 or N display screens 194, N being a positive integer greater than 1.
The electronic device 100 may implement photographing functions through an ISP, a camera 193, a video codec, a GPU, a display screen 194, an application processor, and the like.
The external memory interface 120 may be used to connect an external memory card, such as a Micro SD card, to enable expansion of the memory capabilities of the electronic device 100. The external memory card communicates with the processor 110 through an external memory interface 120 to implement data storage functions.
The internal memory 121 may be used to store computer executable program code including instructions. The processor 110 executes various functional applications of the electronic device 100 and data processing by executing instructions stored in the internal memory 121. The internal memory 121 may include a storage program area and a storage data area. The storage program area may store an application program (such as a sound playing function, an image playing function, etc.) required for at least one function of the operating system, etc. The storage data area may store data created during use of the electronic device 100 (e.g., audio data, phonebook, etc.), and so on. In addition, the internal memory 121 may include a high-speed random access memory, and may further include a nonvolatile memory such as at least one magnetic disk storage device, a flash memory device, a universal flash memory (universal flash storage, UFS), and the like.
The software system of the electronic device 100 may employ a layered architecture, an event driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. In this embodiment, taking an Android system with a layered architecture as an example, a software structure of the electronic device 100 is illustrated.
Fig. 3 is a software configuration block diagram of the electronic device 100 according to the embodiment of the present application.
The layered architecture of the electronic device 100 divides the software into several layers, each with a distinct role and division of labor. The layers communicate with each other through a software interface. In some embodiments, the Android system is divided into four layers, from top to bottom, an application layer, an application Framework layer, an Zhuoyun row (Android run) and Native system libraries, and a Kernel layer.
The application layer may include a series of application packages. As shown in fig. 3, the application packages may include camera, calendar, map, music, video, gallery, call, navigation, browser, etc. applications.
The application framework layer provides an application programming interface (application programming interface, API) and programming framework for application programs of the application layer. The application framework layer includes a number of predefined functions.
As shown in fig. 3, the application framework layer may include a battery service (BatteryService), a power management service (Power Manager Service, PMS), a window manager, a content provider, a view system, a resource manager, a notification manager, and the like.
The battery service may be used to calculate battery charge related status information, such as a battery remaining charge, a charge level, etc. In this embodiment, the battery service may broadcast a shutdown event when the battery is in a low voltage and low voltage state, so as to notify each module device of power down. The battery service can trigger the kernel shutdown process after the power-down of each module device.
The window manager is used for managing window programs. The window manager can acquire the size of the display screen, judge whether a status bar exists, lock the screen, intercept the screen and the like.
The content provider is used to store and retrieve data and make such data accessible to applications. The data may include video, images, audio, calls made and received, browsing history and bookmarks, phonebooks, etc.
The view system includes visual controls, such as controls to display text, controls to display pictures, and the like. The view system may be used to build applications. The display interface may be composed of one or more views. For example, a display interface including a text message notification icon may include a view displaying text and a view displaying a picture.
The resource manager provides various resources for the application program, such as localization strings, icons, pictures, layout files, video files, and the like.
The notification manager allows the application to display notification information in a status bar, can be used to communicate notification type messages, can automatically disappear after a short dwell, and does not require user interaction. Such as notification information is used to inform that the download is complete, a message alert, etc. The notification information may also be a notification in the form of a chart or scroll bar text appearing in the system top status bar, such as a notification of a background running application, or a notification appearing on the screen in the form of a dialog window. The notification information may be, for example, text information presented in a status bar, a presentation sound emitted, vibration of an electronic device, flashing of an indicator light, or the like.
Android run time includes a core library and virtual machines. Android run is responsible for scheduling and management of the Android system.
The core library consists of two parts: one part is a function which needs to be called by java language, and the other part is a core library of android.
The application layer and the application framework layer run in a virtual machine. The virtual machine executes java files of the application program layer and the application program framework layer as binary files. The virtual machine is used for executing the functions of object life cycle management, stack management, thread management, security and exception management, garbage collection and the like.
The Native system library may include a plurality of functional modules. For example: a health module, a surface manager (surface manager), a Media library (Media Libraries), a three-dimensional graphics processing library (e.g., openGL ES), a 2D graphics engine (e.g., SGL), etc.
In this embodiment of the present application, the health module may also be referred to as a battery health detection module, and may receive the battery related data from the bottom layer downward, and may transmit the battery data information, the status information, and the like to the BatteryService of the Framework layer upward.
The surface manager is used to manage the display subsystem and provides a fusion of 2D and 3D layers for multiple applications.
Media libraries support a variety of commonly used audio, video format playback and recording, still image files, and the like. The media library may support a variety of audio video encoding formats, such as: MPEG4, h.264, MP3, AAC, AMR, JPG, PNG, etc.
The three-dimensional graphic processing library is used for realizing three-dimensional graphic drawing, image rendering, synthesis, layer processing and the like.
The 2D graphics engine is a drawing engine for 2D drawing.
The kernel layer is a layer between hardware and software. The kernel layer at least comprises an ADSP function module, an AP function module, a kernel shutdown module, a display driver and the like. Wherein, the hardware at least comprises AP, ADSP, display screen, sensor, etc.
The ADSP functional module may understand a kernel layer functional module corresponding to the ADSP and is configured to implement a software function related to the ADSP, and the AP functional module may understand a kernel layer functional module corresponding to the AP and is configured to implement a software function related to the AP.
In the ADSP function module, an ADSP side fuel gauge driver may be included for processing the battery related data collected by the fuel gauge to obtain battery parameters including, but not limited to, battery charge, battery voltage, battery current, battery temperature, state of charge, etc. In the embodiment of the application, the ADSP side electricity meter driver can also be used for detecting whether the battery enters a low-voltage low-power state (short for low-voltage state).
The AP function module may also include an AP-side fuel gauge driver for processing the battery-related data collected by the fuel gauge to obtain battery parameters including, but not limited to, battery power, battery voltage, battery current, battery temperature, state of charge, etc. In this embodiment of the present application, the AP function module is configured to transfer the battery parameter obtained by driving the ADSP side fuel gauge to an upper layer.
A Kernel shutdown module may be understood as a functional module corresponding to a Kernel shutdown function (kernel_power_off). Accordingly, triggering the Kernel shutdown module may be understood as executing the Kernel shutdown function kernel_power_off.
It will be appreciated that the layers and components contained in the layers in the software structure shown in fig. 3 do not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, electronic device 100 may include more or fewer layers than shown, and more or fewer components may be included in each layer, as the present application is not limited.
It may be understood that, in order to implement the kernel shutdown method in the embodiment of the present application, the electronic device includes corresponding hardware and/or software modules that perform each function. The steps of an algorithm for each example described in connection with the embodiments disclosed herein may be embodied in hardware or a combination of hardware and computer software. Whether a function is implemented as hardware or computer software driven hardware depends upon the particular application and design constraints imposed on the solution. Those skilled in the art may implement the described functionality using different approaches for each particular application in conjunction with the embodiments, but such implementation is not to be considered as outside the scope of this application.
In the shutdown process of the electronic device, a Linux Kernel (Kernel) is a process that needs to be executed for security of a device system. In general, the Linux kernel shutdown process is triggered by an upper layer. It should be noted that, in the embodiment of the present application, the shutdown procedure of the electronic device is performed when the electronic device enters the low power state.
As shown in fig. 4 (1), the ADSP function module transmits a low voltage interrupt signal and battery-related monitoring data to the AP function module when a low voltage phenomenon occurs in the battery. Among other battery related monitoring data, including but not limited to battery charge, battery power, battery current, battery temperature, battery health status, whether the battery is charged, etc. Illustratively, the fuel gauge driver in the ADSP function module processes the data collected by the relevant sensors to obtain the battery-related monitoring data. Regarding the data processing method of the fuel gauge driving in the ADSP function module and the judgment logic of whether the low voltage phenomenon occurs in the battery, reference may be made to the prior art, and this embodiment is not limited thereto.
After receiving the low-voltage interrupt signal and the battery-related monitoring data, the AP functional module transmits the low-voltage interrupt signal and the battery-related monitoring data to the health module in the Native layer.
The health module monitors the battery event information from the bottom layer downwards, and can transfer the battery related data information to the battery service of the Framework layer upwards. In this embodiment, after receiving the low voltage interrupt signal and the battery related monitoring data transmitted by the AP function module, the healthcare module determines that the battery is in a low voltage and low voltage state, and sends the low voltage and low voltage state of the battery and the battery related monitoring data to the battery service of the frame layer.
After the battery service receives the battery related monitoring data, the battery remaining capacity percentage, the battery level and other information can be calculated, so that the battery information in the application layer (such as the battery remaining capacity percentage displayed on the mobile phone interface or the battery information displayed in the battery manager application) can be updated in time.
The battery service, after receiving the information that the battery is in a low voltage and low voltage state, may send a shutdown event broadcast for a period of time to notify the device modules. For example, the battery service may send a 30s shutdown event broadcast to notify the device modules. Meanwhile, a prompt window is popped up on the display screen of the mobile phone and is used for prompting a user that the mobile phone is about to be turned off after a short period of time (such as 30 s). After each device module is powered down, the battery service triggers the kernel shutdown module to execute the kernel shutdown process. When the battery service triggers the kernel shutdown module, a kernel shutdown function Kernell_power_off function corresponding to the kernel shutdown module is executed. When the kernel_power_off function is executed, the handset completes the shutdown operation completely.
Wherein, before the Kernel shutdown procedure, other shutdown procedures may be referred to as Kernel upper-layer shutdown procedures. In the execution of the Kernel upper shutdown procedure, because the electronic device is in a low-power state, some devices may be directly powered down, so that the upper shutdown procedure has abnormal timeout, and even the upper shutdown procedure cannot be completed.
Referring to fig. 4 (2), in order to ensure the integrity of the mobile phone shutdown process, in the Kernel layer, when the ADSP function module has a low voltage phenomenon in the battery, the ADSP function module starts a delay operation (delay_work), for example, 60s delay_work, for triggering the Kernel shutdown module at the end of the delay timer, and executes the Kernel shutdown function kernerl_power_off function. When the kernel_power_off function is executed, the mobile phone can completely complete the shutdown operation.
That is, in order to ensure the integrity of the mobile phone shutdown process, the ADSP function module starts a delay operation, which is used as a standby to trigger the kernel shutdown module to execute the kernel shutdown function kernerl_power_off function when a timeout exception occurs in the upper shutdown process.
Fig. 5 (1) is a schematic diagram illustrating module interaction involved in the triggering process of the kernel shutdown module. As shown in (1) of fig. 5, the triggering process of the kernel shutdown module includes:
s501, when the low voltage phenomenon occurs in the battery, the ADSP function module sends a low voltage interrupt signal and battery related monitoring data to the AP function module.
Among other battery related monitoring data, including but not limited to battery charge, battery power, battery current, battery temperature, battery health status, whether the battery is charged, etc.
S502, when the low voltage phenomenon of the battery occurs, the ADSP function module starts a 60S delay work for triggering the kernel shutdown module.
And when the 60s delay work timing is finished, the ADSP function module triggers the Kernel shutdown module to execute a Kernel_power_off function.
The present embodiment does not limit the sequential timing of S501 and S502.
S503, the AP function module transmits a low-voltage interrupt signal and battery-related monitoring data to the health module.
S504, the Healthd module sends the battery low voltage status, and the battery related monitoring data, to the battery service.
And the health module is used for determining that the battery is in a low-voltage and low-voltage state after receiving the low-voltage interrupt signal transmitted by the AP function module and the battery related monitoring data, and transmitting the low-voltage and low-voltage state of the battery and the battery related monitoring data to the battery service of the Framework layer.
S505, the battery service transmits a 30S shutdown event broadcast to notify each module device to power down.
And under the pushing of a Kernel upper-layer shutdown flow, each module device executes power-down operation.
S506, after the module devices are powered down, the battery service triggers the Kernel shutdown module to execute a Kernel_Power_off function.
The power-down of each module device can be understood as ending the Kernel upper layer shutdown process.
Where this process is not explained in detail, reference may be made to the foregoing and no further explanation is provided here.
It can be appreciated that in one case, if the battery service triggers the Kernel shutdown module to execute the kernel_power_off function before the 60s delay work timer is finished, and the kernel_power_off function is executed, the mobile phone can be completely shut down. The complete shutdown of the mobile phone can be understood as the end of the last shutdown process of the mobile phone. In another case, if the 60s delay work timer is over, the Kernel shutdown module is not triggered by the battery service to execute the kernel_power_off function, and the ADSP function module triggers the Kernel shutdown module to execute the kernel_power_off function, and the kernel_power_off function is executed, so that the mobile phone can be completely shutdown.
With continued reference to fig. 5 (2), in a critical state, the battery service triggers the Kernel shutdown module to execute the kernel_power_off function at time T1, and the ADSP function module triggers the Kernel shutdown module to execute the kernel_power_off function at time T2, where the interval between time T1 and time T2 is smaller, for example, smaller than a preset threshold, and even time T1 and time T2 are the same or almost the same.
In this way, the Kernel shutdown module is repeatedly triggered, so that the kernel_power_off function cannot be successfully executed, the Kernel layer reports errors to enable the mobile phone to be restarted abnormally (panic), and the user side senses that the mobile phone is restarted at low power. Here, panic is a restart caused by an exception in Kernel layer, and cannot be found in aplog, and it is necessary to analyze stacks from Kernel log or grab dump log for analysis. Once the device has a pack at a low power, the stability of the whole device is necessarily affected, and even loss of a battery or part of devices may occur.
In order to avoid the problem of abnormal restarting (panic) of the electronic equipment in a low-power state due to reentry of a Linux kernel shutdown process, the embodiment of the application provides a kernel shutdown method. In the method, the judgment on whether the Kernel shutdown module is repeatedly triggered to execute the kernel_power_off function is newly added, and only one process is allowed to trigger the Kernel shutdown module to execute the kernel_power_off function, so that the overall stability of the electronic equipment in the critical state is ensured.
In the embodiment of the application, a thread lock may be set to a Kernel shutdown module (or kernel_power_off function) in the electronic device. The thread lock is used to provide a mechanism to ensure that only one thread accesses a certain method or variable at a time.
The Kernel shutdown module can be triggered to execute the kernel_power_off function only when the target process (or target function module) holds the thread lock. If the target process does not hold the thread lock, the Kernel shutdown module cannot be triggered to execute the kernel_power_off function.
Therefore, the Linux kernel shutdown process of the electronic equipment cannot generate the reentry problem, and the electronic equipment cannot generate a panic in a low-voltage and low-voltage state due to reentry of the Linux kernel shutdown process, so that the battery and other equipment devices are prevented from being damaged.
As an alternative embodiment, the thread lock may be an atomic lock. Atomic locks, as intended, are atomic in operation on resources and are efficient.
As shown in fig. 6, when the target process needs to trigger the Kernel shutdown module to execute the kernel_power_off function, the target process applies for the atomic lock of the Kernel shutdown module. If the target process successfully applies for the atomic lock of the Kernel shutdown module, the target process triggers the Kernel shutdown module to execute the Kernel_power_off function, and when the Kernel_power_off function is executed, the mobile phone is completely shut down. If the target process does not apply for the atomic lock of the kernel shutdown module, the atomic lock of the kernel shutdown module is indicated to be held by other processes, and the target process is ended.
Therefore, the problem of reentry of the Linux Kernel shutdown process of the electronic equipment cannot occur, namely the problem that the target process repeatedly triggers the Kernel shutdown module to execute the Kernel_power_off function cannot occur.
In the embodiment of the application, the target process may apply for the atomic lock of the kernel shutdown module based on the function atomic_dec_and_test. Illustratively, the lock of the atomic lock of the kernel shutdown module has an initial value of 1. When the target process applies for the atomic lock of the kernel shutdown module, the current value of lock is subtracted by 1 using the function atomic_dec_and_test. If the return value of the function atomic_dec_and_test is true, the current value of lock is 0, which indicates that the kernel shutdown module can be triggered, that is, the target process can successfully apply for the atomic lock of the kernel shutdown module; if the return value of the function atomic_dec_and_test is false, the current value of lock is negative, which indicates that the kernel shutdown module is triggered by other processes, that is, the target process cannot successfully apply for the atomic lock of the kernel shutdown module and can only exit. Before the target process exits, the target process also calls the function atomic_dec_and_test to add 1 to the lock current value, so that the lock current value becomes 0 again.
The following explains the flow of the kernel shutdown method provided in the embodiment of the present application in two specific scenarios.
Scene one
In this scenario, the battery service in the Framework layer determines, at time T1, that the Kernel shutdown module needs to be triggered to execute the kernel_power_off function, and the ADSP function module in the Kernel layer determines, at time T2, that the Kernel shutdown module needs to be triggered to execute the kernel_power_off function. The time T1 is earlier than the time T2, and the interval between the time T1 and the time T2 is smaller, for example, smaller than a preset threshold.
FIG. 7a is a schematic diagram illustrating the interaction of the modules involved in the triggering process of the kernel shutdown module. As shown in fig. 7a, the triggering process of the kernel shutdown module includes:
s601, when the low voltage phenomenon occurs to the battery, the ADSP function module sends a low voltage interrupt signal and battery related monitoring data to the AP function module.
Among other battery related monitoring data, including but not limited to battery charge, battery power, battery current, battery temperature, battery health status, whether the battery is charged, etc.
S602, when the low voltage phenomenon of the battery occurs, the ADSP function module starts a 60S delay work for triggering the kernel shutdown module.
The present embodiment does not limit the sequential timing of S601 and S602.
S603, the AP function module transmits a low-voltage interrupt signal and battery-related monitoring data to the health module.
The health module sends the battery low voltage status, and battery related monitoring data to the battery service S604.
And the health module is used for determining that the battery is in a low-voltage and low-voltage state after receiving the low-voltage interrupt signal transmitted by the AP function module and the battery related monitoring data, and transmitting the low-voltage and low-voltage state of the battery and the battery related monitoring data to the battery service of the Framework layer.
S605, the battery service transmits a 30S shutdown event broadcast to notify each module device to power down.
And under the pushing of a Kernel upper-layer shutdown flow, each module device executes power-down operation.
S606, after the module devices are powered down, the battery service applies for an atomic lock of the kernel shutdown module.
After powering down the module devices, the battery service determines that the Kernel shutdown module needs to be triggered to execute a kernel_power_off function. Assuming that the time is T1, the battery service applies for an atomic lock of the kernel shutdown module at the time T1.
The power-down of each module device can be understood as ending the Kernel upper layer shutdown process.
S607, the battery service successfully holds the atomic lock of the Kernel shutdown module, and triggers the Kernel shutdown module to execute the Kernel_power_off function.
In this scenario, before time T1, the atomic lock of the kernel shutdown module is not held by other processes, and the battery service may successfully hold the atomic lock of the kernel shutdown module. Thus, the battery service can trigger the Kernel shutdown module to execute the kernel_power_off function, so that the mobile phone is completely shut down.
S608, when the 60S delay work timing is finished, the ADSP function module applies for holding the atomic lock of the kernel shutdown module.
S609, the ADSP function module applies for the failure of the atomic lock holding the kernel shutdown module, and ends the process.
At the end of the 60s delay work timer, the ADSP function determines that the Kernel shutdown module needs to be triggered to execute the kernel_power_off function. Assuming that the time is the time T2, the ADSP function module applies for an atomic lock of the kernel shutdown module at the time T2. Because the atomic lock of the kernel shutdown module is already held by the battery service at the time T1 (the time T1 is earlier than the time T2), the ADSP function module fails to apply for holding the atomic lock of the kernel shutdown module, and the process can be ended.
It should be noted that, when the ADSP function module applies for holding the atomic lock of the Kernel shutdown module, the kernel_power_off function triggered and executed by the battery service is not executed, i.e. the mobile phone is not completely closed.
Where this process is not explained in detail, reference may be made to the foregoing and no further explanation is provided here.
Because the battery service in the Framework layer and the ADSP function module in the Kernel layer need to trigger the Kernel shutdown module to execute the kernel_power_off function are close, the scene is a critical scene of the Linux Kernel shutdown process, wherein the problem of reentry can occur. In the scene, the battery service in the Framework layer holds the atomic lock of the Kernel shutdown module in advance, triggers the Kernel shutdown module to execute the kernel_power_off function, can avoid the problem that the Kernel shutdown process reenters due to the fact that the Linux Kernel shutdown process is triggered by the ADSP function module, greatly reduces the probability that the electronic equipment has a sound under the condition of low voltage and low voltage, and improves the overall stability of the electronic equipment.
Scene two
In this scenario, the battery service in the Framework layer determines, at time T1, that the Kernel shutdown module needs to be triggered to execute the kernel_power_off function, and the ADSP function module in the Kernel layer determines, at time T2, that the Kernel shutdown module needs to be triggered to execute the kernel_power_off function. The time T2 is earlier than the time T1, and the interval between the time T2 and the time T1 is smaller, for example, smaller than a preset threshold.
FIG. 7b is a schematic diagram illustrating the interaction of the modules involved in the triggering process of the kernel shutdown module. As shown in fig. 7b, the triggering process of the kernel shutdown module includes:
and S701, when the low voltage phenomenon occurs to the battery, the ADSP function module sends a low voltage interrupt signal and battery related monitoring data to the AP function module.
Among other battery related monitoring data, including but not limited to battery charge, battery power, battery current, battery temperature, battery health status, whether the battery is charged, etc.
S702, when the low voltage phenomenon of the battery occurs, the ADSP function module starts a 60S delay work for triggering the kernel shutdown module.
The present embodiment does not limit the sequential timing of S701 and S702.
S703, the AP function module transmits a low-voltage interrupt signal and battery-related monitoring data to the health module.
S704, the Healthd module sends the battery low voltage status, and the battery related monitoring data, to the battery service.
And the health module is used for determining that the battery is in a low-voltage and low-voltage state after receiving the low-voltage interrupt signal transmitted by the AP function module and the battery related monitoring data, and transmitting the low-voltage and low-voltage state of the battery and the battery related monitoring data to the battery service of the Framework layer.
S705, the battery service transmits a 30S shutdown event broadcast to notify each module device to power down.
And under the pushing of a Kernel upper-layer shutdown flow, each module device executes power-down operation.
S706, when the 60S delay work timing is finished, the ADSP function module applies for holding the atomic lock of the kernel shutdown module.
At the end of the 60s delay work timer, the ADSP function determines that the Kernel shutdown module needs to be triggered to execute the kernel_power_off function. Assuming that the time is the time T2, the ADSP function module applies for an atomic lock of the kernel shutdown module at the time T2.
S707, the ADSP function module successfully holds the atomic lock of the Kernel shutdown module and triggers the Kernel shutdown module to execute the Kernel_power_off function.
In this scenario, before the time T2, the atomic lock of the kernel shutdown module is not held by other processes, and then the ADSP functional module may successfully hold the atomic lock of the kernel shutdown module.
S708, after the module devices are powered down, the battery service applies for an atomic lock of the kernel shutdown module.
After powering down the module devices, the battery service determines that the Kernel shutdown module needs to be triggered to execute a kernel_power_off function. Assuming that the time is T1, the battery service applies for an atomic lock of the kernel shutdown module at the time T1.
The power-down of each module device can be understood as ending the Kernel upper layer shutdown process.
S709, the battery service application holds the atomic lock failure of the kernel shutdown module, and the process is ended.
Because the atomic lock of the kernel shutdown module is already held by the ADSP function module at the time T2 (the time T2 is earlier than the time T1), the battery service application fails to hold the atomic lock of the kernel shutdown module, and the process can be ended.
It should be noted that, when the battery service applies for holding the atomic lock of the Kernel shutdown module, the kernel_power_off function triggered and executed by the ADSP function module is not executed, i.e. the mobile phone is not completely closed.
Where this process is not explained in detail, reference may be made to the foregoing and no further explanation is provided here.
Because the battery service in the Framework layer and the ADSP function module in the Kernel layer need to trigger the Kernel shutdown module to execute the kernel_power_off function are close, the scene is a critical scene of the Linux Kernel shutdown process, wherein the problem of reentry can occur. In the scene, an ADSP function module in the Kernel layer holds an atomic lock of a Kernel shutdown module in advance, triggers the Kernel shutdown module to execute a kernel_power_off function, can avoid the problem that the Kernel shutdown process reenters due to triggering of a Linux Kernel shutdown process by battery service, greatly reduces the probability of the occurrence of a pass of the electronic equipment under the condition of low voltage and low voltage, and improves the overall stability of the electronic equipment.
The present embodiment also provides a computer storage medium having stored therein computer instructions that, when executed on an electronic device, cause the electronic device to execute the above-described related method steps to implement the kernel shutdown method in the above-described embodiments.
The present embodiment also provides a computer program product, which when run on a computer, causes the computer to perform the above-mentioned related steps to implement the kernel shutdown method in the above-mentioned embodiments.
In addition, embodiments of the present application also provide an apparatus, which may be specifically a chip, a component, or a module, and may include a processor and a memory connected to each other; the memory is used for storing computer execution instructions, and when the device runs, the processor can execute the computer execution instructions stored in the memory so that the chip executes the kernel shutdown method in the method embodiments.
The electronic device (such as a mobile phone) provided in this embodiment, the computer storage medium, the computer program product or the chip are used to execute the corresponding method provided above, so that the beneficial effects thereof can be referred to the beneficial effects in the corresponding method provided above, and will not be described herein.
It will be appreciated by those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional modules is illustrated, and in practical application, the above-described functional allocation may be performed by different functional modules according to needs, i.e. the internal structure of the apparatus is divided into different functional modules to perform all or part of the functions described above.
In the several embodiments provided in this application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of modules or units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another apparatus, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The above embodiments are merely for illustrating the technical solution of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.

Claims (9)

1. The kernel shutdown method is characterized by being applied to electronic equipment, wherein the electronic equipment is powered by a battery, the electronic equipment comprises a first functional module, a second functional module and a kernel shutdown module, and the first functional module and the second functional module are used for triggering the kernel shutdown module to execute a kernel shutdown process; the method comprises the following steps:
after the battery is lower than a first threshold, the first functional module determines that a first triggering condition of the kernel shutdown module is met at first moment;
the first functional module applies for holding the thread lock of the kernel shutdown module, and the application result is that the thread lock is successfully held;
the first functional module triggers the kernel shutdown module to execute a kernel shutdown process;
after the electric quantity of the battery is lower than a first threshold value, the second functional module determines that a second triggering condition of the kernel shutdown module is met at a second moment; the first moment is earlier than the second moment, and the time interval between the first moment and the second moment is smaller than a preset threshold value;
the second functional module applies for a thread lock of the kernel shutdown module, and the application result is that the thread lock is failed to hold; and ending the processing flow of the second functional module.
2. The method of claim 1, wherein the first functional module is a functional module in an application framework layer and the second functional module is a functional module in a kernel layer.
3. The method of claim 2, wherein the first functional module determining that the first trigger condition of the kernel shutdown module is currently met at a first time after the battery level is below a first threshold comprises:
after the electric quantity of the battery is lower than a first threshold value, the first functional module broadcasts a shutdown event, wherein the shutdown event is used for indicating each device module in the electronic equipment to execute a power-down operation;
the method comprises the steps that each device module in the electronic equipment completes power-down operation at the first moment, and the first functional module determines that a first triggering condition of a kernel shutdown module is met at the first moment;
after the electric quantity of the battery is lower than a first threshold value, the second functional module determines that a second triggering condition of the kernel shutdown module is currently met at a second moment, and the method comprises the following steps:
after the electric quantity of the battery is lower than a first threshold value, the second functional module starts a delay operation, and the delay operation is used for triggering the kernel shutdown module to execute a kernel shutdown process when delay timing is finished;
And when the delay timing of the delay operation is finished at the second moment, the second functional module determines that the second triggering condition of the kernel shutdown module is met at present at the second moment.
4. The method of claim 1, wherein the first functional module is a functional module in a kernel layer and the second functional module is a functional module in an application framework layer.
5. The method of claim 4, wherein the first functional module determining that the first trigger condition of the kernel shutdown module is currently met at a first time after the battery level is below a first threshold comprises:
after the electric quantity of the battery is lower than a first threshold value, the first functional module starts a delay operation, and the delay operation is used for triggering the kernel shutdown module to execute a kernel shutdown process when delay timing is finished;
the first functional module determines that a first triggering condition of the kernel shutdown module is met at the first moment when the delay timing of the delay operation is finished at the first moment;
after the electric quantity of the battery is lower than a first threshold value, the second functional module determines that a second triggering condition of the kernel shutdown module is currently met at a second moment, and the method comprises the following steps:
After the electric quantity of the battery is lower than a first threshold value, the second functional module broadcasts a shutdown event, wherein the shutdown event is used for indicating each device module in the electronic equipment to execute a power-down operation;
and the second functional module determines that a second triggering condition of the kernel shutdown module is met at the second moment.
6. The method of any of claims 1-5, wherein the thread lock is an atomic lock.
7. The method of any of claims 1-5, wherein the Kernel shutdown module is configured to execute a kernel_power_off function.
8. An electronic device, comprising:
one or more processors;
a memory;
and one or more computer programs, wherein the one or more computer programs are stored on the memory, which when executed by the one or more processors, cause the electronic device to perform the kernel shutdown method of any of claims 1-7.
9. A computer readable storage medium comprising a computer program, characterized in that the computer program, when run on an electronic device, causes the electronic device to perform the kernel shutdown method as claimed in any of claims 1-7.
CN202311330202.8A 2023-10-16 2023-10-16 Kernel shutdown method, electronic device and storage medium Active CN117093278B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311330202.8A CN117093278B (en) 2023-10-16 2023-10-16 Kernel shutdown method, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311330202.8A CN117093278B (en) 2023-10-16 2023-10-16 Kernel shutdown method, electronic device and storage medium

Publications (2)

Publication Number Publication Date
CN117093278A CN117093278A (en) 2023-11-21
CN117093278B true CN117093278B (en) 2024-03-15

Family

ID=88780527

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311330202.8A Active CN117093278B (en) 2023-10-16 2023-10-16 Kernel shutdown method, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN117093278B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2003071419A2 (en) * 2001-12-10 2003-08-28 Incipient, Inc. Fast path for performing data operations
CN105611057A (en) * 2015-12-23 2016-05-25 广东欧珀移动通信有限公司 De-electrification method and device for terminal
CN112749020A (en) * 2020-12-31 2021-05-04 普华基础软件股份有限公司 Microkernel optimization method of Internet of things operating system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112181124B (en) * 2020-09-11 2023-09-01 华为技术有限公司 Method for managing power consumption and related equipment

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2003071419A2 (en) * 2001-12-10 2003-08-28 Incipient, Inc. Fast path for performing data operations
CN105611057A (en) * 2015-12-23 2016-05-25 广东欧珀移动通信有限公司 De-electrification method and device for terminal
CN112749020A (en) * 2020-12-31 2021-05-04 普华基础软件股份有限公司 Microkernel optimization method of Internet of things operating system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于ARM处理器的专用通信手持终端设计与实现;张宝军;《铁道技术监督》;第45卷(第6期);第21-26页 *

Also Published As

Publication number Publication date
CN117093278A (en) 2023-11-21

Similar Documents

Publication Publication Date Title
WO2023284415A1 (en) Power key mistouch detection method and electronic device
CN111569435B (en) Ranking list generation method, system, server and storage medium
CN111443957A (en) Application stuck processing method and device and electronic equipment
CN111381996B (en) Memory exception handling method and device
CN117093278B (en) Kernel shutdown method, electronic device and storage medium
CN115328563B (en) System starting method and electronic equipment
CN111258683A (en) Detection method, detection device, computer equipment and storage medium
CN117130824A (en) Method for processing exception, electronic equipment and storage medium
CN115835135A (en) CELL fence matching method and electronic equipment
CN115794361A (en) Method for managing memory and electronic equipment
CN114816031B (en) Power saving method for terminal equipment, terminal equipment and medium
CN116736999B (en) Control method of electronic equipment and electronic equipment
CN113285500B (en) Mobile terminal and charging method thereof
CN117097883B (en) Frame loss fault cause determining method, electronic equipment and storage medium
CN111385416B (en) Electronic equipment and alarm clock processing method
CN116126744B (en) Memory recycling method and device and terminal equipment
CN117076284B (en) Page loading time length detection method, equipment and storage medium
CN113805949B (en) Picture display method and device
CN110707388B (en) Charging method, charging device, storage medium and electronic equipment
CN115934302A (en) Memory leak processing method and electronic equipment
CN116719556A (en) System upgrading method and electronic equipment
CN117130767A (en) Method for recycling memory, electronic equipment and storage medium
CN117827338A (en) Method for dynamically generating quick application card, electronic equipment, server and communication system
CN115421662A (en) Memory data write-back method, device and equipment
CN117311938A (en) Application running method, device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant