CN114237728A - Control method and operating system of electronic equipment - Google Patents

Control method and operating system of electronic equipment Download PDF

Info

Publication number
CN114237728A
CN114237728A CN202111592105.7A CN202111592105A CN114237728A CN 114237728 A CN114237728 A CN 114237728A CN 202111592105 A CN202111592105 A CN 202111592105A CN 114237728 A CN114237728 A CN 114237728A
Authority
CN
China
Prior art keywords
message
queue
target thread
thread
head
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.)
Granted
Application number
CN202111592105.7A
Other languages
Chinese (zh)
Other versions
CN114237728B (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.)
Beijing Eswin Computing Technology Co Ltd
Original Assignee
Beijing Eswin Computing Technology 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 Beijing Eswin Computing Technology Co Ltd filed Critical Beijing Eswin Computing Technology Co Ltd
Priority to CN202111592105.7A priority Critical patent/CN114237728B/en
Publication of CN114237728A publication Critical patent/CN114237728A/en
Application granted granted Critical
Publication of CN114237728B publication Critical patent/CN114237728B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

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/4418Suspend and resume; Hibernate and awake
    • 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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • 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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/48Indexing scheme relating to G06F9/48
    • G06F2209/482Application
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/547Messaging middleware
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The application discloses a control method and an operating system of electronic equipment, and relates to the technical field of electronic equipment. The method of the present application comprises: circularly detecting whether a message exists in a message queue through a scheduling program; if the message queue has the message, acquiring a queue head message in the message queue through the scheduling program, operating a target thread corresponding to the queue head message according to the queue head message, and deleting the queue head message in the message queue; and if no message exists in the message queue, controlling the electronic equipment to enter a sleep state.

Description

