Task scheduling method and device, electronic equipment and storage medium

By introducing a task control interface and a typeless pointer structure into the Task framework, the problems of inflexible task scheduling and memory consumption due to data sharing are solved, thereby achieving flexibility and resource optimization in task scheduling.

CN115373815BActive Publication Date: 2026-03-24PING AN TECH (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-13
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

The existing Task framework lacks flexibility in scheduling tasks. Parameters in the task table cannot be modified during task execution, resulting in inflexible scheduling between tasks. Furthermore, data sharing between tasks relies on global variables, consuming a large amount of memory resources.

Method used

By setting up a task control interface in the service layer, the task identifier can be obtained and the task parameters in the task table can be modified, thereby achieving flexibility in task scheduling. Furthermore, by creating a structure with an untyped pointer to pass shared data, the use of global variables can be reduced.

Benefits of technology

It improves the flexibility of task scheduling within the Task framework, reduces memory resource consumption, and optimizes the modification of task table parameters and data sharing mechanisms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115373815B_ABST
    Figure CN115373815B_ABST
Patent Text Reader

Abstract

The embodiment provides a task scheduling method and device, electronic equipment and a storage medium, and belongs to the technical field of framework research. The method comprises the following steps: obtaining a task identification number of a second task; sending the task identification number of the second task to a task control interface; modifying a task parameter in a task table through the task control interface according to the task identification number of the second task, obtaining a first task parameter; and performing task scheduling according to the first task parameter. Through the task control interface arranged in the service layer, the task parameter in the task table can be contacted during task running, the task parameter is modified in real time, the task running state is changed, and the flexibility of rescheduling between tasks is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of framework development, and particularly relates to a task scheduling method and device, a computer device and a storage medium. BACKGROUND

[0002] Task framework is widely used in embedded devices because of its simple transplantation and low performance loss. However, a common Task framework runs tasks in the form of polling a task table, and the task table stores related information of each task to determine the running order between tasks. However, the related parameters in the task table are saved in a specific structure, which is isolated from the data of other tasks. During the running of each task, the related parameters in the task table cannot be modified. This means that in the common Task framework, the start time and end time of each task are determined from the beginning and cannot be modified. Only after the current task ends, the processor starts the next task by polling the task table, which leads to the problem of lack of flexibility in scheduling between tasks. SUMMARY

[0003] The main purpose of the embodiments of the present disclosure is to provide a task scheduling method and device, an electronic device and a computer readable storage medium, which can improve the flexibility of task scheduling between tasks.

[0004] To achieve the above purpose, a first aspect of the embodiments of the present disclosure provides a task scheduling method applied to a task scheduling device based on a Task framework, the task scheduling device based on the Task framework comprising a service layer, the service layer comprising a task control interface, and the method comprising:

[0005] obtaining a task identification number of a second task;

[0006] sending the task identification number of the second task to the task control interface;

[0007] modifying a task parameter in a task table according to the task identification number of the second task through the task control interface to obtain a first task parameter;

[0008] scheduling tasks according to the first task parameter.

[0009] In some embodiments, before the task identification number of the second task is sent to the task control interface, the method further comprises:

[0010] detecting whether there is a schedulable relationship between the first task and the second task;

[0011] if the detection result is that there is a schedulable relationship between the first task and the second task, sending a task identification number of the second task to a task control interface;

[0012] The first task is a currently running task, and the second task is any task stored in the task table except the first task.

[0013] In some embodiments, the first task parameter includes a reload time, a repeat reload identifier, and a current time.

[0014] In some embodiments, the task scheduling according to the first task parameter includes:

[0015] polling all task parameters in the task table;

[0016] obtaining a service request sent by the first task parameter;

[0017] performing task scheduling according to the service request.

[0018] In some embodiments, after the first task parameter is obtained by modifying the task parameter in the task table according to the task identification number of the second task through the task control interface, the method further includes:

[0019] determining whether a data value of the first task parameter is within a preset range;

[0020] if the data value of the first task parameter is within the preset range, performing task scheduling according to the first task parameter;

[0021] if the data value of the first task parameter is not within the preset range, discarding the first task parameter and returning an error message.

[0022] In some embodiments, after the task scheduling according to the first task parameter, the method further includes:

[0023] running the second task;

[0024] detecting whether to continue running the second task;

[0025] if it is detected that the second task is no longer to be run, modifying the task parameter in the task table according to a second task parameter and performing task scheduling;

[0026] The second task parameter is a task parameter stored in the task table before the task parameter in the task table is modified according to the task identification number of the second task through the task control interface, and the second task parameter is stored in a preset address in advance.

[0027] In some embodiments, the task scheduling according to the first task parameter further comprises:

[0028] obtaining a storage address of the first data in the first task;

[0029] creating a typeless pointer and pointing the typeless pointer to the storage address of the first data to obtain a first data address pointer;

[0030] constructing the first data address pointer into a structure;

[0031] passing the structure as a parameter to the second task for parsing;

[0032] the second task obtains the first data address pointer;

[0033] the second task obtains the first data according to the first data address pointer;

[0034] wherein the first data is data in the first task that needs to be shared with the second task.

[0035] A second aspect of the embodiments of the present disclosure provides a task scheduling device, the device comprising:

[0036] an obtaining unit configured to obtain a task identification number of a second task;

[0037] an information transmission unit configured to send the task identification number of the second task to the task control interface;

[0038] a control unit configured to modify a task parameter of a task table according to the task identification number of the second task to obtain a first task parameter;

[0039] a processing unit configured to perform task scheduling according to the first task parameter.

[0040] A third aspect of the embodiments of the present disclosure provides an electronic device, comprising a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for realizing connection communication between the processor and the memory, wherein the program is run by the processor to realize the task scheduling method according to any one of the first aspect of the embodiments of the present disclosure.

[0041] A fourth aspect of the embodiments of the present disclosure provides a storage medium, which is a computer readable storage medium, for computer readable storage, characterized in that the storage medium stores one or more programs, and the one or more programs are executable by one or more processors to realize the task scheduling method according to any one of the first aspect of the embodiments of the present disclosure.

[0042] The task scheduling method, apparatus, electronic device, and storage medium proposed in this disclosure involve: obtaining a task identifier for a second task; sending the task identifier to a task control interface; modifying task parameters in a task table based on the task identifier to obtain first task parameters; and performing task scheduling based on the first task parameters. This disclosure, by setting a task control interface at the service layer, allows the apparatus to modify task parameters in the task table during task execution. After modifying the task parameters, the running status of the current task and related tasks is changed, thereby enabling task scheduling during task execution and improving the flexibility of task scheduling within the Task framework. Attached Figure Description

[0043] Figure 1 This is a flowchart of the task scheduling method provided in the embodiments of this disclosure;

[0044] Figure 2 yes Figure 1 A flowchart of the steps preceding step S200 is also included;

[0045] Figure 3 yes Figure 1 A flowchart of the steps that follow step S300;

[0046] Figure 4 yes Figure 1 The flowchart of step S400 in the middle;

[0047] Figure 5 yes Figure 1 A flowchart of the steps that follow step S400 is also included;

[0048] Figure 6 yes Figure 1 A flowchart of the steps preceding step S400 is also included;

[0049] Figure 7 This is a block diagram of the module structure of the task scheduling device provided in the embodiments of this disclosure;

[0050] Figure 8 This is a schematic diagram of the hardware structure of a computer device provided in an embodiment of this disclosure. Detailed Implementation

[0051] To make the objectives, technical solutions, and advantages of this invention clearer, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only for explaining this application and are not intended to limit this application.

[0052] It should be noted that although the functional modules are divided in the device schematic diagram, and the logical order is shown in the flowchart, in some cases, the steps shown or described can be run in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", and the like in the description and claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0053] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in the specification herein is for describing the embodiments of the application only and is not intended to limit the application.

[0054] In addition, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the present disclosure. One skilled in the relevant art will recognize, however, that the technology solution of the present disclosure can be practiced without one or more of the specific details, or with other methods, components, devices, steps, etc. In other instances, well-known methods, devices, implementations, or operations are not shown or described in detail to avoid obscuring aspects of the present disclosure.

[0055] The block diagrams shown in the accompanying drawings are only functional entities, and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0056] The flowcharts shown in the accompanying drawings are only exemplary illustrations, and do not necessarily include all contents and operations / steps, nor do they necessarily run in the order described. For example, some operations / steps can be further divided, and some operations / steps can be combined or partially combined, so the actual running order can be changed according to the actual situation.

