CN112988355B - Program task scheduling method and device, terminal equipment and readable storage medium - Google Patents

Program task scheduling method and device, terminal equipment and readable storage medium Download PDF

Info

Publication number
CN112988355B
CN112988355B CN202110350211.8A CN202110350211A CN112988355B CN 112988355 B CN112988355 B CN 112988355B CN 202110350211 A CN202110350211 A CN 202110350211A CN 112988355 B CN112988355 B CN 112988355B
Authority
CN
China
Prior art keywords
program
task
mode
program task
triggered
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
CN202110350211.8A
Other languages
Chinese (zh)
Other versions
CN112988355A (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.)
Shenzhen Ubtech Technology Co ltd
Original Assignee
Shenzhen Ubtech 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 Shenzhen Ubtech Technology Co ltd filed Critical Shenzhen Ubtech Technology Co ltd
Priority to CN202110350211.8A priority Critical patent/CN112988355B/en
Publication of CN112988355A publication Critical patent/CN112988355A/en
Application granted granted Critical
Publication of CN112988355B publication Critical patent/CN112988355B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

The application is applicable to the technical field of computers, and provides a scheduling method, a scheduling device, terminal equipment and a readable storage medium for program tasks, wherein the method comprises the following steps: when a plurality of program tasks are detected, creating corresponding coroutine objects for each program task, and determining the attribute of each coroutine object; adding each coroutine object to a corresponding task queue container according to the attribute, and distributing a corresponding detection interface; and according to the running mode of the program task, starting the corresponding processing thread to control the program task to switch and execute. According to the method, the corresponding operation program is called to switch and execute based on the operation mode of the program task, diversified program triggering judgment and execution sequence conversion can be integrated, richer and diversified operation logic is realized, and the program operation is more convenient and effective.

Description

