CN109947548B - Method and device for distributing time slices and method and device for controlling task execution - Google Patents

Method and device for distributing time slices and method and device for controlling task execution Download PDF

Info

Publication number
CN109947548B
CN109947548B CN201910199386.6A CN201910199386A CN109947548B CN 109947548 B CN109947548 B CN 109947548B CN 201910199386 A CN201910199386 A CN 201910199386A CN 109947548 B CN109947548 B CN 109947548B
Authority
CN
China
Prior art keywords
task
idle
tasks
preset
time slices
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
CN201910199386.6A
Other languages
Chinese (zh)
Other versions
CN109947548A (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.)
Midea Intelligent Lighting and Controls Technology Co Ltd
Original Assignee
Midea Intelligent Lighting and Controls 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 Midea Intelligent Lighting and Controls Technology Co Ltd filed Critical Midea Intelligent Lighting and Controls Technology Co Ltd
Priority to CN201910199386.6A priority Critical patent/CN109947548B/en
Publication of CN109947548A publication Critical patent/CN109947548A/en
Application granted granted Critical
Publication of CN109947548B publication Critical patent/CN109947548B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The embodiment of the invention provides a method and a device for distributing time slices and a method and a device for controlling task execution, and belongs to the field of intelligent home systems. The method comprises the following steps: determining a state of each task of the at least one task at predetermined time intervals; and according to the determination result, performing the following operations: allocating preset idle time slices to the tasks in the idle state in the at least one task respectively; and allocating preset non-idle time slices to the tasks in the non-idle state respectively, wherein the preset time interval is smaller than the preset non-idle time slices allocated to the tasks in the non-idle state respectively, and the preset idle time slices allocated to each task in the at least one task in the idle state are smaller than the preset non-idle time slices allocated to the tasks in the non-idle state. Therefore, the execution efficiency of the tasks is improved, and better experience is brought to the user.

Description