Control method and operating system of electronic equipment
Technical Field
The present disclosure relates to the field of electronic devices, and in particular, to a control method and an operating system for an electronic device.
Background
Currently, an operating system generally schedules an application according to a time slice, and the specific process is as follows: the operating system allocates time slices for each application program in the running state, and schedules the process corresponding to each application program according to the time slice corresponding to each application program; in the time slice corresponding to a certain process, if the thread corresponding to the process has executed the corresponding operation, the process hangs up and waits until the time slice corresponding to the process is finished unless the application program corresponding to the process automatically controls the dormancy or hangs up.
In order to save the power consumption of the electronic device, the operating system generally controls the electronic device to go to the sleep state when it is determined that all the applications in the running state agree to the sleep state based on a preset algorithm. However, when the number of the applications running in the electronic device is too large, it is difficult to determine that all the applications in the running state agree to the hibernation based on the preset algorithm, and therefore, the difficulty of controlling the electronic device to enter the hibernation state is also high, which results in high power consumption of the electronic device.
Disclosure of Invention
The embodiment of the application provides a control method and an operating system of an electronic device, and mainly aims to effectively control the electronic device to enter a sleep state so as to reduce the power consumption of the electronic device.
In order to solve the above technical problem, an embodiment of the present application provides the following technical solutions:
in a first aspect, the present application provides a method for controlling an electronic device, where the method is applied to an operating system, and the method includes:
circularly detecting whether a message exists in a message queue through a scheduling program;
if the message queue has the message, acquiring a queue head message in the message queue through the scheduling program, operating a target thread corresponding to the queue head message according to the queue head message, and deleting the queue head message in the message queue;
and if no message exists in the message queue, controlling the electronic equipment to enter a sleep state.
Optionally, before the cyclically detecting whether there is a message in the message queue by the scheduler, the method further includes:
creating the message queue;
when an operation instruction is received, generating a message corresponding to the operation instruction according to a preset registry;
adding the message to the tail of the message queue.
Optionally, a mapping relationship between each operation instruction and the thread unique identifier corresponding to the operation instruction is recorded in the preset registry; the generating of the message corresponding to the operation instruction according to the preset registry comprises:
searching a thread unique identifier corresponding to the operation instruction in the preset registry;
extracting operation content corresponding to the operation instruction from the operation instruction;
and generating a message corresponding to the operation instruction according to the unique thread identifier and the operation content corresponding to the operation instruction.
Optionally, the queue head message includes a thread unique identifier and operation content corresponding to the queue head message; the running of the target thread corresponding to the head-of-line message according to the head-of-line message comprises:
determining a target thread corresponding to the queue head message according to the thread unique identifier corresponding to the queue head message;
calling an entry function corresponding to the target thread to start the target thread;
and sending the operation content corresponding to the queue head message to the target thread so that the target thread executes the operation corresponding to the operation content.
Optionally, after the sending the operation content corresponding to the head-of-queue message to the target thread so that the target thread executes the operation corresponding to the operation content, the method further includes:
if the target thread executes the operation corresponding to the operation content within the preset time length, immediately closing the target thread;
if the target thread does not execute the operation corresponding to the operation content within the preset time length, determining the non-executed operation content according to the execution state of the target thread executing the operation corresponding to the operation content, generating an update message corresponding to the target thread according to the non-executed operation content and the thread unique identifier corresponding to the target thread, and adding the update message to the tail of the message queue.
Optionally, the electronic device includes a plurality of first hardware and a plurality of second hardware; the controlling the electronic device to enter a sleep state includes:
starting an interrupt program;
controlling the scheduler and the plurality of first hardware to enter a sleep state;
and after the dispatcher and the plurality of first hardware enter the dormant state for more than a preset time, controlling the plurality of second hardware and the operating system to enter the dormant state.
Optionally, after the controlling electronic device enters the sleep state, the method further includes:
when an interrupt signal is received, the interrupt program wakes up the operating system and the scheduling program so that the operating system generates an interrupt message corresponding to the interrupt signal according to a preset registry and runs a target thread corresponding to the interrupt message according to the interrupt message.
In a second aspect, the present application further provides an operating system, the system comprising:
the detection unit is used for circularly detecting whether a message exists in the message queue through the scheduling program;
an obtaining unit, configured to obtain a head message in the message queue through the scheduler when the detecting unit detects that a message exists in the message queue;
the running unit is used for running a target thread corresponding to the queue head message according to the queue head message;
a deleting unit, configured to delete the head-of-queue message in the message queue after the obtaining unit obtains the head-of-queue message;
and the control unit is used for controlling the electronic equipment to enter a dormant state when the detection unit detects that no message exists in the message queue.
Optionally, the system further includes:
the creating unit is used for creating the message queue before the detecting unit circularly detects whether the message exists in the message queue through a dispatcher;
the generating unit is used for generating a message corresponding to the operation instruction according to a preset registry when the operation instruction is received;
and the adding unit is used for adding the message to the tail of the message queue.
Optionally, a mapping relationship between each operation instruction and the thread unique identifier corresponding to the operation instruction is recorded in the preset registry; the generation unit includes:
the searching module is used for searching the unique thread identifier corresponding to the operating instruction in the preset registry;
the extracting module is used for extracting the operation content corresponding to the operation instruction from the operation instruction;
and the generating module is used for generating a message corresponding to the operating instruction according to the unique thread identifier and the operating content corresponding to the operating instruction.
Optionally, the queue head message includes a thread unique identifier and operation content corresponding to the queue head message; the operation unit includes:
the determining module is used for determining a target thread corresponding to the head-of-line message according to the thread unique identifier corresponding to the head-of-line message;
the calling module is used for calling the entry function corresponding to the target thread so as to start the target thread;
and the sending module is used for sending the operation content corresponding to the queue head message to the target thread so that the target thread can execute the operation corresponding to the operation content.
Optionally, the operation unit further includes:
the closing module is used for immediately closing the target thread when the target thread executes the operation corresponding to the operation content within the preset time length;
and the updating module is used for determining the unexecuted operation content according to the execution state of the target thread executing the operation corresponding to the operation content when the target thread does not execute the operation corresponding to the operation content within the preset time length, generating an updating message corresponding to the target thread according to the unexecuted operation content and the thread unique identifier corresponding to the target thread, and adding the updating message to the tail of the message queue.
Optionally, the electronic device includes a plurality of first hardware and a plurality of second hardware; the control unit includes:
the starting module is used for starting an interrupt program;
the first control module is used for controlling the scheduling program and the first hardware to enter a dormant state;
and the second control module is used for controlling the second hardware and the operating system to enter the dormant state after the dispatcher and the first hardware enter the dormant state for more than the preset time.
Optionally, the system further includes:
and the awakening unit is used for awakening the operating system and the scheduling program by the interrupt program when receiving an interrupt signal after the control unit controls the electronic equipment to enter the dormant state, so that the operating system generates an interrupt message corresponding to the interrupt signal according to a preset registry and runs a target thread corresponding to the interrupt message according to the interrupt message.
In a third aspect, an embodiment of the present application provides a storage medium, where the storage medium includes a stored program, and when the program runs, a device in which the storage medium is located is controlled to execute the control method of the electronic device according to the first aspect.
In a fourth aspect, embodiments of the present application provide an electronic device comprising a storage medium; and one or more processors, the storage medium coupled with the processors, the processors configured to execute program instructions stored in the storage medium; the program instructions are executed to perform the control method of the electronic device according to the first aspect.
By means of the technical scheme, the technical scheme provided by the application at least has the following advantages:
the application provides a control method and an operating system of electronic equipment, wherein the operating system circularly detects whether a message exists in a message queue through a scheduler, and when the operating system circularly detects that the message exists in the message queue through the scheduler, the operating system obtains a queue head message in the message queue through the scheduler and runs a target thread corresponding to the queue head message according to the queue head message so that the target thread executes an operation corresponding to the queue head message and deletes the queue head message in the message queue; when the operating system detects that no message exists in the message queue through the cycle of the scheduler, the operating system needs to control the electronic device to enter a sleep state. Therefore, when the operation instruction is received, the operation system can timely execute the operation corresponding to the operation instruction, and when the operation corresponding to all the operation instructions is executed, the operation system can timely control the electronic equipment to enter the dormant state.
The foregoing description is only an overview of the technical solutions of the present application, and the present application can be implemented according to the content of the description in order to make the technical means of the present application more clearly understood, and the following detailed description of the present application is given in order to make the above and other objects, features, and advantages of the present application more clearly understandable.
Drawings
The above and other objects, features and advantages of exemplary embodiments of the present application will become readily apparent from the following detailed description read in conjunction with the accompanying drawings. Several embodiments of the present application are illustrated by way of example and not by way of limitation in the figures of the accompanying drawings and in which like reference numerals refer to similar or corresponding parts and in which:
fig. 1 is a flowchart illustrating a control method for an electronic device according to an embodiment of the present disclosure;
fig. 2 is a flowchart illustrating a control method for an electronic device according to an embodiment of the present disclosure;
FIG. 3 is a schematic diagram of an operating system provided by an embodiment of the present application;
fig. 4 is a schematic diagram illustrating another operating system provided in an embodiment of the present application.
Detailed Description
Exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
It is to be noted that, unless otherwise specified, technical or scientific terms used herein shall have the ordinary meaning as understood by those skilled in the art to which this application belongs.
An embodiment of the present application provides a method for controlling an electronic device, as shown in fig. 1, where the method is applied to an operating system, and the method includes:
101. and circularly detecting whether the message exists in the message queue through the dispatcher.
In this embodiment of the present application, an execution subject in each step is an operating system running in an electronic device, where the electronic device may be, but is not limited to: computers, servers, and the like.
When a user controls the electronic equipment through the input equipment of the electronic equipment or other electronic equipment sends information to the electronic equipment through a network, the operating system receives and obtains a corresponding operating instruction; after receiving the operation instruction, the operating system needs to generate a message corresponding to the operation instruction, and adds the newly generated message to the tail of the message queue, so that when the subsequent operating system circularly detects that a message exists in the message queue through the scheduling program, the operating system sequentially executes the operation corresponding to each message according to the sequence of each message in the message queue.
In the embodiment of the application, in order to ensure that operations corresponding to received operation instructions can be executed in time and that the electronic device can be controlled to enter the sleep state in time after all operations corresponding to the operation instructions are executed, the operating system needs to detect whether a message exists in a message queue through a scheduler in a circulating manner.
102a, if the message exists in the message queue, acquiring a queue head message in the message queue through a scheduling program, operating a target thread corresponding to the queue head message according to the queue head message, and deleting the queue head message in the message queue.
The queue head message is the first message in the message queue.
In this embodiment of the present application, when the operating system detects that there is a message in the message queue through the scheduler in a loop manner, the operating system needs to obtain a queue head message in the message queue through the scheduler, and run a target thread corresponding to the queue head message according to the queue head message, so that the target thread executes an operation corresponding to the queue head message, and deletes the queue head message in the message queue.
For the embodiment of the application, in step 102b parallel to step 102a, if no message exists in the message queue, the electronic device is controlled to enter the sleep state.
In this embodiment, when the operating system detects that there is no message in the message queue through the scheduler cycle, the operating system needs to control the electronic device to enter the sleep state.
In the embodiment of the application, an operating system circularly detects whether a message exists in a message queue through a scheduler, and when the operating system circularly detects that the message exists in the message queue through the scheduler, the operating system obtains a queue head message in the message queue through the scheduler and runs a target thread corresponding to the queue head message according to the queue head message so that the target thread executes an operation corresponding to the queue head message and deletes the queue head message in the message queue; when the operating system detects that no message exists in the message queue through the cycle of the scheduler, the operating system needs to control the electronic device to enter a sleep state. Therefore, when the operation instruction is received, the operation system can timely execute the operation corresponding to the operation instruction, and when the operation corresponding to all the operation instructions is executed, the operation system can timely control the electronic equipment to enter the dormant state.
At present, the mainstream operating system generally schedules the application programs according to time slices, and no matter how elaborate the scheduling algorithm adopted by the operating system is, the operating system cannot accurately know whether each application program is really busy or not. Therefore, even if an application is in an idle state, i.e. the application does not need to perform any operation, the operating system still schedules the application in the time slice corresponding to the application unless the application is self-sleeping or suspended.
In order to save the power consumption of the electronic device, the operating system generally controls the electronic device to go to the sleep state when it is determined that all the applications in the running state agree to the sleep state based on a preset algorithm. However, when the number of the applications running in the electronic device is too large, it is difficult to determine that all the applications in the running state agree to the hibernation based on the preset algorithm, and therefore, the difficulty of controlling the electronic device to enter the hibernation state is also high, which results in high power consumption of the electronic device.
In the embodiment of the application, when the operation instruction is received, the operation system can execute the operation corresponding to the operation instruction in time, and when the operation corresponding to all the operation instructions is executed, the operation system can control the electronic device to enter the dormant state in time, so that the idle running of the operation system caused by scheduling the application program according to the time slice can be avoided, and the effect of saving the power consumption of the electronic device to the maximum extent is achieved.
To explain in more detail below, an embodiment of the present application provides another control method for an electronic device, specifically as shown in fig. 2, where the method is applied to an operating system, and the method includes:
201. a message queue is created.
In the embodiment of the application, the operating system needs to create the message queue in advance.
202. And when the operation instruction is received, generating a message corresponding to the operation instruction according to a preset registry, and adding the message to the tail of the message queue.
In the embodiment of the application, after receiving the operation instruction, the operating system needs to generate a message corresponding to the operation instruction according to the preset registry, and add the newly generated message to the tail of the message queue.
Specifically, in this step, the operating system may generate a message corresponding to the operation instruction according to the preset registry in the following manner:
the preset registry records the mapping relation between each operation instruction and the thread unique identifier corresponding to the operation instruction; the thread unique identifier corresponding to any one operation instruction is used for uniquely identifying the thread executing the operation corresponding to the operation instruction.
Firstly, a thread unique identifier corresponding to a newly received operation instruction is searched in a preset registry; secondly, extracting operation content corresponding to the operation instruction from the operation instruction; and finally, generating a message corresponding to the operation instruction according to the thread unique identifier and the operation content corresponding to the operation instruction, namely the newly generated message comprises the thread unique identifier and the operation content corresponding to the operation instruction.
203. And circularly detecting whether the message exists in the message queue through the dispatcher.
In step 203, it may refer to the description of the corresponding part in fig. 1 for the scheduler to circularly detect whether there is a cancellation in the message queue, and this embodiment of the present application will not be described again here.
204a, if the message exists in the message queue, acquiring a queue head message in the message queue through a scheduling program, operating a target thread corresponding to the queue head message according to the queue head message, and deleting the queue head message in the message queue.
In this embodiment of the present application, when the operating system detects that there is a message in the message queue through the scheduler in a loop manner, the operating system needs to obtain a queue head message in the message queue through the scheduler, and run a target thread corresponding to the queue head message according to the queue head message, so that the target thread executes an operation corresponding to the queue head message, and deletes the queue head message in the message queue.
Specifically, in this step, the operating system may run the target thread corresponding to the head-of-queue message according to the head-of-queue message in the following manner:
the queue head message comprises a thread unique identifier and operation content corresponding to the queue head message.
Firstly, determining a target thread corresponding to a queue head message according to a thread unique identifier corresponding to the queue head message; secondly, calling an entry function corresponding to the target thread so as to start the target thread; and finally, sending the operation content corresponding to the queue head message to the target thread so that the target thread executes the operation corresponding to the operation content contained in the queue head message.
Further, in the embodiment of the present application, in order to prevent the target thread from consuming a long time to execute the operation corresponding to the operation content included in the queue head message, thereby affecting the operation corresponding to the other messages in the execution message queue, the operating system sends the operation content corresponding to the queue head message to the target thread, so that after the target thread starts to execute the operation corresponding to the operation content, it is required to monitor whether the target thread executes the operation corresponding to the operation content within a preset time duration, and if the target thread executes the operation corresponding to the operation content within the preset time duration, the target thread is immediately closed; if the target thread does not execute the operation corresponding to the operation content within the preset time length, determining the non-executed operation content (namely the non-executed operation content at this time) according to the execution state of the target thread executing the operation corresponding to the operation content, generating an update message corresponding to the target thread according to the non-executed operation content and the thread unique identifier corresponding to the target thread, and adding the update message to the tail of the message queue, so that the target thread can continue to execute the operation corresponding to the non-executed operation content when the update message becomes a head of queue message in the following process.
For the embodiment of the present application, in step 204b parallel to step 204a, if there is no message in the message queue, the electronic device is controlled to enter the sleep state.
In this embodiment, when the operating system detects that there is no message in the message queue through the scheduler cycle, the operating system needs to control the electronic device to enter the sleep state.
Specifically, in this step, the operating system may control the electronic device to enter the sleep state in the following manner:
the electronic equipment comprises a plurality of pieces of first hardware and a plurality of pieces of second hardware; the method includes the steps of obtaining the use frequency of each piece of hardware in the electronic equipment in advance, determining N pieces of hardware with lower use frequencies as first hardware, and determining the rest pieces of hardware as second hardware, wherein the first hardware is the hardware with lower use frequencies in the electronic equipment, the second hardware is the hardware with higher use frequencies in the electronic equipment, and N is a positive integer.
Firstly, starting an interrupt program; secondly, controlling the scheduling program and the first hardware to enter a dormant state; finally, after the scheduler and the plurality of first hardware enter the sleep state for more than a preset time, controlling the plurality of second hardware and the operating system to enter the sleep state, at this time, only the interrupt program is in the running state, wherein the preset time may be, but is not limited to: 60 seconds, 2 minutes, 5 minutes, etc.
Further, in this embodiment of the application, after the electronic device enters the sleep state, when the user operates the electronic device through the input device of the electronic device again, and the other electronic device sends information to the electronic device or the local clock of the electronic device is automatically woken up, so that when the interrupt program receives the interrupt signal, the interrupt program needs to wake up the operating system and the scheduling program, so that the operating system generates an interrupt message corresponding to the interrupt signal according to the preset registry, and runs the target thread corresponding to the interrupt message according to the interrupt message, so that the target thread corresponding to the interrupt message executes an operation corresponding to the interrupt message.
It should be noted that, in the process that the operating system runs the target thread corresponding to the interrupt message according to the interrupt message, if other operation instructions are received, a message corresponding to a newly received operation instruction needs to be generated, and the newly generated message is added to the tail of the message queue, so that when the subsequent operating system circularly detects that a message exists in the message queue through the scheduler, the operation corresponding to each message is sequentially executed according to the sequence of each message in the message queue; if no other operation instruction is received, the electronic device needs to be controlled to enter the sleep state again after the target thread corresponding to the interrupt message executes the operation corresponding to the interrupt message.
In order to achieve the above object, according to another aspect of the present application, an embodiment of the present application further provides a storage medium, where the storage medium includes a stored program, and when the program runs, a device on which the storage medium is located is controlled to execute the control method of the electronic device described above.
In order to achieve the above object, according to another aspect of the present application, an embodiment of the present application further provides an electronic device, which includes a storage medium; and one or more processors, the storage medium coupled with the processors, the processors configured to execute program instructions stored in the storage medium; the program instructions execute the control method of the electronic equipment when running.
Further, as an implementation of the method shown in fig. 1 and fig. 2, another embodiment of the present application further provides an operating system. The system embodiment corresponds to the method embodiment, and details in the method embodiment are not described in detail again in this system embodiment for easy reading, but it should be clear that the system in this embodiment can correspondingly implement all the contents in the method embodiment. The system is applied to effectively control the electronic device to enter the sleep state to reduce the power consumption of the electronic device, and specifically, as shown in fig. 3, the system includes:
a detecting unit 31, configured to detect whether there is a message in the message queue through a scheduler cycle;
an obtaining unit 32, configured to obtain, by the scheduler, a head-of-queue message in the message queue when the detecting unit 31 detects that a message exists in the message queue;
the running unit 33 is configured to run a target thread corresponding to the head-of-queue message according to the head-of-queue message;
a deleting unit 34, configured to delete the head-of-queue message in the message queue after the obtaining unit 32 obtains the head-of-queue message;
a control unit 35, configured to control the electronic device to enter a sleep state when the detection unit 31 detects that no message exists in the message queue.
Further, as shown in fig. 4, the system further includes:
a creating unit 36, configured to create a message queue before the detecting unit 31 circularly detects whether there is a message in the message queue through a scheduler;
the generating unit 37 is configured to generate, when receiving an operation instruction, a message corresponding to the operation instruction according to a preset registry;
an adding unit 38, configured to add the message to the tail of the message queue.
Further, as shown in fig. 4, a mapping relationship between each operation instruction and the thread unique identifier corresponding to the operation instruction is recorded in the preset registry; the generation unit 37 includes:
the searching module 371 is configured to search the thread unique identifier corresponding to the operation instruction in the preset registry;
an extracting module 372, configured to extract, from the operation instruction, operation content corresponding to the operation instruction;
a generating module 373, configured to generate a message corresponding to the operation instruction according to the unique thread identifier and the operation content corresponding to the operation instruction.
Further, as shown in fig. 4, the queue head message includes a thread unique identifier and operation content corresponding to the queue head message; the operation unit 33 includes:
the determining module 331 is configured to determine, according to the thread unique identifier corresponding to the head-of-line message, a target thread corresponding to the head-of-line message;
a calling module 332, configured to call an entry function corresponding to the target thread to start the target thread;
a sending module 333, configured to send the operation content corresponding to the head-of-queue message to the target thread, so that the target thread executes the operation corresponding to the operation content.
Further, as shown in fig. 4, the operation unit 33 further includes:
a closing module 334, configured to immediately close the target thread when the target thread executes the operation corresponding to the operation content within a preset time period;
an updating module 335, configured to determine, when the target thread does not perform the operation corresponding to the operation content within the preset time duration, the non-executed operation content according to the execution state of the target thread performing the operation corresponding to the operation content, generate an update message corresponding to the target thread according to the non-executed operation content and the thread unique identifier corresponding to the target thread, and add the update message to the tail of the message queue.
Further, as shown in fig. 4, the electronic device includes a plurality of first hardware and a plurality of second hardware; the control unit 35 includes:
a starting module 351, configured to start an interrupt program;
a first control module 352, configured to control the scheduler and the plurality of first hardware to enter a sleep state;
the second control module 353 is configured to control the plurality of second hardware and the operating system to enter the sleep state after the scheduler and the plurality of first hardware enter the sleep state for more than a preset time period.
Further, as shown in fig. 4, the system further includes:
and a waking unit 39, configured to wake up, by the interrupt program, the operating system and the scheduling program when receiving an interrupt signal after the control unit 35 controls the electronic device to enter the sleep state, so that the operating system generates an interrupt message corresponding to the interrupt signal according to a preset registry, and runs a target thread corresponding to the interrupt message according to the interrupt message.
The embodiment of the application provides a control method and an operating system of electronic equipment, wherein in the embodiment of the application, the operating system circularly detects whether a message exists in a message queue through a scheduler, and when the operating system circularly detects that the message exists in the message queue through the scheduler, the operating system obtains a queue head message in the message queue through the scheduler, and operates a target thread corresponding to the queue head message according to the queue head message, so that the target thread executes an operation corresponding to the queue head message, and deletes the queue head message in the message queue; when the operating system detects that no message exists in the message queue through the cycle of the scheduler, the operating system needs to control the electronic device to enter a sleep state. Therefore, when the operation instruction is received, the operation system can timely execute the operation corresponding to the operation instruction, and when the operation corresponding to all the operation instructions is executed, the operation system can timely control the electronic equipment to enter the dormant state.
The embodiment of the application provides a storage medium, which comprises a stored program, wherein when the program runs, the device where the storage medium is located is controlled to execute the control method of the electronic device.
The storage medium may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
An embodiment of the present application further provides an electronic device, which includes a storage medium; and one or more processors, the storage medium coupled with the processors, the processors configured to execute program instructions stored in the storage medium; the program instructions execute the control method of the electronic equipment when running.
The embodiment of the application provides equipment, the equipment comprises a processor, a memory and a program which is stored on the memory and can run on the processor, and the following steps are realized when the processor executes the program:
circularly detecting whether a message exists in a message queue through a scheduling program;
if the message queue has the message, acquiring a queue head message in the message queue through the scheduling program, operating a target thread corresponding to the queue head message according to the queue head message, and deleting the queue head message in the message queue;
and if no message exists in the message queue, controlling the electronic equipment to enter a sleep state.
Further, before the detecting whether there is a message in the message queue circularly by the scheduler, the method further includes:
creating the message queue;
when an operation instruction is received, generating a message corresponding to the operation instruction according to a preset registry;
adding the message to the tail of the message queue.
Further, a mapping relationship between each operation instruction and the thread unique identifier corresponding to the operation instruction is recorded in the preset registry; the generating of the message corresponding to the operation instruction according to the preset registry comprises:
searching a thread unique identifier corresponding to the operation instruction in the preset registry;
extracting operation content corresponding to the operation instruction from the operation instruction;
and generating a message corresponding to the operation instruction according to the unique thread identifier and the operation content corresponding to the operation instruction.
Further, the queue head message includes a thread unique identifier and operation content corresponding to the queue head message; the running of the target thread corresponding to the head-of-line message according to the head-of-line message comprises:
determining a target thread corresponding to the queue head message according to the thread unique identifier corresponding to the queue head message;
calling an entry function corresponding to the target thread to start the target thread;
and sending the operation content corresponding to the queue head message to the target thread so that the target thread executes the operation corresponding to the operation content.
Further, after the sending the operation content corresponding to the head-of-queue message to the target thread so that the target thread executes the operation corresponding to the operation content, the method further includes:
if the target thread executes the operation corresponding to the operation content within the preset time length, immediately closing the target thread;
if the target thread does not execute the operation corresponding to the operation content within the preset time length, determining the non-executed operation content according to the execution state of the target thread executing the operation corresponding to the operation content, generating an update message corresponding to the target thread according to the non-executed operation content and the thread unique identifier corresponding to the target thread, and adding the update message to the tail of the message queue.
Further, the electronic device comprises a plurality of first hardware and a plurality of second hardware; the controlling the electronic device to enter a sleep state includes:
starting an interrupt program;
controlling the scheduler and the plurality of first hardware to enter a sleep state;
and after the dispatcher and the plurality of first hardware enter the dormant state for more than a preset time, controlling the plurality of second hardware and the operating system to enter the dormant state.
Further, after the controlling electronic device enters the sleep state, the method further includes:
when an interrupt signal is received, the interrupt program wakes up the operating system and the scheduling program so that the operating system generates an interrupt message corresponding to the interrupt signal according to a preset registry and runs a target thread corresponding to the interrupt message according to the interrupt message.
The present application further provides a computer program product adapted to perform program code for initializing the following method steps when executed on a data processing device: circularly detecting whether a message exists in a message queue through a scheduling program; if the message queue has the message, acquiring a queue head message in the message queue through the scheduling program, operating a target thread corresponding to the queue head message according to the queue head message, and deleting the queue head message in the message queue; and if no message exists in the message queue, controlling the electronic equipment to enter a sleep state.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims (16)