[0057] First, some terms involved in the present application are analyzed:

[0058] Task framework: a thread pool task scheduling framework, through the reuse of timing multiplexing, the timer count, timing the change of flag bit, and then the main program judges the true or false of the flag, realizes the running of different tasks at different times. It has the advantages of simple transplantation and low performance loss, and is commonly used in embedded device development.

[0059] Polling: A way for the CPU to decide how to service peripheral devices, also known as "Programmed I / O". The concept of polling is that the CPU periodically issues a query to each peripheral device in turn to see if it needs service, and if so, services it and then queries the next peripheral.

[0060] task_struct: An important data structure in the Linux kernel, it is the process descriptor for each process and thread (a thread is also a process in the kernel). The task_struct stores almost all important information about a process, such as its name, uid, stack address pointer, parent process pointer, and so on.

[0061] thread: The smallest unit of operation that can be scheduled by the operating system. It is contained within a process and is the actual unit of execution within the process. A thread refers to a single sequence of control flow within a process. A process can have multiple threads, each running different tasks in parallel. In Unix System V and SunOS, it is also known as a lightweight process, but lightweight process refers more to a kernel thread, while user threads are referred to as threads, which are the basic unit of scheduling and dispatching.

[0062] Process: A running program on a set of data, it is the basic unit of resource allocation and scheduling, and is the basis of operating system structure. In the early process-oriented computer structure, the process is the basic running entity of the program; in the current thread-oriented computer structure, the process is a container for threads, and a process can include multiple threads.