Method and device for distributing time slices and method and device for controlling task execution
Technical Field
The invention relates to the field of intelligent home systems, in particular to a method and a device for distributing time slices and a method and a device for controlling task execution.
Background
With the continuous development of the smart home industry, more and more intelligent systems are applied to products in the field, such as a KNX building system, a zigbee or bluetooth standard protocol stack system, or a private system specified by a specific company, or an open source system such as linux, freertos, etc. At present, many intelligent products need to meet the user requirements of multiple scenes, and the problem of multi-task scheduling needs to be solved inevitably. Multitasking generally requires consideration of the problem of allocating time slices for each task, and also the user experience of the whole system, and how to make a balance between the two is important.
At present, the allocation of task time slices to an intelligent system applied to a certain product by a company is fixed, and such a mechanism wastes system resources of a processor to a certain extent, affects the execution efficiency of system tasks, and cannot bring better experience to users.
Disclosure of Invention
The invention aims to provide a method and a device for allocating time slices and a method and a device for controlling task execution, which can improve the task execution efficiency and bring better experience to users.
To achieve the above object, one aspect of the present invention provides a method for allocating a time slice for a task, the method comprising: determining a state of each task of the at least one task at predetermined time intervals; and according to the determination result, performing the following operations: allocating preset idle time slices to the tasks in the idle state in the at least one task respectively; and allocating preset non-idle time slices to the tasks in the non-idle state respectively, wherein the preset time interval is smaller than the preset non-idle time slices allocated to the tasks in the non-idle state respectively, and the preset idle time slices allocated to each task in the at least one task in the idle state are smaller than the preset non-idle time slices allocated to the tasks in the non-idle state.
Optionally, the at least one task includes a screen control task, a voice broadcast task, and a security management task; in a case where the password needs to be modified, the determining of the state of each task of the at least one task at every predetermined time interval includes: firstly, the states of the screen control task and the voice broadcast task are non-idle states, and the state of the safety management task is an idle state; secondly, the states of the screen control task and the voice broadcasting task are idle states, and the state of the safety management task is a non-idle state; and thirdly, the states of the screen control task, the voice broadcasting task and the safety management task are all idle states.
Optionally, the at least one task includes a screen control task, a voice broadcast task, a security management task, a motor control task, and a message report task; in a case where the lock is required to be unlocked by the password, the determining the state of each task of the at least one task at predetermined time intervals includes: firstly, the states of the screen control task and the voice broadcast task are non-idle states, and the states of the safety management task, the motor control task and the message reporting task are idle states; secondly, the state of the safety management task is a non-idle state, and the states of the screen control task, the voice broadcast task, the motor control task and the message report task are idle states; thirdly, the state of the motor control task is a non-idle state, and the states of the screen control task, the voice broadcast task, the safety management task and the message report task are idle states; fourthly, the states of the voice broadcasting task and the message reporting task are non-idle states, and the states of the screen control task, the safety management task and the motor control task are idle states; and fifthly, the states of the screen control task, the voice broadcast task, the safety management task, the motor control task and the message report task are idle states.
Optionally, before said determining the state of each of the at least one task at every predetermined time interval, the method further comprises: and allocating initial preset non-idle time slices corresponding to the at least one task, wherein the allocation of the preset non-idle time slices to the tasks in the at least one task, the tasks in the non-idle state, is to allocate the initial preset non-idle time slices corresponding to the tasks in the at least one task, the tasks in the non-idle state.
Optionally, the method further comprises: judging whether at least one task has a task with abnormal execution; and under the condition that the task with abnormal execution exists in the at least one task, controlling to execute the abnormal processing operation corresponding to the task with abnormal execution so as to enable the task with abnormal execution to be recovered to be normal.
Accordingly, another aspect of the present invention provides an apparatus for allocating time slices for a task, the apparatus comprising: the state determining module is used for determining the state of each task in at least one task at preset time intervals; and a time slice allocation module for executing the following operations according to the determination result: allocating preset idle time slices to the tasks in the idle state in the at least one task respectively; and allocating preset non-idle time slices to the tasks in the non-idle state respectively, wherein the preset time interval is smaller than the preset non-idle time slices allocated to the tasks in the non-idle state respectively, and the preset idle time slices allocated to each task in the at least one task in the idle state are smaller than the preset non-idle time slices allocated to the tasks in the non-idle state.
Optionally, the at least one task includes a screen control task, a voice broadcast task, and a security management task; in a case where the password needs to be modified, the determining of the state of each task of the at least one task at every predetermined time interval includes: firstly, the states of the screen control task and the voice broadcast task are non-idle states, and the state of the safety management task is an idle state; secondly, the states of the screen control task and the voice broadcasting task are idle states, and the state of the safety management task is a non-idle state; and thirdly, the states of the screen control task, the voice broadcasting task and the safety management task are all idle states.
Optionally, the at least one task includes a screen control task, a voice broadcast task, a security management task, a motor control task, and a message report task; in a case where the lock is required to be unlocked by the password, the determining the state of each task of the at least one task at predetermined time intervals includes: firstly, the states of the screen control task and the voice broadcast task are non-idle states, and the states of the safety management task, the motor control task and the message reporting task are idle states; secondly, the state of the safety management task is a non-idle state, and the states of the screen control task, the voice broadcast task, the motor control task and the message report task are idle states; thirdly, the state of the motor control task is a non-idle state, and the states of the screen control task, the voice broadcast task, the safety management task and the message report task are idle states; fourthly, the states of the voice broadcasting task and the message reporting task are non-idle states, and the states of the screen control task, the safety management task and the motor control task are idle states; and fifthly, the states of the screen control task, the voice broadcast task, the safety management task, the motor control task and the message report task are idle states.
Optionally, the apparatus further comprises: the initial setting module is configured to allocate, to each task, a corresponding initial preset non-idle time slice before the state of each task in the at least one task is determined at every predetermined time interval, where allocating, to each task in the at least one task in which the state is the non-idle state, a preset non-idle time slice is to allocate, to each task in the at least one task in which the state is the non-idle state, a corresponding initial preset non-idle time slice.
Optionally, the apparatus further comprises: the judging module is used for judging whether a task with abnormal execution exists in the at least one task; and the control module is used for controlling the abnormal processing operation corresponding to the task with the abnormal execution under the condition that the task with the abnormal execution exists in the at least one task, so that the task with the abnormal execution is recovered to be normal.
In addition, the invention also provides an intelligent home system which comprises the device.
In addition, another aspect of the present invention also provides a machine-readable storage medium having stored thereon instructions for causing a machine to execute the above-mentioned method.
Through the technical scheme, the time slices are allocated to the tasks according to the states of the tasks, and the time slices allocated when the tasks are in the idle state are smaller than the time slices allocated when the tasks are in the non-idle state.
Additional features and advantages of the invention will be set forth in the detailed description which follows.
Drawings
The accompanying drawings, which are included to provide a further understanding of the embodiments of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the embodiments of the invention without limiting the embodiments of the invention. In the drawings:
FIG. 1 is a flow diagram of a method for allocating time slices for a task according to one embodiment of the invention;
FIG. 2 is a logic diagram of assigning time slices to tasks according to another embodiment of the present invention;
FIG. 3 is a logic diagram illustrating the assignment of time slices to tasks according to another embodiment of the present invention;
FIG. 4 is a logic diagram illustrating the assignment of time slices to tasks according to another embodiment of the present invention;
FIG. 5 is a schematic diagram of assigning an initial default non-idle time slice for a task according to another embodiment of the present invention;
FIG. 6 is a logic diagram illustrating the execution of exception handling operations according to another embodiment of the present invention; and
FIG. 7 is a block diagram of an apparatus for allocating time slices for tasks according to another embodiment of the present invention.
Description of the reference numerals
1 state determination module 2 time slice distribution module
Detailed Description
The following detailed description of embodiments of the invention refers to the accompanying drawings. It should be understood that the detailed description and specific examples, while indicating embodiments of the invention, are given by way of illustration and explanation only, not limitation.
One aspect of embodiments of the present invention provides a method for allocating time slices for a task. FIG. 1 is a flow diagram of a method for allocating time slices for a task according to an embodiment of the present invention. As shown in fig. 1, the method includes the following.
In step S10, the state of each of at least one task is determined at predetermined time intervals. The state of the task may include an idle state and a non-idle state, among others. Alternatively, in the embodiment of the present invention, the predetermined time interval may be 1 ms.
In step S11, the time slices are allocated according to the determination. Specifically, the following may be included. In at least one task, a preset idle time slice is respectively allocated to the tasks in the idle state. The preset idle time slices allocated to each task whose state is idle state may be the same or different. In addition, the smaller the preset idle time slice is, the less system resources of the processor are occupied when the task is idle, the less the waste of the system resources of the processor is, and the more the execution efficiency of the task can be improved. Alternatively, each task may be assigned a 1ms time slice when the state is idle. In at least one task, allocating preset non-idle time slices for the tasks in the non-idle state respectively, wherein the preset time interval is smaller than the preset non-idle time slices allocated for the tasks in the non-idle state respectively, and the preset idle time slices allocated for each task in the at least one task in the idle state are smaller than the preset non-idle time slices allocated for the tasks in the non-idle state. The preset non-idle time slices allocated to the tasks in the non-idle state may be the same or different. Specifically, the preset non-idle time slice to which each task is allocated when the state is the non-idle state may be determined based on hardware for executing the task, a condition of the task, and a communication timing. In addition, the time interval (the predetermined time interval) for re-determining the state of each task in the at least one task is smaller than the preset non-idle time slice allocated to each task in the at least one task when the state is the non-idle state. And the time slice allocated to each task when the state is the idle state is smaller than the time slice allocated to each task when the state is the non-idle state. In addition, the relationship between the time slice allocated to each task when the state is the idle state and the time slices allocated to other tasks when the state is the non-idle state is not determined, and may be determined according to specific situations.
The time slices are allocated to the tasks according to the states of the tasks, and the time slices allocated when the tasks are in the idle state are smaller than the time slices allocated when the tasks are in the non-idle state, so that compared with the time slices allocated when the tasks are in the non-idle state no matter what states the tasks are in, occupation of system resources is reduced, waste of the system resources of the processor is reduced, execution efficiency of the tasks is improved, especially the execution efficiency is improved under the multi-task condition, and better experience is brought to users.
For example, the distribution time slice will be described with reference to fig. 2 by taking an intelligent door lock as an example. Suppose that the intelligent door lock needs to execute a screen control task, a voice broadcast task, a safety management task, a motor control task and a message report task at most, and the total tasks are five tasks. The method for allocating a time slice to a task according to the embodiment of the present invention corresponds to a timer interrupt procedure, for example, a timing interval is 1ms, and the method according to the embodiment of the present invention corresponds to a 1ms timer interrupt procedure, and a timer is set to detect time. As shown in fig. 2, the timer enters an interrupt routine every 1ms, and the interrupt routine is used to query the status of each task, and further allocate a time slice to each task according to the status of each task. When tasks do not need to be executed (i.e., idle state), each task is assigned a 1ms time slice to reduce the loss of system resources. When the task needs to be executed (namely, the task is in a non-idle state), 2ms, 3ms, 5ms, 2ms and 3ms time slices are respectively allocated to the screen control task, the voice broadcasting task, the safety management task, the motor control task and the message reporting task. The time slice allocated to each task may be the same as or different from the hardware for executing the task, the task condition and the communication timing sequence, which is only an example, and how many time slices are specifically allocated to the non-idle state may be determined according to the actual situation.
FIG. 3 is a logic diagram illustrating the assignment of time slices to tasks according to another embodiment of the present invention. In this embodiment, it is assumed that the intelligent door lock needs to execute at most five tasks, namely, a screen control task, a voice broadcast task, a security management task, a motor control task, and a message report task, and how to allocate a time slice to a task in the process of password modification is described with reference to the time slice allocation shown in fig. 2 by taking the password modification of the intelligent door lock as an example. Wherein the predetermined time interval is 1ms, that is, the status of the task is determined once every 1 ms. Further, in this embodiment, "execution required" corresponds to the idle state described in the embodiment of the present invention, and "execution not required" corresponds to the non-idle state. Assume that the intelligent door lock is in an idle state (each task is allocated with only 1ms time slice, and the time for the control system of the intelligent door lock to execute a large cycle is only 5 ms). At this time, if the user wants to modify the password, firstly, the 1ms timer interrupt program judges that the screen control task and the voice broadcast task need to be executed, and other tasks do not need to be executed. The time slices allocated for the screen control task and the voice broadcasting task are respectively modified into 2ms and 3ms, and the time slices of other tasks are not changed (the time for the control system of the intelligent door lock to execute the major cycle is 8 ms). And the user modifies the unlocking password through the screen terminal according to the voice prompt. Subsequently, the 1ms timer judges that the screen control task and the voice broadcast task do not need to be executed, the safety management task does not need to be executed, other tasks do not need to be executed, the time slices of the screen control task, the voice broadcast task and the safety management task are respectively modified into 1ms, 1ms and 5ms, and the time slices of the other tasks are not changed (the time for the control system of the intelligent door lock to execute the major cycle is 9 ms). And saving the unlocking password modified by the user. The 1ms timer judges that the safety management task does not need to be executed and other tasks do not need to be executed, the time slice of the safety management task is modified into 1ms, the time slices of the other tasks are unchanged (the time for the control system of the intelligent door lock to execute the major cycle is 5ms), the system resources are released, and each task returns to the original idle state.
FIG. 4 is a logic diagram illustrating the assignment of time slices to tasks according to another embodiment of the present invention. In this embodiment, it is assumed that the intelligent door lock needs to execute at most five tasks, namely, a screen control task, a voice broadcast task, a security management task, a motor control task, and a message report task, and how to allocate a time slice to a task in the unlocking process is described with reference to the allocation time slice shown in fig. 2 by taking the modification of a password for the intelligent door lock as an example. Wherein the predetermined time interval is 1ms, that is, the status of the task is determined once every 1 ms. Further, in this embodiment, "execution required" corresponds to the idle state described in the embodiment of the present invention, and "execution not required" corresponds to the non-idle state. Assume that the intelligent door lock is in an idle state (each task is allocated with only 1ms time slice, and the time for the control system of the intelligent door lock to execute a large cycle is only 5 ms). The user unlocks the lock in a password mode. The 1ms timer judges that the screen control task and the voice broadcast task need to be executed, other tasks do not need to be executed, the time slices of the screen control task and the voice broadcast task are modified into 2ms and 3ms respectively, and the time slices of the other tasks are unchanged (the time for the control system of the intelligent door lock to execute the major cycle is only 8 ms). And the user inputs an unlocking password through the screen terminal according to the voice prompt. The 1ms timed interrupt program judges that the screen control task and the voice broadcast task do not need to be executed, the safety management task needs to be executed, other tasks do not need to be executed, the time slices of the screen control task, the voice broadcast task and the safety management task are respectively modified into 1ms, 1ms and 5ms, and the time slices of the other tasks are unchanged (the time for the control system of the intelligent door lock to execute the major cycle is only 9 ms). The security management task verifies that the password entered by the user is correct (assuming correct). The 1ms timed interrupt program judges that the safety management task does not need to be executed, the motor control task needs to be executed, other tasks do not need to be executed, the time slices of the safety management task and the motor control task are respectively modified into 1ms and 2ms, and the time slices of the other tasks are not changed (the time for the control system of the intelligent door lock to execute the major cycle is only 6 ms). The motor operates and the door lock is opened. The 1ms timed interrupt program judges that the motor control task is not required to be executed, the voice broadcast task and the message reporting task are required to be executed, other tasks are not required to be executed, the time slices of the motor control task, the voice broadcast task and the message reporting task are respectively modified into 1ms, 3ms and 3ms, and the time slices of the other tasks are not changed (the time for the control system of the intelligent door lock to execute the major cycle is only 9 ms). The voice broadcast is that the unlocking is successful, and relevant information is reported to the cloud server. And the 1ms timed interrupt program judges that the voice broadcasting task and the message reporting task do not need to be executed, other tasks do not need to be executed, the time slices of the voice broadcasting task and the message reporting task are respectively modified into 1ms and 1ms, the time slices of the other tasks are not changed (the time for the control system of the intelligent door lock to execute the major cycle is only 5ms), the system resources are released, and each task returns to the original idle state.
Optionally, in the embodiment of the present invention, before determining the state of each task in the at least one task at predetermined time intervals, an initial preset non-idle time slice when the corresponding state is the non-idle state may be allocated to each task in the at least one task. In the foregoing embodiment, in at least one task, when the state is the non-idle state, the preset non-idle time slice allocated to the task may be an initial preset non-idle time slice allocated to the task first.
As shown in fig. 5, taking the intelligent door lock as an example, it is assumed that the intelligent door lock needs to execute at most five tasks, namely, a screen control task, a voice broadcast task, a security management task, a motor control task, and a message report task. When the control system of the intelligent door lock is powered on, the relevant parameters of five tasks of a screen control task, a voice broadcast task, a safety management task, a motor control task and a message reporting task are initialized, corresponding time slices are given (the time slices corresponding to the task screen control task, the voice broadcast task, the safety management task, the motor control task and the message reporting task are respectively 2ms, 3ms, 5ms, 2ms and 3 ms. time slices, after the time slices of each task in a non-idle state are initialized, the state of the task is determined at preset time intervals, the time slices are distributed to the tasks according to the state of the task, for example, when the control system of the intelligent door lock is powered on, each task which is possibly required to be executed is initialized, a preset time slice is distributed to each task, then a 1 millisecond timer is set, the state of each task is regularly inquired every 1 millisecond, when a task is found to need to be executed, the task is executed according to the previous predetermined time slice, and the system resources are released after the task is finished. When the task is found not to be executed, the time slice preset at the beginning of the modification is 1ms, so that the influence on the next task needing to be executed later is reduced to the minimum, and the efficiency of the system for executing multiple tasks is improved.
In addition, in the embodiment of the present invention, it may also be determined whether there is a task that is executed abnormally in at least one task; when the task with abnormal execution exists, the abnormal processing operation corresponding to the task with abnormal execution is controlled to be executed, so that the task with abnormal execution is recovered to be normal. Specifically, after a certain task is executed, a success or failure result is returned, and the returned results of the tasks may be checked, and it may be determined that exception handling is not required according to the results. If the result returned by a task is failure, the corresponding exception handling function of the task can be called to carry out relevant operation. Wherein the state of the task corresponds to a non-idle state when the task requires exception handling. Therefore, the exception processing is judged not to be required according to the execution result returned by the task, and the recovery processing can be carried out after the task is in error.
FIG. 6 is a logic diagram illustrating an execution of an exception handling operation according to another embodiment of the present invention. In this embodiment, taking the intelligent door lock as an example, it is assumed that the intelligent door lock needs to execute at most five tasks, namely a screen control task, a voice broadcast task, a security management task, a motor control task and a message reporting task. How to perform the exception handling operation will be described by taking the motor control failure as an example in conjunction with the distribution time slice shown in fig. 2. The predetermined time interval is 1ms, that is, the state of the task is determined every 1 ms. In addition, in this embodiment, the time slices allocated to the screen control task, the voice broadcast task, the security management task, the motor control task, and the message report task when the state is the non-idle state may be set to be 2ms, 3ms, 5ms, 2ms, and 3 ms. Further, when the task execution is abnormal, a non-idle state is assumed.
And the user unlocks, and the control system of the intelligent door lock executes a motor control task. The 1ms timer interrupt routine looks up the motor control results (assuming an abnormal state is returned). At this time, the 1ms timed interrupt program considers that the motor control task is abnormally executed, and the time slice to which the motor control task is allocated is still 2 ms. And the control system of the intelligent door lock calls an exception handling function corresponding to the motor control task to carry out processing, such as overcurrent and overvoltage detection of the motor, retry operation of the motor and the like. Meanwhile, the 1ms timed interrupt program judges that the voice broadcast task and the message report task need to be executed, and the states of other tasks are unchanged. The time slices of the voice broadcast task and the message work task are modified to be 3ms and 3 ms. The control system performs related abnormity detection on the motor control, such as overcurrent and overvoltage detection, tries to control the motor again, broadcasts voice prompt of unlocking failure and reports information of unlocking abnormity to the cloud server. And then, the 1ms timed interrupt program judges that the motor control task, the voice broadcast task and the message report task do not need to be executed. The time slices of the motor control task, the voice broadcast task and the message report task are modified to be 1ms, and system resources are released.
Accordingly, another aspect of the embodiments of the present invention provides an apparatus for allocating time slices for a task. FIG. 7 is a block diagram of an apparatus for allocating time slices for tasks according to another embodiment of the present invention. As shown in fig. 7, the apparatus includes a state determination module 1 and a time slice allocation module 2. The state determining module 1 is used for determining the state of each task in at least one task at preset time intervals; the time slice allocation module 2 is configured to perform the following operations according to the determination result: allocating preset idle time slices for the tasks in idle state in at least one task; and allocating preset non-idle time slices to tasks in a non-idle state in at least one task, wherein the preset time interval is smaller than the preset non-idle time slices allocated to the tasks in the non-idle state, and the preset idle time slices allocated to each task in the at least one task in the idle state are smaller than the preset non-idle time slices allocated to the tasks in the non-idle state.
And allocating time slices for the tasks according to the states of the tasks, wherein the time slices allocated when the tasks are in the idle state are smaller than the time slices allocated when the tasks are in the non-idle state, so that the occupation of system resources is reduced, the waste of the system resources of the processor is reduced, the execution efficiency of the tasks is improved, and better experience is brought to users compared with the case that the tasks are allocated to the time slices when the tasks are in the non-idle state no matter what states the tasks are in.
Optionally, in the embodiment of the present invention, the at least one task includes a screen control task, a voice broadcast task, and a security management task; in a case where the password needs to be modified, the determining of the state of each task of the at least one task at every predetermined time interval includes: firstly, the states of a screen control task and a voice broadcast task are non-idle states, and the state of a safety management task is an idle state; secondly, the states of the screen control task and the voice broadcasting task are idle states, and the state of the safety management task is a non-idle state; and thirdly, the states of the screen control task, the voice broadcasting task and the safety management task are all idle states.
Optionally, in the embodiment of the present invention, the at least one task includes a screen control task, a voice broadcast task, a security management task, a motor control task, and a message report task; in a case where the lock is required to be unlocked by the password, the determining result of determining the state of each task of the at least one task at predetermined time intervals includes: firstly, the states of a screen control task and a voice broadcast task are non-idle states, and the states of a safety management task, a motor control task and a message report task are idle states; secondly, the state of the safety management task is a non-idle state, and the states of the screen control task, the voice broadcast task, the motor control task and the message report task are idle states; thirdly, the state of the motor control task is a non-idle state, and the states of the screen control task, the voice broadcast task, the safety management task and the message report task are idle states; fourthly, the states of the voice broadcasting task and the message reporting task are non-idle states, and the states of the screen control task, the safety management task and the motor control task are idle states; and fifthly, the states of the screen control task, the voice broadcast task, the safety management task, the motor control task and the message report task are idle states.
Optionally, in an embodiment of the present invention, the apparatus further includes: the initial setting module is used for allocating corresponding initial preset non-idle time slices to at least one task before the state of each task in the at least one task is determined at preset time intervals, wherein the allocation of the preset non-idle time slices to the tasks in the non-idle state in the at least one task is the allocation of the corresponding initial preset non-idle time slices to the tasks in the non-idle state in the at least one task.
Optionally, in an embodiment of the present invention, the apparatus further includes: the judging module is used for judging whether at least one task has a task with abnormal execution; and the control module is used for controlling the abnormal processing operation corresponding to the task with the abnormal execution under the condition that the task with the abnormal execution exists in at least one task, so that the task with the abnormal execution is recovered to be normal.
The specific working principle and benefits of the apparatus for allocating time slices to tasks according to the embodiment of the present invention are similar to those of the method for allocating time slices to tasks according to the embodiment of the present invention, and will not be described herein again.
In addition, another aspect of the embodiments of the present invention further provides an intelligent home system, which includes the apparatus described in the above embodiments.
In addition, another aspect of the embodiments of the present invention also provides a machine-readable storage medium, which stores instructions for causing a machine to execute the method described in the above embodiments.
Although the embodiments of the present invention have been described in detail with reference to the accompanying drawings, the embodiments of the present invention are not limited to the details of the above embodiments, and various simple modifications can be made to the technical solutions of the embodiments of the present invention within the technical idea of the embodiments of the present invention, and the simple modifications all belong to the protection scope of the embodiments of the present invention.
It should be noted that the various features described in the above embodiments may be combined in any suitable manner without departing from the scope of the invention. In order to avoid unnecessary repetition, the embodiments of the present invention do not describe every possible combination.
Those skilled in the art will understand that all or part of the steps in the method according to the above embodiments may be implemented by a program, which is stored in a storage medium and includes several instructions to enable a single chip, a chip, or a processor (processor) to execute all or part of the steps in the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
In addition, any combination of various different implementation manners of the embodiments of the present invention is also possible, and the embodiments of the present invention should be considered as disclosed in the embodiments of the present invention as long as the combination does not depart from the spirit of the embodiments of the present invention.

Claims (8)

1. A method for allocating time slices for a task, the method comprising:
determining a state of each task of the at least one task at predetermined time intervals; and
according to the determination result, the following operations are performed:
allocating preset idle time slices to the tasks in the idle state in the at least one task respectively; and
and allocating preset non-idle time slices to the tasks in the non-idle state in the at least one task, wherein the preset time interval is smaller than the preset non-idle time slices allocated to the tasks in the non-idle state, and the preset idle time slices allocated to each task in the at least one task in the idle state are smaller than the preset non-idle time slices allocated to each task in the non-idle state.
2. The method of claim 1, wherein prior to said determining the status of each of the at least one task at predetermined time intervals, the method further comprises:
and allocating initial preset non-idle time slices corresponding to the at least one task, wherein the allocation of the preset non-idle time slices to the tasks in the at least one task, the tasks in the non-idle state, is to allocate the initial preset non-idle time slices corresponding to the tasks in the at least one task, the tasks in the non-idle state.
3. The method of claim 1, further comprising:
judging whether at least one task has a task with abnormal execution; and
and controlling to execute an exception handling operation corresponding to the task with the execution exception so as to enable the task with the execution exception to be recovered to be normal when the task with the execution exception exists in the at least one task.
4. An apparatus for allocating time slices for a task, the apparatus comprising:
the state determining module is used for determining the state of each task in at least one task at preset time intervals; and
a time slice allocation module for executing the following operations according to the determination result:
allocating preset idle time slices to the tasks in the idle state in the at least one task respectively; and
and allocating preset non-idle time slices to the tasks in the non-idle state in the at least one task, wherein the preset time interval is smaller than the preset non-idle time slices allocated to the tasks in the non-idle state, and the preset idle time slices allocated to each task in the at least one task in the idle state are smaller than the preset non-idle time slices allocated to each task in the non-idle state.
5. The apparatus of claim 4, further comprising:
the initial setting module is configured to allocate, to each task, a corresponding initial preset non-idle time slice before the state of each task in the at least one task is determined at every predetermined time interval, where allocating, to each task in the at least one task in which the state is the non-idle state, a preset non-idle time slice is to allocate, to each task in the at least one task in which the state is the non-idle state, a corresponding initial preset non-idle time slice.
6. The apparatus of claim 4, further comprising:
the judging module is used for judging whether a task with abnormal execution exists in the at least one task; and
and the control module is used for controlling the abnormal processing operation corresponding to the task with the abnormal execution under the condition that the task with the abnormal execution exists in the at least one task, so that the task with the abnormal execution is recovered to be normal.
7. The utility model provides an intelligent home systems, its characterized in that, this intelligent home systems includes: the device of any one of claims 4-6.
8. A machine-readable storage medium having stored thereon instructions for causing a machine to perform the method of any one of claims 1-3.
CN201910199386.6A 2019-03-15 2019-03-15 Method and device for distributing time slices and method and device for controlling task execution Active CN109947548B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910199386.6A CN109947548B (en) 2019-03-15 2019-03-15 Method and device for distributing time slices and method and device for controlling task execution

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910199386.6A CN109947548B (en) 2019-03-15 2019-03-15 Method and device for distributing time slices and method and device for controlling task execution

Publications (2)

Publication Number Publication Date
CN109947548A CN109947548A (en) 2019-06-28
CN109947548B true CN109947548B (en) 2020-11-20

Family

ID=67010205

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910199386.6A Active CN109947548B (en) 2019-03-15 2019-03-15 Method and device for distributing time slices and method and device for controlling task execution

Country Status (1)

Country Link
CN (1) CN109947548B (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0558106A2 (en) * 1988-04-18 1993-09-01 BRUNSWICK BOWLING & BILLIARDS CORPORATION Operating method for a processing system under control of a multi-tasking time slice operating system
CN101027642A (en) * 2004-09-17 2007-08-29 松下电器产业株式会社 Processor
CN103885825A (en) * 2014-03-05 2014-06-25 南京邮电大学 Real-time speed monotony scheduling method based on dynamic time slices
CN104536835A (en) * 2014-12-12 2015-04-22 北京控制工程研究所 Self-adaption task scheduling method in hot backup real-time control system
CN106155806A (en) * 2015-04-14 2016-11-23 腾讯科技(深圳)有限公司 A kind of multi-task scheduling method and server
CN106648856A (en) * 2016-11-24 2017-05-10 深圳市万普拉斯科技有限公司 Task scheduling method and device
CN108166845A (en) * 2017-12-20 2018-06-15 美的集团股份有限公司 A kind of information prompting method of intelligent door lock, device, system and intelligent door lock
CN108509276A (en) * 2018-03-30 2018-09-07 南京工业大学 A kind of video task dynamic migration method in edge calculations environment
CN108594777A (en) * 2018-04-20 2018-09-28 百度在线网络技术(北京)有限公司 Intelligent home furnishing control method, device, equipment, system and storage medium
CN108958157A (en) * 2018-07-09 2018-12-07 北京东土科技股份有限公司 Control process control dispatching method, device, computer equipment and storage medium

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0558106A2 (en) * 1988-04-18 1993-09-01 BRUNSWICK BOWLING & BILLIARDS CORPORATION Operating method for a processing system under control of a multi-tasking time slice operating system
CN101027642A (en) * 2004-09-17 2007-08-29 松下电器产业株式会社 Processor
CN103885825A (en) * 2014-03-05 2014-06-25 南京邮电大学 Real-time speed monotony scheduling method based on dynamic time slices
CN104536835A (en) * 2014-12-12 2015-04-22 北京控制工程研究所 Self-adaption task scheduling method in hot backup real-time control system
CN106155806A (en) * 2015-04-14 2016-11-23 腾讯科技(深圳)有限公司 A kind of multi-task scheduling method and server
CN106648856A (en) * 2016-11-24 2017-05-10 深圳市万普拉斯科技有限公司 Task scheduling method and device
CN108166845A (en) * 2017-12-20 2018-06-15 美的集团股份有限公司 A kind of information prompting method of intelligent door lock, device, system and intelligent door lock
CN108509276A (en) * 2018-03-30 2018-09-07 南京工业大学 A kind of video task dynamic migration method in edge calculations environment
CN108594777A (en) * 2018-04-20 2018-09-28 百度在线网络技术(北京)有限公司 Intelligent home furnishing control method, device, equipment, system and storage medium
CN108958157A (en) * 2018-07-09 2018-12-07 北京东土科技股份有限公司 Control process control dispatching method, device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN109947548A (en) 2019-06-28

Similar Documents

Publication Publication Date Title
CN110855536B (en) Operation control method and device, household appliance and storage medium
CN106941516B (en) Heterogeneous field device control management system based on industrial internet operating system
JP7101127B2 (en) Industrial server microkernel architecture control system and industrial server
CN102081554A (en) Cloud computing operating system as well as kernel control system and method thereof
CN110750343B (en) Cluster system timing task scheduling control method and cluster system
CN110704185B (en) Cluster system fragmentation timing task scheduling method and cluster system
CN109726073A (en) Database monitoring method, device, equipment and readable storage medium storing program for executing
CN111400039A (en) Control method and device of cloud platform, cloud platform system and electronic equipment
CN109947548B (en) Method and device for distributing time slices and method and device for controlling task execution
CN106603689B (en) Data processing method and device based on distributed publish-subscribe message system
CN114327929A (en) Priority processing method, device, scheduler and multi-core system based on AMP architecture
CN100589417C (en) System and method for processing a large number reporting message on topology interface in telecommunication network management system
CN115794350A (en) Task synchronization method, device and computer readable medium
CN103136045A (en) Dispatching method and device of virtualization operating system
CN117251260A (en) Data processing method and system
CN114114941A (en) Method and device for avoiding control instruction conflict, processor and intelligent home system
CN114721801A (en) Dynamic scheduling method and device for batch task execution time
CN104572036B (en) Event processing method and device
CN112860391A (en) Dynamic cluster rendering resource management system and method
CN112631730A (en) Model processing method and device, equipment and computer readable storage medium
CN111738823A (en) Bank peripheral system and sun-cutting method thereof
CN111327499A (en) Method and device for sending message and automobile
CN111698342A (en) Temperature controller communication address allocation method and system
Kim et al. Multi-Core ECU Load-Reducing Method using Time-Division Processing
CN110618863A (en) Operation scheduling method based on Raft algorithm

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: 335400 No. 1 Industrial Park, Yingtan, Jiangxi, Guixi

Applicant after: Meizhi Optoelectronic Technology Co., Ltd

Address before: 335400 No. 1 Industrial Park, Yingtan, Jiangxi, Guixi

Applicant before: MEIZHI PHOTOELECTRIC TECHNOLOGY Co.,Ltd.

GR01 Patent grant
GR01 Patent grant