1. A control method of an electronic device, wherein the method is applied to an operating system, and comprises the following steps:
circularly detecting whether a message exists in a message queue through a scheduling program;
if the message queue has the message, acquiring a queue head message in the message queue through the scheduling program, operating a target thread corresponding to the queue head message according to the queue head message, and deleting the queue head message in the message queue;
and if no message exists in the message queue, controlling the electronic equipment to enter a sleep state.
2. The method of claim 1, wherein prior to said detecting a message in a message queue in a round-robin fashion by a scheduler, the method further comprises:
creating the message queue;
when an operation instruction is received, generating a message corresponding to the operation instruction according to a preset registry;
adding the message to the tail of the message queue.
3. The method according to claim 2, wherein the preset registry records mapping relationships between the operation instructions and the thread unique identifiers corresponding thereto; the generating of the message corresponding to the operation instruction according to the preset registry comprises:
searching a thread unique identifier corresponding to the operation instruction in the preset registry;
extracting operation content corresponding to the operation instruction from the operation instruction;
and generating a message corresponding to the operation instruction according to the unique thread identifier and the operation content corresponding to the operation instruction.
4. The method according to claim 1, wherein the queue head message comprises a thread unique identifier and operation content corresponding to the queue head message; the running of the target thread corresponding to the head-of-line message according to the head-of-line message comprises:
determining a target thread corresponding to the queue head message according to the thread unique identifier corresponding to the queue head message;
calling an entry function corresponding to the target thread to start the target thread;
and sending the operation content corresponding to the queue head message to the target thread so that the target thread executes the operation corresponding to the operation content.
5. The method according to claim 4, wherein after the sending the operation content corresponding to the head-of-queue message to the target thread so that the target thread performs the operation corresponding to the operation content, the method further comprises:
if the target thread executes the operation corresponding to the operation content within the preset time length, immediately closing the target thread;
if the target thread does not execute the operation corresponding to the operation content within the preset time length, determining the non-executed operation content according to the execution state of the target thread executing the operation corresponding to the operation content, generating an update message corresponding to the target thread according to the non-executed operation content and the thread unique identifier corresponding to the target thread, and adding the update message to the tail of the message queue.
6. The method of claim 1, wherein the electronic device comprises a plurality of first hardware and a plurality of second hardware; the controlling the electronic device to enter a sleep state includes:
starting an interrupt program;
controlling the scheduler and the plurality of first hardware to enter a sleep state;
and after the dispatcher and the plurality of first hardware enter the dormant state for more than a preset time, controlling the plurality of second hardware and the operating system to enter the dormant state.
7. The method of claim 6, wherein after the controlling electronic device enters the sleep state, the method further comprises:
when an interrupt signal is received, the interrupt program wakes up the operating system and the scheduling program so that the operating system generates an interrupt message corresponding to the interrupt signal according to a preset registry and runs a target thread corresponding to the interrupt message according to the interrupt message.
8. An operating system, the system comprising:
the detection unit is used for circularly detecting whether a message exists in the message queue through the scheduling program;
an obtaining unit, configured to obtain a head message in the message queue through the scheduler when the detecting unit detects that a message exists in the message queue;
the running unit is used for running a target thread corresponding to the queue head message according to the queue head message;
a deleting unit, configured to delete the head-of-queue message in the message queue after the obtaining unit obtains the head-of-queue message;
and the control unit is used for controlling the electronic equipment to enter a dormant state when the detection unit detects that no message exists in the message queue.
9. The system of claim 8, further comprising:
the creating unit is used for creating the message queue before the detecting unit circularly detects whether the message exists in the message queue through a dispatcher;
the generating unit is used for generating a message corresponding to the operation instruction according to a preset registry when the operation instruction is received;
and the adding unit is used for adding the message to the tail of the message queue.
10. The system according to claim 9, wherein the preset registry records mapping relationships between the respective operation instructions and the thread unique identifiers corresponding thereto; the generation unit includes:
the searching module is used for searching the unique thread identifier corresponding to the operating instruction in the preset registry;
the extracting module is used for extracting the operation content corresponding to the operation instruction from the operation instruction;
and the generating module is used for generating a message corresponding to the operating instruction according to the unique thread identifier and the operating content corresponding to the operating instruction.
11. The system according to claim 8, wherein the queue head message comprises a thread unique identifier and operation content corresponding to the queue head message; the operation unit includes:
the determining module is used for determining a target thread corresponding to the head-of-line message according to the thread unique identifier corresponding to the head-of-line message;
the calling module is used for calling the entry function corresponding to the target thread so as to start the target thread;
and the sending module is used for sending the operation content corresponding to the queue head message to the target thread so that the target thread can execute the operation corresponding to the operation content.
12. The system of claim 11, wherein the operation unit further comprises:
the closing module is used for immediately closing the target thread when the target thread executes the operation corresponding to the operation content within the preset time length;
and the updating module is used for determining the unexecuted operation content according to the execution state of the target thread executing the operation corresponding to the operation content when the target thread does not execute the operation corresponding to the operation content within the preset time length, generating an updating message corresponding to the target thread according to the unexecuted operation content and the thread unique identifier corresponding to the target thread, and adding the updating message to the tail of the message queue.
13. The system of claim 8, wherein the electronic device comprises a plurality of first hardware and a plurality of second hardware; the control unit includes:
the starting module is used for starting an interrupt program;
the first control module is used for controlling the scheduling program and the first hardware to enter a dormant state;
and the second control module is used for controlling the second hardware and the operating system to enter the dormant state after the dispatcher and the first hardware enter the dormant state for more than the preset time.
14. The system of claim 13, further comprising:
and the awakening unit is used for awakening the operating system and the scheduling program by the interrupt program when receiving an interrupt signal after the control unit controls the electronic equipment to enter the dormant state, so that the operating system generates an interrupt message corresponding to the interrupt signal according to a preset registry and runs a target thread corresponding to the interrupt message according to the interrupt message.
15. A storage medium characterized by comprising a stored program, wherein an apparatus in which the storage medium is located is controlled to execute the control method of the electronic apparatus according to any one of claims 1 to 7 when the program is executed.
16. An electronic device, characterized in that the electronic device comprises a storage medium; and one or more processors, the storage medium coupled with the processors, the processors configured to execute program instructions stored in the storage medium; the program instructions when executed perform the control method of the electronic device of any one of claims 1 to 7.
CN202111592105.7A 2021-12-23 2021-12-23 Control method and operating system of electronic equipment Active CN114237728B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111592105.7A CN114237728B (en) 2021-12-23 2021-12-23 Control method and operating system of electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111592105.7A CN114237728B (en) 2021-12-23 2021-12-23 Control method and operating system of electronic equipment