[0063] Task: Refers to an activity completed by software. A task can be either a process or a thread. In short, it refers to a series of operations that work together to achieve a certain purpose. For example, reading data and putting data into memory. This task can be implemented as a process, or as a thread (or as an interrupt task).

[0064] Pointer: also known as memory address, pointer variable is used to store memory address, in the same CPU architecture, the length of the storage unit occupied by different types of pointer variable is the same, while the length of the storage space occupied by the variable storing data is different due to the type of data. Pointer describes the location of data in memory, indicating the relative distance value of the starting position of the occupied storage space. In C / C++ language, pointer is generally considered as pointer variable, the content of pointer variable stores the first address of the object it points to, and the object it points to can be variable (pointer variable is also variable), array, function and other occupied storage entities.

[0065] Struct: a composite data type, which is a data collection composed of a series of data with the same type or different types.

[0066] Service: equivalent to the role of intermediate class, the intermediate factory class provides another general permissive interface for the caller to use the methods exposed by the interface, without worrying about the changes of architecture or underlying.

[0067] Dependency: that is, class A references class B to complete a function, which is mainly reflected in the return value, parameter, local variable or static method call of a member function of class A in the code. Dependency relationship is one-way, and only when the method of the class is called, the dependency relationship is generated, and it ends with the end of the method, that is, dependency is a temporary relationship between objects.

[0068] Association: including one-way association, two-way association, self-association and multi-dimensional association, which reflects a strong dependency relationship between two classes or classes and interfaces at the semantic level. Compared with dependency relationship, association is a long-term and not temporary relationship, and the relationship between two classes is equal. At the code level, the associated class B appears in the form of class attribute in the associated class A, or the associated class A references a global variable of type associated class B.

[0069] In recent years, embedded devices play an increasingly important role in daily life. In order to ensure the stability and reliability of the whole system, it is necessary to choose a relatively appropriate software framework to run complex tasks during development. Task framework is commonly used in embedded device development due to its simple porting, low performance loss and other advantages in meeting common development needs. However, due to the limitation of the design structure of the framework, the related parameters of the task table are saved in a specific structure, and the data between the related parameters of the task table and each task is isolated. During the running process of the task, the related parameters of the task table cannot be modified, and the rescheduling between tasks lacks flexibility.

[0070] In addition, the data between the various tasks is also isolated under this framework, and the communication between them is blocked. When multiple tasks need to share part of the data, a global variable needs to be set to pass parameters to achieve data sharing. When the amount of data to be shared is large, multiple global variables need to be set, thereby occupying a large amount of memory space and causing resource waste.

[0071] Based on this, the task scheduling method and device, the electronic device, and the storage medium provided in the embodiments of the present disclosure can improve the flexibility of task rescheduling under the Task framework.