Program task scheduling method and device, terminal equipment and readable storage medium
Technical Field
The present application belongs to the field of computer technology, and in particular, relates to a method and apparatus for scheduling program tasks, a terminal device, and a readable storage medium.
Background
The program operation logic generated by the products based on programming education in the market at present is single, the supported programming course is relatively simple, and the program operation efficiency is low.
Disclosure of Invention
The embodiment of the application provides a scheduling method, a scheduling device, terminal equipment and a readable storage medium for program tasks, which can solve the problems of single program operation logic and low program operation efficiency generated by products based on programming education.
In a first aspect, an embodiment of the present application provides a method for scheduling a program task, including:
when a plurality of program tasks are detected, creating corresponding coroutine objects for each program task, and determining the attribute of each coroutine object;
adding each coroutine object to a corresponding task queue container according to the attribute, and distributing a corresponding detection interface;
and starting a corresponding processing thread to control the program task to switch and execute according to the running mode of the program task.
In a second aspect, an embodiment of the present application provides a scheduling apparatus for a program task, including:
the detection module is used for creating a corresponding coroutine object for each program task when detecting a plurality of program tasks and determining the attribute of each coroutine object;
the distribution module is used for adding each coroutine object to a corresponding task queue container according to the attribute and distributing a corresponding detection interface;
and the scheduling module is used for starting a corresponding processing thread to control the program task to switch and execute according to the running mode of the program task.
In a third aspect, an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the scheduling method of program tasks according to any one of the first aspect when the processor executes the computer program.
In a fourth aspect, an embodiment of the present application provides a computer readable storage medium storing a computer program which, when executed by a processor, implements a method for scheduling program tasks according to any one of the first aspects.
In a fifth aspect, an embodiment of the present application provides a computer program product, which, when run on a terminal device, causes the terminal device to perform the scheduling method of the program task according to any one of the first aspects.
According to the method, the corresponding operation program is called to switch and execute based on the operation mode of the program task, diversified program triggering judgment and execution sequence conversion can be integrated, richer and diversified operation logic is realized, and the efficiency and convenience of program operation are improved.
It will be appreciated that the advantages of the second to fifth aspects may be found in the relevant description of the first aspect, and are not described here again.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments or the description of the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings can be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a method for scheduling program tasks according to an embodiment of the present application;
fig. 2 is a flowchart of step S102 of a scheduling method of a program task according to an embodiment of the present application;
fig. 3 is a flowchart of step S103 of a scheduling method of a program task according to an embodiment of the present application;
fig. 4 is a schematic diagram of an application scenario of program task scheduling based on a parallel mode according to an embodiment of the present application;
fig. 5 is a schematic diagram of an application scenario of program task scheduling based on a preemption mode according to an embodiment of the present application;
FIG. 6 is a schematic diagram of a scheduling apparatus for program tasks according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of a terminal device according to an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth such as the particular system architecture, techniques, etc., in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
It should be understood that the terms "comprises" and/or "comprising," when used in this specification and the appended claims, specify the presence of stated features, integers, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and/or groups thereof.
It should also be understood that the term "and/or" as used in the present specification and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes such combinations.
As used in the present description and the appended claims, the term "if" may be interpreted as "when..once" or "in response to a determination" or "in response to detection" depending on the context. Similarly, the phrase "if a determination" or "if a [ described condition or event ] is detected" may be interpreted in the context of meaning "upon determination" or "in response to determination" or "upon detection of a [ described condition or event ]" or "in response to detection of a [ described condition or event ]".
Furthermore, the terms "first," "second," "third," and the like in the description of the present specification and in the appended claims, are used for distinguishing between descriptions and not necessarily for indicating or implying a relative importance.
Reference in the specification to "one embodiment" or "some embodiments" or the like means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," and the like in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments" unless expressly specified otherwise. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless expressly specified otherwise.
The scheduling method of the program tasks provided by the embodiment of the application can be applied to terminal equipment such as mobile phones, tablet computers, wearable equipment, vehicle-mounted equipment, notebook computers and the like, and the embodiment of the application does not limit the specific type of the terminal equipment.
Fig. 1 shows a schematic flow chart of a scheduling method of program tasks provided by the application, which can be applied to the notebook computer by way of example and not limitation.
S101, when a plurality of program tasks are detected, creating corresponding coroutine objects for each program task, and determining the attribute of each coroutine object.
In a specific application, when detecting that the main thread contains a plurality of program tasks at the current time, creating a corresponding coroutine object for each program task, and determining the attribute of each coroutine object according to the parameters carried by the program task. Attributes include, but are not limited to, trigger conditions for program tasks, execution content, and trigger patterns. The trigger condition refers to a detection condition for executing the program task, namely, executing execution content carried in the corresponding program task if and only if the trigger data is detected to meet the trigger condition. The trigger mode includes, but is not limited to, a software trigger mode or a hardware trigger mode.
S102, adding each coroutine object to a corresponding task queue container according to the attribute, and distributing a corresponding detection interface.
In a specific application, each coroutine object is added into a corresponding task queue container according to the attribute of each coroutine object, and each queue container is used for storing coroutine objects with the same attribute and distributing corresponding detection interfaces for coroutine objects according to the attribute of coroutine objects.
S103, according to the running mode of the program task, starting a corresponding processing thread to control the program task to switch and execute.
In a specific application, when the trigger data corresponding to the program task is detected to meet the trigger condition, determining the running mode of the triggered program task, and starting the processing thread corresponding to the running mode to control the triggered program task to switch and execute.
It will be appreciated that the manner in which the processing thread control program tasks corresponding to the different modes of operation are switched for execution is different.
In one embodiment, the attributes include trigger conditions, execution content, and trigger patterns;
as shown in fig. 2, the step S102 includes:
s1021, adding each coroutine object to a corresponding task queue container according to the trigger mode;
s1022, according to the type of the triggering data in the triggering condition, a corresponding detection interface is allocated for each coroutine object.
In a particular application, attributes of the coroutine object include, but are not limited to, trigger conditions, execution content, and trigger mode. Corresponding to the triggering mode of each coroutine object, adding each coroutine object to different task queue containers correspondingly, acquiring the type of triggering data in the triggering condition of each coroutine object, and distributing a corresponding detection interface for the corresponding coroutine object according to the type of the triggering data.
For example, the triggering condition of a certain program task is that the value of the triggering data infrared sensor ID1 is larger than 10, and the execution content is playing an 'elephant' sound effect; therefore, a detection interface of the infrared sensor is allocated to the coroutine object corresponding to the program task, so that the triggering data of the ID1 value of the infrared sensor can be detected in real time.
As shown in fig. 3, in one embodiment, the step S103 includes:
s1031, when the trigger data is detected to meet the trigger condition, determining that the corresponding program task is a triggered program task, and determining an operation mode of the triggered program task;
s1032, starting the corresponding processing thread to schedule and control the triggered program task to switch and execute according to the operation mode.
In a specific application, when triggering data of a certain program task is detected to meet a triggering condition, judging the corresponding program task as a triggered program task, and determining an operation mode of the triggered program task; and starting a corresponding processing thread to schedule and control the triggered program task to switch and execute according to the running mode of the triggered program task.
For example, the triggering condition of a certain program task is that the value of the triggering data infrared sensor ID1 is larger than 10, and the execution content is playing an 'elephant' sound effect. That is, when it is detected that the value of the trigger data infrared sensor ID1 is greater than 10, it is determined that the corresponding program task is a triggered program task.
In one embodiment, the modes of operation include a parallel mode, a preemption mode, a mutex mode, and an iterative mode;
and starting the corresponding processing thread according to the running mode to schedule and control the triggered program task to switch and execute, wherein the method comprises the following steps:
when the running mode of the triggered program task is detected to be a parallel mode, starting a parallel processing thread to process the triggered program task;
when the operation mode of the triggered program task is detected to be a preemption mode, starting a preemption processing thread to process the triggered program task;
when the running mode of the triggered program task is detected to be the mutual exclusion mode, starting a mutual exclusion processing thread to process the triggered program task;
and when the operation mode of the triggered program task is detected to be an iteration mode, starting an iteration processing thread to process the triggered program task.
In a specific application, the running modes of the program task include, but are not limited to, a parallel mode, a preemption mode, a mutual exclusion mode and an iteration mode, and according to the running modes of different program tasks, different processing threads are correspondingly called to process the triggered program task, namely when the running mode of the triggered program task is detected to be the parallel mode, the parallel processing threads are started to execute parallel processing on the triggered program task; when the operation mode of the triggered program task is detected to be a preemption mode, starting a preemption processing thread to execute preemption processing on the triggered program task; when the running mode of the triggered program task is detected to be the mutual exclusion mode, starting a mutual exclusion processing thread to execute mutual exclusion processing on the triggered program task; and when the operation mode of the triggered program task is detected to be an iteration mode, starting an iteration processing thread to execute iteration processing on the triggered program task.
It will be appreciated that in parallel mode, multiple triggered program tasks may be processed in parallel. In the preemption mode, the execution right preempts the triggered program task triggered later, namely the triggered program task triggered earlier needs to be controlled to stop running, and the triggered program task triggered later is run instead. In the exclusive mode, two triggered program tasks that are exclusive cannot run simultaneously. In the iterative mode, triggered program tasks that satisfy the iteration conditions may be performed iteratively.
In one embodiment, when the running mode of the triggered program task is detected to be a parallel mode, starting a parallel processing thread to process the triggered program task includes:
detecting whether a running program task exists in a parallel processing thread or not when detecting that the running mode of the triggered program task is a parallel mode;
executing the triggered program task when detecting that no running program task exists in the parallel processing thread;
and when detecting that the running program task exists in the parallel processing thread, controlling the running program task and the started program task to be alternately executed.
In a specific application, when detecting that the running mode of the triggered program task is a parallel mode, detecting whether the running program task exists in the parallel processing thread; directly executing the triggered program task when detecting that no running program task exists in the parallel processing thread; when detecting that the running program task exists in the parallel processing thread, controlling the running program task and the started program task to be executed alternately, namely running the running program task and the started program task simultaneously.
As shown in fig. 4, an application scenario schematic diagram of program task scheduling based on parallel mode is provided.
In fig. 4, program tasks a and B are both program tasks in parallel mode. In the parallel processing thread, when the program task B is determined to be triggered, the running program task A in the parallel processing thread is detected, the program task A and the program task B are controlled to alternately obtain the execution right, and the execution result is expressed as that the program task A and the program task B run simultaneously.
In one embodiment, when the operation mode of the triggered program task is detected to be a preemption mode, starting a preemption processing thread to process the triggered program task, and further including:
detecting whether running program tasks exist in the parallel processing threads or not when detecting that the running mode of the triggered program tasks is a preemption mode;
executing the triggered program task when detecting that no running program task exists in the preemptive processing thread;
when detecting that the running program task exists in the preemption processing thread, controlling the running program task to stop executing;
and executing the triggered program task.
In a specific application, when the operation mode of the triggered program task is detected to be the preemption mode, detecting whether the running program task exists in the preemption processing thread, and when the running program task does not exist in the preemption processing thread, directly executing the triggered program task. When detecting that the running program task exists in the preemption processing thread, controlling the running program task to stop executing, distributing the execution right to the triggered program task, and executing the triggered program task.
It can be understood that after the triggered program task preempts the execution right, the program task stopped from executing still cannot be executed even if the triggered program task is finished running.
By way of example, and not limitation, after the triggered program task preempts the execution rights, if a new triggered task is detected, the running triggered program task is controlled to stop running, the execution rights are allocated to the new triggered program task, and the new triggered task is executed.
As shown in fig. 5, an application scenario schematic diagram of program task scheduling based on a preemption mode is provided.
In fig. 5, program tasks a and B are both program tasks in the preemption mode. In the preemption processing thread, when the program task B is determined to be triggered, the running program task A in the preemption processing thread is detected, the program task A is controlled to stop running, the program task B preemptively obtains the execution right, and the execution result is expressed as that the program task B runs independently.
In one embodiment, the method further comprises:
when receiving an exit program instruction, controlling all processing threads to exit the running state;
and when all the processing threads are detected to exit the running state, completing the program exiting operation.
In a specific application, in the process of processing program tasks by threads, if an instruction for exiting the program is received, all processing threads are immediately controlled to stop running all program tasks, and the running state is exited; and when detecting that all the processing threads exit the running state, controlling the main thread to exit the running state, and finishing the program exiting operation. The program exit instruction refers to a control instruction for stopping all program tasks at the current time.
According to the embodiment, the corresponding operation program is called to switch and execute based on the operation mode of the program task, so that diversified program triggering judgment and execution sequence conversion can be integrated, richer and diversified operation logic is realized, and the efficiency and convenience of program operation are improved.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic, and should not limit the implementation process of the embodiment of the present application.
Corresponding to the scheduling method of program tasks described in the above embodiments, fig. 6 shows a block diagram of a scheduling apparatus of program tasks provided in an embodiment of the present application, and for convenience of explanation, only a portion related to the embodiment of the present application is shown.
Referring to fig. 6, the scheduling apparatus 100 of the program task includes:
the detection module 101 is configured to, when detecting a plurality of program tasks, create a corresponding coroutine object for each program task, and determine an attribute of each coroutine object;
the allocation module 102 is configured to add each coroutine object to a corresponding task queue container according to the attribute, and allocate a corresponding detection interface;
and the scheduling module 103 is used for starting a corresponding processing thread to control the program task to switch and execute according to the running mode of the program task.
In one embodiment, the scheduling apparatus 100 of program tasks further includes:
the control module is used for controlling all processing threads to exit the running state when receiving an exit program instruction;
and the detection module is used for completing the operation of exiting the program when detecting that all the processing threads exit the running state.
According to the embodiment, the corresponding operation program is called to switch and execute based on the operation mode of the program task, so that diversified program triggering judgment and execution sequence conversion can be integrated, richer and diversified operation logic is realized, and the efficiency and convenience of program operation are improved.
It should be noted that, because the content of information interaction and execution process between the above devices/units is based on the same concept as the method embodiment of the present application, specific functions and technical effects thereof may be referred to in the method embodiment section, and will not be described herein.
Fig. 7 is a schematic structural diagram of a terminal device according to an embodiment of the present application. As shown in fig. 7, the terminal device 7 of this embodiment includes: at least one processor 70 (only one shown in fig. 7), a memory 71, and a computer program 72 stored in the memory 71 and executable on the at least one processor 70, the processor 70, when executing the computer program 72, performing the steps in the scheduling method embodiments of any of the various program tasks described above.
The terminal device 7 may be a computing device such as a desktop computer, a notebook computer, a palm computer, a cloud server, etc. The terminal device may include, but is not limited to, a processor 70, a memory 71. It will be appreciated by those skilled in the art that fig. 7 is merely an example of the terminal device 7 and is not limiting of the terminal device 7, and may include more or fewer components than shown, or may combine certain components, or different components, such as may also include input-output devices, network access devices, etc.
The processor 70 may be a central processing unit (Central Processing Unit, CPU) and the processor 70 may be other general purpose processors, a digital signal processor (Digital Signal Processor, DSP), an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), an off-the-shelf programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 71 may in some embodiments be an internal storage unit of the terminal device 7, such as a hard disk or a memory of the terminal device 7. The memory 71 may in other embodiments also be an external storage device of the terminal device 7, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital Card (SD), a Flash memory Card (Flash Card) or the like, which are provided on the terminal device 7. Further, the memory 71 may also include both an internal storage unit and an external storage device of the terminal device 7. The memory 71 is used for storing an operating system, application programs, boot loader (BootLoader), data, other programs, etc., such as program codes of the computer program. The memory 71 may also be used for temporarily storing data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, the specific names of the functional units and modules are only for distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
Embodiments of the present application also provide a computer readable storage medium storing a computer program which, when executed by a processor, implements steps for implementing the various method embodiments described above.
Embodiments of the present application provide a computer program product which, when run on a mobile terminal, causes the mobile terminal to perform steps that enable the implementation of the method embodiments described above.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application may implement all or part of the flow of the method of the above embodiments, and may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include at least: any entity or device capable of carrying computer program code to a photographing device/terminal apparatus, recording medium, computer Memory, read-Only Memory (ROM), random access Memory (RAM, random Access Memory), electrical carrier signals, telecommunications signals, and software distribution media. Such as a U-disk, removable hard disk, magnetic or optical disk, etc. In some jurisdictions, computer readable media may not be electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/network device and method may be implemented in other manners. For example, the apparatus/network device embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical functional division, and there may be additional divisions in actual implementation, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
The above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.