Publications (2)

Publication Number Publication Date
CN114237728A true CN114237728A (en) 2022-03-25
CN114237728B CN114237728B (en) 2024-03-29

Family

ID=80762116

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111592105.7A Active CN114237728B (en) 2021-12-23 2021-12-23 Control method and operating system of electronic equipment

Country Status (1)

Country Link
CN (1) CN114237728B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105550032A (en) * 2015-10-27 2016-05-04 深圳市美贝壳科技有限公司 CPU (Central Processing Unit) optimization method and system based on Android
CN108446183A (en) * 2018-04-13 2018-08-24 广东亿迅科技有限公司 Processing method and processing device based on message distribution
CN112929441A (en) * 2021-02-09 2021-06-08 上海锐伟电子科技有限公司 Control method and system of Internet of things equipment

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105550032A (en) * 2015-10-27 2016-05-04 深圳市美贝壳科技有限公司 CPU (Central Processing Unit) optimization method and system based on Android
CN108446183A (en) * 2018-04-13 2018-08-24 广东亿迅科技有限公司 Processing method and processing device based on message distribution
CN112929441A (en) * 2021-02-09 2021-06-08 上海锐伟电子科技有限公司 Control method and system of Internet of things equipment

Also Published As

Publication number Publication date
CN114237728B (en) 2024-03-29