[0072] The task scheduling method and device, the electronic device, and the storage medium provided in the embodiments of the present disclosure are described in detail as follows. First, the task scheduling method in the embodiments of the present disclosure is described.

[0073] The task scheduling method provided in the embodiments of the present disclosure can be applied to an embedded terminal based on a task framework, can be applied to a server end based on a task framework, and can also be software running in a terminal or a server end. In some embodiments, the terminal can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart watch, or the like. The server end can be configured as a separate physical server, can be configured as a server cluster or a distributed system formed by multiple physical servers, or can be configured as a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs, and big data and artificial intelligence platforms. The software can be an application that implements the task scheduling method, but is not limited to the above forms.

[0074] The embodiments of the present disclosure can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld devices or portable devices, tablet devices, multi-processor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, small computers, mainframe computers, distributed computing environments including any of the above systems or devices, and the like. The present application can be described in the general context of computer-executable instructions run by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. The present application can also be practiced in a distributed computing environment in which tasks are performed by remote processing devices connected by a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.

[0075] Reference Figure 1According to the task scheduling method of the first aspect of the embodiments of the present disclosure, the following steps can be included, but are not limited to steps S100-S400.

[0076] In step S100, the task identifier of the second task is obtained.

[0077] In step S200, the task identifier of the second task is sent to the task control interface.

[0078] In step S300, the task parameters in the task table are modified according to the task identifier of the second task through the task control interface, and the first task parameters are obtained.

[0079] In step S400, the task is scheduled according to the first task parameters.

[0080] In step S100 of some embodiments, the task identifier of the second task is obtained, wherein the second task can be any task to be run in the system, the task identifier is generated according to a system preset rule and is pre-assigned to each task, the task identifier assigned to each task is different, the task identifier and the task are one-to-one corresponding, and based on this, the task identifier can be used as an identifier to distinguish each task. The specific form of the task identifier can be Arabic numerals, uppercase letters, lowercase letters, punctuation marks, or a combination of at least two of them, which is determined by the system preset rule. For example, the task identifier of the second task can be "Task_0002".

[0081] In step S200 of some embodiments, the task identifier of the second task is sent to the task control interface, wherein the task control interface is arranged in the service layer, and the service layer directly contacts the task parameters.

[0082] In step S300 of some embodiments, the task parameters in the task table are modified according to the task identifier of the second task through the task control interface, and the first task parameters are obtained. The task table stores task parameters including reload time, repeat reload identifier, and current time, and these parameters are stored in a specific structure. In addition, the task table structure also stores the process name, uid, stack address pointer, parent process pointer, and almost all process-related important information of the process. Specifically, after the control interface receives the task identifier of the second task, the task-related parameters including the reload time, the repeat reload identifier, and the current time stored therein are modified, and the modified reload time, repeat reload identifier, and current time are recorded as the first task parameters.

[0083] In step S400 of some embodiments, the task is scheduled according to the first task parameter. When the task-related parameters in the task table, such as the overload time, the repeated overload identifier, and the current time, are modified, the processor adjusts the running time of the task, the state of whether the task is running, and the like according to the modified task-related parameters, i.e., the first task parameter, so as to suspend or directly end the running of the current task and start running the task corresponding to the first task parameter.

[0084] In some embodiments, as shown in FIG. 2, step S200 is followed by, but not limited to, steps S210 to S220. Figure 2

[0085] In step S210, it is detected whether there is a schedulable relationship between the first task and the second task.

[0086] In step S220, if the detection result is that there is a schedulable relationship between the first task and the second task, the task identifier of the second task is sent to the task control interface.

[0087] In step S210 of some embodiments, it is detected whether there is a schedulable relationship between the first task and the second task, wherein the first task refers to a task currently running by the system, the second task refers to any one of the tasks stored in the task table and to be run, and the schedulable relationship can be one of the relationships such as dependency and association, or a schedulable relationship forcibly added by the system, such as actively pausing the process of the current first task and starting the process of the second task when the first task runs to a certain node.

[0088] In step S220 of some embodiments, if the detection result is that there is a schedulable relationship between the first task and the second task, the task identifier of the second task is sent to the task control interface, wherein the system can send the task identifier of the second task to the task control interface through a message bus.

[0089] In some embodiments, as shown in FIG. 3, step S300 is followed by, but not limited to, steps S310 to S330. Figure 3