Claims (10)

1. A method for scheduling program tasks, comprising:
when a plurality of program tasks are detected, creating a corresponding coroutine object for each program task, and determining the attribute of each coroutine object, wherein the attribute comprises a trigger condition, execution content and a trigger mode;
adding each coroutine object to a corresponding task queue container according to the attribute, and distributing a corresponding detection interface, wherein each task queue container is used for storing coroutine objects with the same attribute;
starting a corresponding processing thread to control the program task to switch and execute according to the running mode of the program task; the operation modes comprise a parallel mode, a preemption mode, a mutual exclusion mode and an iteration mode.
2. The method for scheduling program tasks according to claim 1, wherein adding each coroutine object to a corresponding task queue container according to the attribute and allocating a corresponding detection interface comprises:
adding each coroutine object to a corresponding task queue container according to the triggering mode;
and according to the type of the trigger data in the trigger condition, distributing a corresponding detection interface for each coroutine object.
3. The method for scheduling a program task according to claim 1, wherein starting a corresponding processing thread to control the program task to switch execution according to an operation mode of the program task comprises:
when the trigger data is detected to meet the trigger condition, determining that the corresponding program task is a triggered program task, and determining an operation mode of the triggered program task;
and starting the corresponding processing thread to schedule and control the triggered program task to switch and execute according to the running mode.
4. A method of scheduling program tasks according to claim 3, wherein said initiating a corresponding processing thread schedule according to said run mode controls said triggered program task to switch execution, comprising:
when the running mode of the triggered program task is detected to be a parallel mode, starting a parallel processing thread to process the triggered program task;
when the operation mode of the triggered program task is detected to be a preemption mode, starting a preemption processing thread to process the triggered program task;
when the running mode of the triggered program task is detected to be the mutual exclusion mode, starting a mutual exclusion processing thread to process the triggered program task;
and when the operation mode of the triggered program task is detected to be an iteration mode, starting an iteration processing thread to process the triggered program task.
5. The method for scheduling a program task according to claim 4, wherein when the running mode of the triggered program task is detected to be a parallel mode, starting a parallel processing thread to process the triggered program task includes:
detecting whether a running program task exists in a parallel processing thread or not when detecting that the running mode of the triggered program task is a parallel mode;
executing the triggered program task when detecting that no running program task exists in the parallel processing thread;
and when detecting that the running program task exists in the parallel processing thread, controlling the running program task and the triggered program task to be alternately executed.
6. The method for scheduling a program task according to claim 4, wherein when the operation mode of the triggered program task is detected to be a preemption mode, starting a preemption processing thread to process the triggered program task, further comprising:
detecting whether running program tasks exist in the parallel processing threads or not when detecting that the running mode of the triggered program tasks is a preemption mode;
executing the triggered program task when detecting that no running program task exists in the preemptive processing thread;
when detecting that the running program task exists in the preemption processing thread, controlling the running program task to stop executing;
and executing the triggered program task.
7. A method of scheduling program tasks according to any one of claims 1 to 6, characterised in that the method further comprises:
when receiving an exit program instruction, controlling all processing threads to exit the running state;
and when all the processing threads are detected to exit the running state, completing the program exiting operation.
8. A scheduling apparatus for program tasks, comprising:
the detection module is used for creating a corresponding coroutine object for each program task when detecting a plurality of program tasks, and determining the attribute of each coroutine object, wherein the attribute comprises a trigger condition, execution content and a trigger mode;
the allocation module is used for adding each coroutine object to a corresponding task queue container according to the attribute, allocating a corresponding detection interface, and storing coroutine objects with the same attribute in each task queue container;
the scheduling module is used for starting a corresponding processing thread to control the program task to switch and execute according to the running mode of the program task; the operation modes comprise a parallel mode, a preemption mode, a mutual exclusion mode and an iteration mode.
9. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1 to 7 when executing the computer program.
10. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the method according to any one of claims 1 to 7.
CN202110350211.8A 2021-03-31 2021-03-31 Program task scheduling method and device, terminal equipment and readable storage medium Active CN112988355B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110350211.8A CN112988355B (en) 2021-03-31 2021-03-31 Program task scheduling method and device, terminal equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110350211.8A CN112988355B (en) 2021-03-31 2021-03-31 Program task scheduling method and device, terminal equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN112988355A CN112988355A (en) 2021-06-18
CN112988355B true CN112988355B (en) 2023-12-15