Similar Documents

Publication Publication Date Title
US8839238B2 (en) Dynamic virtual machine shutdown without service interruptions
CN105159776B (en) Process handling method and device
KR102048329B1 (en) Method and apparatus for running application program
JP5960262B2 (en) Suspend and / or limit processes for connected standby
US20200174823A1 (en) State management method and apparatus for virtual machine, and smart terminal thereof
JP5951771B2 (en) Suspend and / or limit processes for connected standby
US8490118B2 (en) Wait on address synchronization interface
JP2018517202A (en) Event processing system paging
US10075409B2 (en) Terminal and application synchronization method therefor
JP2015501969A (en) Conserving power through workload estimation for portable computing devices using scheduled resource set migration
CN107818012B (en) Data processing method and device and electronic equipment
CN108806679B (en) Voice wake-up method and device
JP2014523059A (en) Suspend and / or limit processes for connected standby
CN107533479B (en) Power aware scheduling and power manager
CN110618860A (en) Spark-based Kafka consumption concurrent processing method and device
KR102060431B1 (en) Apparatus and method for managing power in multi-core system
US20140298073A1 (en) On-Demand Scalable Timer Wheel
CN114237728B (en) Control method and operating system of electronic equipment
CN111045507B (en) List management and control method, device, mobile terminal and storage medium
CN115617494B (en) Process scheduling method and device in multi-CPU environment, electronic equipment and medium
WO2019137298A1 (en) Process management and inter-process communication method, device, computing device, and storage medium
CN115658153A (en) Sleep lock optimization method and device, electronic equipment and storage medium
CN115344371A (en) Interface calling method and device, storage medium and computer equipment
CN114327835A (en) Distributed task scheduling method and device, processor and electronic equipment
CN109669526B (en) Method, system, terminal and storage medium for configuring energy-saving mode of cluster server

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: Room 101, floor 1, building 3, yard 18, Kechuang 10th Street, Beijing Economic and Technological Development Zone, Daxing District, Beijing 100176

Applicant after: Beijing yisiwei Computing Technology Co.,Ltd.

Address before: Room 101, floor 1, building 3, yard 18, Kechuang 10th Street, Beijing Economic and Technological Development Zone, Daxing District, Beijing 100176

Applicant before: Beijing yisiwei Computing Technology Co.,Ltd.

GR01 Patent grant
GR01 Patent grant