[0090] In step S310, it is judged whether the data value of the first task parameter is within a preset range.

[0091] In step S320, if the data value of the first task parameter is within the preset range, the task is scheduled according to the first task parameter.

[0092] In step S330, if the data value of the first task parameter is not within the preset range, the first task parameter is discarded, and an error message is returned.

[0093] ​​In step S310 of some embodiments, it is judged whether the first task parameter is within the preset range. For example, it is judged whether the current time should be a parameter conforming to the time format, whether the overload time is negative, etc.

[0094] In step S330 of some embodiments, if the data value of the first task parameter is not within the preset range, the first task parameter is discarded, and an error message is returned. For example, when the current time in the task parameter is a parameter not conforming to the time format or a parameter exceeding the normal time range, for example, the current time parameter contains an English letter string "abc" with unclear meaning or represents a negative time, it is judged that the first task parameter is not within the preset range. In this case, if the task scheduling is still performed according to the first task parameter, unexpected BUGs may occur. Therefore, in this case, the system should discard the first task parameter at this time and report the error message to the system.

[0095] In some embodiments, as shown in FIG. 4, step S400 includes but is not limited to steps S410 to S430. Figure 4

[0096] In step S410, all task parameters in the task table are polled.

[0097] In step S420, a service request issued by the first task parameter is acquired.

[0098] In step S430, task scheduling is performed according to the service request.

[0099] In step S410 of some embodiments, all task parameters in the task table are polled, wherein the task table stores almost all process parameters including the overload time, the repeated overload identifier, the current time, and the process name, uid, stack address pointer, parent process pointer, etc. of the process. Polling means that the CPU successively inquires whether the task parameters in the task table need the CPU to provide services for them. If a service request is received, the CPU provides the service. If no request is received, the next one is inquired, and the cycle is continued.

[0100] In step S420 of some embodiments, a service request issued by the first task parameter is acquired, wherein the modified first task parameter does not correspond to the currently running first task, and then a service request is issued to the CPU to change the running state of the current task, suspend or end the current running parameter not corresponding to the first task parameter, and start the running of the second task corresponding to the first task parameter.

[0101] In step S430 of some embodiments, task scheduling is performed according to the service request. After receiving the service request issued by the first task parameter, the processor performs the corresponding operation, suspends the first task, and starts the second task. ​

[0102] In some embodiments, as shown in Figure 5 S400, further comprising but not limited to steps S510-S530.

[0103] S510, running a second task;

[0104] S520, detecting whether to continue running the second task;

[0105] S530, if it is detected that the second task is no longer running, modifying the task parameters in the task table according to the second task parameters, and performing task scheduling.

[0106] In step S510 of some embodiments, a second task is run. The second task is a task in the task table corresponding to the first task parameters in the above step S400. After the task scheduling according to the first task parameters in step S400, the system suspends or terminates the running of the first task and starts running the second task.

[0107] In step S520 of some embodiments, it is detected whether to continue running the second task. It can be understood that, since the running process of the first task is suspended or terminated in the foregoing steps and the running process of the second task is started, in order to ensure that the running process of the first task is continued after the running of the second task ends, the running state of the second task is monitored in real time after the running process of the second task is started.

[0108] In step S530 of some embodiments, if it is detected that the second task is no longer running, the task parameters in the task table are modified according to the second task parameters, and task scheduling is performed. The second task parameters are the task parameters stored in the task table before the task parameters in the task table are modified according to the task identification number of the second task through the task control interface. The second task parameters are stored in a preset address in advance, that is, the second task parameters record the node before the first task is suspended or terminated. When the running of the first task is interrupted or terminated before the second task starts running, the processor should be reset to the node before the first task is interrupted or terminated to continue the running process of the first task after the second task ends running.

[0109] In some embodiments, as shown in Figure 6 S400, further comprising but not limited to steps S610-S660.

[0110] S610, obtaining the storage address of the first data in the first task;

[0111] Step S620, creating a typeless pointer and pointing the typeless pointer to the storage address of the first data to obtain a first data address pointer;

[0112] Step S630, constructing the first data address pointer into a structure;

[0113] Step S640, passing the structure as a parameter to the second task for parsing;

[0114] Step S650, the second task obtaining the first data address pointer;

[0115] Step S660, the second task obtaining the first data according to the first data address pointer.