Family

ID=76338737

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110350211.8A Active CN112988355B (en) 2021-03-31 2021-03-31 Program task scheduling method and device, terminal equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN112988355B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113934409B (en) * 2021-10-15 2022-05-20 深圳奥睿图科技有限公司 Programming method and device and computer readable storage medium

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102612157A (en) * 2012-02-24 2012-07-25 哈尔滨工业大学 Embedded real-time scheduling system of wireless sensor network
CN108549583A (en) * 2018-04-17 2018-09-18 成都致云科技有限公司 Big data processing method, device, server and readable storage medium storing program for executing
CN109634728A (en) * 2018-11-16 2019-04-16 深圳市云智融科技有限公司 Job scheduling method, device, terminal device and readable storage medium storing program for executing
CN110046809A (en) * 2019-04-02 2019-07-23 中国工商银行股份有限公司 Job scheduling method and device
CN110955503A (en) * 2018-09-27 2020-04-03 深圳市创客工场科技有限公司 Task scheduling method and device
CN111078436A (en) * 2019-12-18 2020-04-28 上海金仕达软件科技有限公司 Data processing method, device, equipment and storage medium
CN111209046A (en) * 2019-12-25 2020-05-29 北京时代民芯科技有限公司 Multitask-oriented embedded SPARC processor operating system design method
CN111736987A (en) * 2020-05-29 2020-10-02 山东大学 Task scheduling method based on GPU space resource sharing
CN111831410A (en) * 2020-07-01 2020-10-27 Oppo广东移动通信有限公司 Task processing method and device, storage medium and electronic equipment

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102612157A (en) * 2012-02-24 2012-07-25 哈尔滨工业大学 Embedded real-time scheduling system of wireless sensor network
CN108549583A (en) * 2018-04-17 2018-09-18 成都致云科技有限公司 Big data processing method, device, server and readable storage medium storing program for executing
CN110955503A (en) * 2018-09-27 2020-04-03 深圳市创客工场科技有限公司 Task scheduling method and device
CN109634728A (en) * 2018-11-16 2019-04-16 深圳市云智融科技有限公司 Job scheduling method, device, terminal device and readable storage medium storing program for executing
CN110046809A (en) * 2019-04-02 2019-07-23 中国工商银行股份有限公司 Job scheduling method and device
CN111078436A (en) * 2019-12-18 2020-04-28 上海金仕达软件科技有限公司 Data processing method, device, equipment and storage medium
CN111209046A (en) * 2019-12-25 2020-05-29 北京时代民芯科技有限公司 Multitask-oriented embedded SPARC processor operating system design method
CN111736987A (en) * 2020-05-29 2020-10-02 山东大学 Task scheduling method based on GPU space resource sharing
CN111831410A (en) * 2020-07-01 2020-10-27 Oppo广东移动通信有限公司 Task processing method and device, storage medium and electronic equipment

Also Published As

Publication number Publication date
CN112988355A (en) 2021-06-18

Similar Documents

Publication Publication Date Title
US9298438B2 (en) Profiling application code to identify code portions for FPGA implementation
CN110489213B (en) Task processing method and processing device and computer system
CN113835895B (en) Thread and/or virtual machine scheduling for cores with different capabilities
US8745362B2 (en) Operating system aware branch predictor using a dynamically reconfigurable branch history table
WO2015136283A1 (en) Exception handling in microprocessor systems
WO2013192231A1 (en) Managing use of a field programmable gate array by multiple processes in an operating system
CN111831410A (en) Task processing method and device, storage medium and electronic equipment
US11687242B1 (en) FPGA board memory data reading method and apparatus, and medium
US8528006B1 (en) Method and apparatus for performing real-time commands in a non real-time operating system environment
CN114168271B (en) Task scheduling method, electronic device and storage medium
CN107436810A (en) A kind of resource for computer system dispatching method and device
CN111831438A (en) Resource allocation method, device, storage medium and electronic equipment
CN115033352A (en) Task scheduling method, device and equipment for multi-core processor and storage medium
JP2020053013A (en) Request processing method and device
CN112988355B (en) Program task scheduling method and device, terminal equipment and readable storage medium
CN106789337B (en) Network performance optimization method of KVM
CN109840151B (en) Load balancing method and device for multi-core processor
CN105677481A (en) Method and system for processing data and electronic equipment
CN110837415A (en) Thread scheduling method and device based on RISC-V multi-core processor
CN113253978A (en) Embedded software development method, model, electronic device, and medium
CN113495787A (en) Resource allocation method, device, storage medium and electronic equipment
CN116661964A (en) Task processing method and device and electronic equipment
CN115268713A (en) Thread identification method and device, storage medium and electronic equipment
CN114911538A (en) Starting method of running system and computing equipment
CN112673354B (en) System state detection method, system state device and terminal equipment

Legal Events

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