[0116] In step S610 of some embodiments, the storage address of the first data in the first task is obtained. The first data refers to the data in the first task that needs to be shared with the second task. It can be understood that the first data can be one data or at least two data, which is determined by the amount of data that needs to be shared with the second task in the first task.

[0117] In step S620 of some embodiments, a typeless pointer is created and pointed to the storage address of the first data to obtain a first data address pointer. Since the data type of the first data can be various, such as integer data (int, short, long), floating point data (float, double), and character data (char), different types of data have different requirements for pointer addressing range, therefore, a typeless pointer, i.e. a general pointer, is created here, which can point to any data type.

[0118] In step S630 of some embodiments, the first data address pointer is constructed into a structure. As described in step S620 above, since the first data can be of various data types, its address pointer can also be of various data types of pointers, based on which a data collection body that can include various data types needs to be constructed, and the structure can meet this requirement, therefore, the first data address pointer is constructed into a structure.

[0119] In step S640 of some embodiments, the structure is passed as a parameter to the second task for parsing. In step S630 above, the first data address pointer is constructed into a structure, and then the structure is passed as a parameter to the second task through structure addressing, and the structure is parsed in the second task to extract the first data address pointer, so that the second task can obtain the first data address pointer.

[0120] In step S660 of some embodiments, the second task acquires the first data according to the first data address pointer. In steps S640 to S650, the second task acquires the first data address pointer. However, in step S620, the first data is pointed to by creating a typeless pointer. Since the typeless pointer does not have a specific data type, it can only point to the starting address of a variable and cannot specify the addressing range of the pointer. Therefore, during use, the typeless pointer needs to be converted into a specific type of pointer by type conversion according to the known byte length of the variable. For example, if the known variable is 4 bytes long starting from a specified address, the typeless pointer needs to be converted into an int type pointer. Then, according to the variable storage starting address and the addressing range, the accurate first data is acquired.

[0121] The task scheduling device based on the Task framework provided in the embodiments of the present disclosure includes a service layer, and the service layer includes a task control interface. The task control interface acquires the task identification number of the second task, sends the task identification number of the second task to the task control interface, modifies the task parameters in the task table according to the task identification number of the second task through the task control interface to obtain first task parameters, and performs task scheduling according to the first task parameters. In the embodiments of the present disclosure, the task control interface is arranged in the service layer, so that the related task parameters in the task table can be modified in real time during the running of each task. By modifying the related task parameters, the task running state is changed, so that the rescheduling between tasks is realized, and the flexibility of the rescheduling between tasks under the task framework is effectively improved.

[0122] In addition, the embodiments of the present disclosure consider that in the traditional task framework, the data between tasks is isolated from each other, and the implementation of cross-task data sharing depends on global variables. When the number of global variables is large, too much memory is occupied, causing resource waste. In the embodiments of the present disclosure, a pointer is created to point to the address of the data to be shared. In the process of rescheduling between tasks, the pointer is constructed as a structure and passed to the second task as a parameter. Then, in the second task, the storage address of the data to be shared is acquired according to the pointer, so that the data to be shared is acquired. By this method, the setting of global variables can be reduced, and the memory occupied by the pointer is less than that occupied by the global variables, so that the memory resources can be saved.

[0123] The embodiments of the present disclosure also provide a task scheduling device 700, as shown in Figure 7As shown, the task scheduling method can be implemented, and the task scheduling apparatus includes an acquisition unit 710, an information transmission unit 720, a control unit 730, and a processing unit 740. The acquisition unit 710 is configured to acquire a task identification number of a second task. The information transmission unit 720 is configured to send the task identification number of the second task to the task control interface. The control unit 730 is configured to modify a task parameter of a task table according to the task identification number of the second task to obtain a first task parameter. The processing unit 740 is configured to perform task scheduling according to the first task parameter.

[0124] The task scheduling apparatus 700 of the embodiment of the present disclosure is used to execute the task scheduling method in the above-described embodiments, and the specific processing process is the same as that of the task scheduling method in the above-described embodiments, which will not be repeated here.

[0125] The embodiment of the present disclosure further provides a computer device 800, which includes:

[0126] at least one processor, and

[0127] a memory in communication connection with the at least one processor; wherein

[0128] The memory stores instructions, and the instructions are executed by the at least one processor, so that the at least one processor implements the method in any one of the embodiments of the first aspect of the present disclosure when executing the instructions.

[0129] The following will be described in detail Figure 8 The hardware structure of the computer device will be described in detail. The computer device includes a processor 810, a memory 820, an input / output interface 830, a communication interface 840, and a bus 850.

[0130] The processor 810 can be implemented in the form of a general-purpose central processing unit (CPU), a microprocessor, an application specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute related programs to implement the technical solutions provided by the embodiments of the present disclosure.

[0131] The memory 820 can be implemented in the form of a read only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 820 can store an operating system and other application programs. When the technical solutions provided by the embodiments of the present disclosure are implemented by software or firmware, the related program codes are saved in the memory 820 and are called and executed by the processor 810 to implement the task scheduling method of the embodiments of the present disclosure.

[0132] The input / output interface 830 is configured to realize information input and output.

[0133] The communication interface 840 is configured to realize the communication interaction between the device and other devices, which can be realized through wired mode (for example, USB, network cable, etc.) or wireless mode (for example, mobile network, WIFI, Bluetooth, etc.).

[0134] The bus 850 is configured to transmit information between various components (for example, the processor 810, the memory 820, the input / output interface 830 and the communication interface 840) of the device.

[0135] The processor 810, the memory 820, the input / output interface 830 and the communication interface 840 are connected to each other through the bus 850 to realize the communication connection between the device.

[0136] The embodiments described in the embodiments of the present disclosure are used to more clearly illustrate the technical solutions of the embodiments of the present disclosure, and do not constitute a limitation on the technical solutions provided by the embodiments of the present disclosure. Those skilled in the art can know that, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of the present disclosure are also applicable to similar technical problems.

[0137] Those skilled in the art can understand that, Figures 1 to 8 The technical solutions shown in the above description do not constitute a limitation on the embodiments of the present disclosure, and can include more or fewer steps than those shown in the figure, or combine certain steps, or different steps.

[0138] The device embodiments described above are only schematic, and the units described as separate components can or can not be physically separate, that is, they can be located in one place, or distributed on multiple network units. According to actual needs, part or all of the modules can be selected to realize the purpose of the embodiments of the present disclosure.

[0139] Those skilled in the art can understand that all or some steps in the above disclosed method, the function modules / units in the system and the device can be implemented as software, firmware, hardware and their appropriate combinations.

[0140] The terms "first", "second", "third", "fourth", and the like in the description and in the claims of this application, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the use of the terms so termed is interchangeable under appropriate circumstances such that the embodiments of the application described herein are, for example, capable of orderly or chronological mundane operation, reverse order operation, based on circuitry availability, based on stated preference or the like, and that "default" or other orderings are thus permissible. Further, the terms "comprise", "comprising", "include", "including", and the like, are specifically intended to be open-ended. That is, references to individual steps and the like do not suhstantially exclude the presence of two or more of a given step or its integral presence in the process, method, system, article, or apparatus having been made with a wider scope. The use of notation such as "first", "second", "third", etc. does not generally limit the areas, but is used to connect like elements or to distinguish one claim from another. These terms can be used interchangeably when appropriate. Terms concerning the relative position of elements can be interpreted such that their use adheres to their normal meaning, but they can also be interpreted to mean the opposite according to specific claims.

[0141] It should be understood that, in the application, "at least one" refers to one or more, and "multiple" refers to two or more. "And / or" is used to describe the relationship between associated objects, which means that there can be three relationships, for example, "A and / or B" can mean that there are only A, only B, and A and B at the same time. Where A and B can be singular or plural. The character " / " generally represents an "or" relationship between the front and back associated objects. "At least one of the following" or similar expressions means any combination of these items, including any combination of single or multiple items. For example, at least one of a, b or c, can mean a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0142] In several embodiments provided by the application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the above-described device embodiments are only illustrative, for example, the division of the units is only a logical functional division, and actual implementation can have another division manner, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not run. In addition, the coupling or direct coupling or communication connection between the displayed or discussed each other can be indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.

[0143] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or they can be distributed on multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment of the application.

[0144] In addition, each of the functional units in the embodiments of the present application can be integrated in one processing unit, or each unit can exist alone physically, or two or more units can be integrated in one unit. The integrated unit can be implemented in the form of hardware, or in the form of a software functional unit.

[0145] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on such an understanding, the technical solutions of the present application essentially, or the part that contributes to the prior art, or all or a part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes multiple instructions used to cause a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the embodiments of the present application. The foregoing storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk, and various program storage media.

[0146] The preferred embodiments of the present application are described above with reference to the accompanying drawings, and are not intended to limit the scope of the present application. Any modification, equivalent replacement and improvement made by those skilled in the art without departing from the scope and essence of the present application shall be within the scope of the present application.

Claims

1. A task scheduling method, applied to a task scheduling device based on a Task framework, characterized in that, The task scheduling device based on the Task framework includes a service layer, the service layer includes a task control interface, and the method includes: Obtain the task identifier for the second task; Send the task identifier of the second task to the task control interface; Based on the task identifier of the second task, the task parameters in the task table are modified through the task control interface to obtain the first task parameters; Obtain the storage address of the first data in the first task; Create an untyped pointer and point the untyped pointer to the storage address of the first data to obtain multiple first data address pointers; Construct the first data address pointer into a structure; The structure is passed as a parameter to the second task for parsing; wherein, the second task obtains the first data address pointer, and the second task obtains the first data according to the first data address pointer, and the first data is data that needs to be shared between the first task and the second task; Task scheduling is performed based on the first task parameters.

2. The task scheduling method according to claim 1, characterized in that, Before sending the task identifier of the second task to the task control interface, the method further includes: Detect whether there is a schedulable relationship between the first task and the second task; If the detection result indicates that there is a schedulable relationship between the first task and the second task, the task identifier of the second task is sent to the task control interface. Wherein, the first task is the currently running task, and the second task is any task stored in the task table other than the first task.

3. The task scheduling method according to claim 1, characterized in that, The first task parameters include reload time, repeated reload identifier, and current time.

4. The task scheduling method according to claim 1, characterized in that, The step of scheduling tasks based on the first task parameters includes: Poll all task parameters in the task table; Obtain the service request sent by the first task parameters; Task scheduling is performed based on the service request.

5. The task scheduling method according to claim 1, characterized in that, After modifying the task parameters in the task table according to the task identifier number of the second task through the task control interface to obtain the first task parameters, the method further includes: Determine whether the data value of the first task parameter is within a preset range; If the data value of the first task parameter is within a preset range, task scheduling is performed according to the first task parameter. If the data value of the first task parameter is not within the preset range, the first task parameter is discarded and an error message is returned.

6. The task scheduling method according to claim 1, characterized in that, After scheduling the task according to the first task parameters, the method further includes: Run the second task; Check whether to continue running the second task; If it is detected that the second task will no longer continue to run, the task parameters in the task table are modified according to the second task parameters, and task scheduling is performed. The second task parameter is the task parameter stored in the task table before the task parameter in the task table is modified through the task control interface according to the task identifier number of the second task. The second task parameter is pre-stored in a preset address.

7. A task scheduling device, characterized in that, The task scheduling device includes a service layer, the service layer includes a task control interface, and the device includes: The acquisition unit is used to acquire the task identifier number of the second task; The information transmission unit is used to send the task identifier number of the second task to the task control interface; The control unit is used to modify the task parameters of the task table according to the task identifier number of the second task to obtain the first task parameters; A processing unit is used to schedule tasks based on the first task parameters; Before performing task scheduling based on the first task parameters, the device is further configured to: Obtain the storage address of the first data in the first task; Create an untyped pointer and point the untyped pointer to the storage address of the first data to obtain multiple first data address pointers; Construct the first data address pointer into a structure; The structure is passed as a parameter to the second task for parsing; wherein, the second task obtains the first data address pointer, and the second task obtains the first data according to the first data address pointer, and the first data is data that needs to be shared between the first task and the second task.

8. An electronic device, characterized in that, The electronic device includes a memory, a processor, a program stored in the memory and executable on the processor, and a data bus for establishing communication between the processor and the memory. The program is executed by the processor to implement the task scheduling method as described in any one of claims 1 to 6.

9. A storage medium, said storage medium being a computer-readable storage medium for computer-readable storage, characterized in that, The storage medium stores one or more programs, which can be executed by one or more processors to implement the task scheduling method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Job re-running method and device, electronic equipment, medium and product

    CN114610458A