Operation task scheduling method, device, computer equipment and storage medium
Through the parallel scheduling mechanism, blocking and non-blocking tasks are distinguished according to task status information, which solves the problem of disk file read and write operation conflicts and improves read and write efficiency.
Patent Information
- Application Number
- CN202310139015.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-10
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2043-02-10
AI Technical Summary
In the computer field, frequent disk file read and write operations are prone to read and write operation conflicts, resulting in low efficiency. The existing serial queue method cannot perform read and write operations on multiple files simultaneously, and the fence function method may cause thread pool exhaustion and write operation lock.
The invention provides an operation task scheduling method, which obtains the task execution status information of the file, distinguishes blocking tasks from non-blocking tasks, adopts a parallel scheduling mechanism, avoids conflicts and improves efficiency.
It realizes concurrent scheduling among multiple files, avoids task conflicts, and improves the efficiency of read and write operations.
Smart Images

Figure CN116126505B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to an operation task scheduling method, apparatus, computer equipment, and storage medium. Background Art
[0002] In the computer field, exchanging memory data with disk file data is a very common scenario. For example, when mobile applications are persisting data, they need to frequently exchange memory data with disk file data, which means that they need to perform frequent read and write operations.
[0003] When performing read and write operations on disk files, read and write conflicts may occur. For example, if thread 1 and thread 2 perform read and write operations concurrently, and thread 1 reads the file content, thread 2 has already deleted the file content through a write operation, causing thread 1's read operation to fail. To avoid read and write conflicts, if a serial queue is used to perform read and write operations on disk files, only one operation can be executed at a time, which will greatly affect the read and write efficiency of the entire disk file. Summary of the Invention
[0004] The embodiments of the present disclosure at least provide a method, apparatus, computer equipment, and storage medium for scheduling operation tasks.
[0005] In a first aspect, an embodiment of the present disclosure provides an operation task scheduling method, comprising:
[0006] For multiple files, the following task scheduling process is executed in parallel:
[0007] In response to the file satisfying the operation task scheduling condition, task execution status information of the file is obtained; the task execution status information is used to indicate whether there is an operation task being executed in the file, and if there is an operation task being executed, the first task type and the number of operation tasks being executed; the task type of the operation task includes a blocking task and a non-blocking task;
[0008] Based on the task execution status information of the file and the second task type of the to-be-executed operation task corresponding to the file, a scheduling result for the to-be-executed operation task is determined.
[0009] In an optional implementation, determining the scheduling result of the to-be-executed operation task based on the task execution status information of the file and the second task type of the to-be-executed operation task corresponding to the file includes:
[0010] If the task execution status information indicates that there is no operation task being executed, the operation task to be executed is dispatched to the concurrent queue of the file; the operation tasks to be executed in the concurrent queue are executed synchronously;
[0011] If the task execution status information indicates that there is a non-blocking task being executed, and the to-be-executed operation task is a non-blocking task, dispatching the to-be-executed operation task to the concurrent queue;
[0012] If the task execution status information indicates that there is a non-blocking task being executed and the pending operation task is a blocking task, the pending operation task is cached in a queue to be dispatched; wherein the pending operation task in the queue to be dispatched is dispatched to the concurrent queue after the multiple blocking operation tasks being executed are completed;
[0013] If the task execution status information indicates that there is a blocking task being executed, the to-be-executed operation task is cached in the to-be-dispatched queue.
[0014] In an optional implementation, if the task execution status information indicates that there is no operation task being executed, after dispatching the operation task to be executed to the concurrent queue of the file, the method further includes:
[0015] If the operation task to be executed is a blocking task, then the first task type of the operation task being executed indicated by the task execution status information is updated to the blocking task; or
[0016] If the operation task to be executed is a non-blocking task, the first task type of the operation task being executed indicated by the task execution status information is updated to the non-blocking task, and the number of operation tasks is set to 1.
[0017] In an optional implementation, if the task execution status information indicates that there is a non-blocking task being executed and the pending operation task is a non-blocking task, after dispatching the pending operation task to the concurrent queue, the method further includes:
[0018] The number of the operation tasks indicated by the task execution status information is increased by 1.
[0019] In an optional implementation, the method further includes:
[0020] After any pending operation task in the file is completed, the task execution status information of the file is updated.
[0021] In an optional implementation manner, updating the task execution status information of the file includes:
[0022] If the task execution status information indicates that there is a non-blocking task being executed, and the number of operation tasks of the non-blocking operation task is greater than 1, subtract 1 from the number of operation tasks indicated by the task execution status information;
[0023] If the task execution status information indicates that there is a non-blocking task being executed, and the number of operation tasks of the non-blocking operation task is equal to 1, updating the task execution status information to indicate that there is no operation task being executed in the file;
[0024] If the task execution status information indicates that there is a blocking task being executed, the task execution status information is updated to indicate that there is no operating task being executed in the file.
[0025] In an optional implementation, the to-be-executed operation task corresponding to the file is extracted from a sub-scheduling queue corresponding to the file in a task scheduling queue;
[0026] The method further comprises:
[0027] In response to receiving the operation task to be executed, determining a file identifier of a target file corresponding to the operation task to be executed;
[0028] The to-be-executed operation tasks are stored in a task scheduling queue, in a sub-scheduling queue corresponding to the file identifier; and the to-be-executed operation tasks in the sub-scheduling queue are arranged in sequence according to the order of reception time.
[0029] In a second aspect, an embodiment of the present disclosure further provides an operation task scheduling device, comprising:
[0030] The execution module is used to execute the following task scheduling processes in parallel for multiple files:
[0031] In response to the file satisfying the operation task scheduling condition, task execution status information of the file is obtained; the task execution status information is used to indicate whether there is an operation task being executed in the file, and if there is an operation task being executed, the first task type and the number of operation tasks being executed; the task type of the operation task includes a blocking task and a non-blocking task;
[0032] Based on the task execution status information of the file and the second task type of the to-be-executed operation task corresponding to the file, a scheduling result for the to-be-executed operation task is determined.
[0033] In a third aspect, an embodiment of the present disclosure further provides a computer device comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the computer device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps in the above-mentioned first aspect or any optional implementation of the first aspect are performed.
[0034] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned first aspect or any optional implementation of the first aspect are executed.
[0035] The operation task scheduling method provided by the embodiment of the present disclosure can execute the task scheduling process in parallel for multiple files, thereby realizing the concurrent scheduling of the respective read and write operations between multiple files, and improving the efficiency of executing read and write operations. In addition, during the task scheduling process, the task execution status information corresponding to the file can be used to identify the current state of the concurrent queue corresponding to the file to execute the operation task, for example, whether it is currently in a blocked state or a non-blocking state, and then the operation task can be scheduled in combination with the task type (including blocking tasks and non-blocking tasks) of the operation task to be executed. For example, if a write operation (blocking task) for a certain file is currently being executed, other operations will not be scheduled. If a read operation (non-blocking task) for the file is currently being executed, other read operation tasks can be dispatched, that is, multiple read operation tasks are executed concurrently, thereby avoiding the occurrence of task conflicts and improving operation efficiency at the same time.
[0036] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following briefly introduces the drawings required for use in the embodiments. The drawings herein are incorporated into and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and, together with the specification, are used to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For those of ordinary skill in the art, other relevant drawings can be obtained based on these drawings without inventive effort.
[0038] Figure 1 A flowchart of an operation task scheduling method provided by an embodiment of the present disclosure is shown;
[0039] Figure 2 A schematic diagram showing a collection of operation tasks to be performed provided by an embodiment of the present disclosure is shown;
[0040] Figure 3 A flowchart of another operation task scheduling method provided by an embodiment of the present disclosure is shown;
[0041] Figure 4 A schematic structural diagram of an operation task scheduling device provided by an embodiment of the present disclosure is shown;
[0042] Figure 5 A schematic diagram of a computer device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings herein can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the disclosure for which protection is sought, but merely represents selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present disclosure.
[0044] In scenarios where read and write operations are frequently performed, concurrent queues are often used. These queues use asynchronous threads to perform operations on the same file. For example, thread 1 might perform a read operation on the same file, while thread 2 might perform a delete operation (a type of write operation). However, when thread 1 needs to read the file contents, thread 2 has already completed the delete operation. Thread 1 will then be unable to read the file contents, causing execution logic errors.
[0045] In this case, if a serial queue is used for read and write operations, only one operation can be performed on the entire disk file at a time, and it is impossible to quickly perform read and write operations on multiple files.
[0046] In addition, if read and write operations are performed using a concurrent queue based on a fence function, the write operation will monopolize the entire concurrent queue. The read operation before the write operation can be executed concurrently, and the read operation after the write operation needs to wait for the write operation to be completed before it can be executed concurrently. However, since the fence area requires a thread to first obtain the lock used to block the concurrent queue before dispatching the write operation, if the concurrent read operation occupies the remaining threads, the thread pool will be exhausted and there will be no extra threads to perform the write operation. The concurrent read operation must wait for the write operation to be completed before it can continue to execute, and the thread cannot be released. At this time, there is no available thread to execute the write operation first, which causes the write operation to be locked. In addition, the fence function will block the entire concurrent queue, so it is impossible to perform read and write operations on multiple files at the same time.
[0047] Based on this, the present disclosure provides an operation task scheduling method, which can execute the task scheduling process in parallel for multiple files, thereby realizing the concurrent scheduling of the respective read and write operations between multiple files, and improving the efficiency of executing read and write operations. In addition, during the task scheduling process, the task execution status information corresponding to the file can be used to identify the current state of the concurrent queue corresponding to the file to execute the operation task, such as whether it is currently in a blocked state or a non-blocking state, and the operation task is scheduled. For example, if a write operation (blocking task) for a certain file is currently being executed, other operations will not be scheduled. If a read operation (non-blocking task) for the file is currently being executed, other read operation tasks can be dispatched, that is, multiple read operation tasks are executed concurrently, thereby avoiding task conflicts and improving operation efficiency at the same time.
[0048] The defects of the above solutions and the proposed solutions are the results obtained by the inventor after practice and careful research. Therefore, the discovery process of the above problems and the solutions proposed in the present disclosure for the above problems below should be the contributions made by the inventor to the present disclosure during the disclosure process.
[0049] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not require further definition or explanation in subsequent drawings.
[0050] It is understandable that before using the technical solutions disclosed in the various embodiments of this disclosure, the type, scope of use, usage scenarios, etc. of the personal information involved in this disclosure should be informed to the user and the user's authorization should be obtained in an appropriate manner in accordance with relevant laws and regulations.
[0051] To facilitate understanding of this embodiment, an operation task scheduling method disclosed in the embodiment of the present disclosure is first introduced in detail. The execution subject of the operation task scheduling method provided in the embodiment of the present disclosure is generally a computer device with certain computing capabilities.
[0052] The operation task scheduling method provided by the embodiment of the present disclosure can be applied to scenarios such as application persistence data. In the process of application persistence data, it is necessary to frequently exchange memory data and data in disk files, that is, it is necessary to frequently perform read and write operations on files in the disk. Therefore, the embodiment of the present disclosure can schedule read and write operation tasks when reading and writing files on the disk. In practice, operation tasks similar to read and write protection can also be performed on objects in the memory. Therefore, the embodiment of the present disclosure can also schedule related protection operation tasks when performing related protection operations on objects in the memory.
[0053] See also Figure 1 The figure shows a flowchart of an operation task scheduling method provided by an embodiment of the present disclosure. The method may include executing the following task scheduling process in parallel for multiple files, that is, executing the following task scheduling process for each of the multiple files may be concurrent. During the execution of the following task scheduling process for each file, the task scheduling processes between the files do not affect each other. The task scheduling process may include the following steps:
[0054] S101: In response to the file satisfying the operation task scheduling conditions, task execution status information of the file is obtained; the task execution status information is used to indicate whether there is an operation task being executed in the file, and when there is an operation task being executed, the first task type and the number of operation tasks being executed; the task type of the operation task includes a blocking task and a non-blocking task.
[0055] S102: Determine a scheduling result for the to-be-executed operation task based on the task execution status information of the file and the second task type of the to-be-executed operation task corresponding to the file.
[0056] In the disclosed embodiments, each file may correspond to at least one pending operation task. The at least one pending operation task corresponding to each file may include a task for performing a corresponding operation on each file. For example, when a user opens or saves a file, a read operation task or a write operation task may be generated for the file.
[0057] In the embodiment of the present disclosure, each file may correspond to a sub-scheduling queue, and the pending operation tasks corresponding to the file may be stored in the sub-scheduling queue corresponding to the file, that is, the pending operation tasks corresponding to the file may be extracted from the task scheduling queue and the sub-scheduling queue corresponding to the file.
[0058] In a specific implementation, in response to receiving a pending operation task, the file identifier of the target file corresponding to the pending operation task can be determined. The pending operation task is then stored in a sub-scheduling queue corresponding to the file identifier in the task scheduling queue. The pending operation tasks in the sub-scheduling queue are arranged in order of the time of receipt, that is, the pending operation task received first can be arranged first in the sub-scheduling queue, and the pending operation task received later can be arranged later in the sub-scheduling queue.
[0059] In one embodiment, for each file in a plurality of files, the set of at least one pending operation task corresponding to the file can be represented by a keyword Key. The Key can be a file identifier of the file, such as a file path, file name, or other custom file identifier. The Key can be used to aggregate at least one pending operation task corresponding to each file. Figure 2 The diagram of a set of pending operation tasks shown includes two sets of pending operation tasks: File ID 1 and File ID 2. Each set can include at least one blocking task and / or at least one non-blocking task. The pending operation tasks in each set correspond to the same file. In other words, there can be a one-to-one correspondence between files and sets.
[0060] For each file among the multiple files, at least one to-be-executed operation task of the file may be executed by using the concurrent queue corresponding to the file.
[0061] In the embodiment of the present disclosure, the operation task scheduling condition may include that any operation task in the concurrent queue of the file is completed. When any operation task of the file is completed, the task execution status information of the file may be obtained.
[0062] Through the task execution status information of the file, it can be determined whether there are any operating tasks being executed in the file, and if there are any operating tasks being executed, the first task type and the number of the operating tasks being executed.
[0063] Here, the task type of the operation task can include blocking tasks (such as write operations) and non-blocking tasks (such as read operations). A blocking task can be an operation task that blocks a concurrent queue, that is, at the same time, a concurrent queue can only execute one blocking task; a non-blocking task can be an operation task that does not block a concurrent queue, that is, at the same time, a concurrent queue can concurrently execute multiple non-blocking tasks.
[0064] In the embodiment of the present disclosure, the task execution status information may include the following three situations: (1) there is no operating task being executed in the file, which can be recorded as none; (2) there is a non-blocking task being executed in the file, which can be recorded as normal, and the number of operating tasks of the non-blocking task can be recorded as N, where N is a positive integer greater than or equal to 1; (3) there is a blocking task being executed in the file, which can be recorded as barrier, and the number of operating tasks of the blocking task is 1.
[0065] Here, the acquired task execution status information of the file may be task execution status information updated after the operation task being executed in the file is completed.
[0066] In one embodiment, the initial task execution status information of the file can be found based on the correspondence between the file identifier and the task execution status information, and the file identifier carried by the operation task to be executed. Here, the initial task execution status information of the file can be the task execution status information when the operation task is being executed in the file.
[0067] Here, the correspondence between file identifiers and task execution status information can be pre-generated. In a specific implementation, a target dictionary workMap containing the correspondence between each file identifier and task execution status information can be generated. The target dictionary stores the file identifiers of all files currently executing operation tasks and the task execution status information corresponding to the file identifiers.
[0068] If the initial task execution status information of the file corresponding to the operation to be performed is not found, it may indicate that after all the operation tasks under the file are executed, the correspondence between the file identifier of the file and the task execution status information is deleted, or no operation task has been performed for the file, and the correspondence between the file identifier of the file and the task execution status information has not been established. At this time, a new task execution status can be initialized, and the initialized task execution status information can indicate that there is no operation task being executed. At this time, the operation task to be executed can be dispatched to the concurrent queue corresponding to the file for execution, and the initialized task execution status information can be updated according to the second task type of the operation task to be executed. In a specific implementation, when the second task type of the operation task to be executed is a blocking task, the initialized task execution status information can be updated to indicate that there is a blocking task being executed; when the second task type of the operation task to be executed is a non-blocking task, the initialized task execution status information can be updated to indicate that there is a non-blocking task being executed, and the number of operation tasks of the non-blocking operation task is equal to 1.
[0069] If the initial task execution status information of the file corresponding to the operation to be performed is found, the initial task execution status information can be updated after the operation task being performed is completed. In specific implementations, the initial task execution status information can be updated based on the task type and number of the operation tasks being performed, which can specifically include the following three situations:
[0070] (1) If the initial task execution status information indicates that there is a non-blocking task being executed, and the number of operation tasks of the non-blocking operation task is greater than 1, the number of operation tasks indicated by the initial task execution status information is reduced by 1.
[0071] (2) If the initial task execution status information indicates that there is a non-blocking task being executed, and the number of operation tasks of the non-blocking operation task is equal to 1, the initial task execution status information is updated to indicate that there is no operation task being executed in the file.
[0072] (3) If the initial task execution status information indicates that there is a blocking task being executed, the initial task execution status information is updated to indicate that there is no operating task being executed in the file.
[0073] In case (1), if the initial task execution status information indicates that there are non-blocking tasks being executed, and the number of operational tasks of the non-blocking operational tasks is greater than 1, that is, more than one non-blocking task is currently being executed. Before all non-blocking tasks are executed, each time a non-blocking task is executed, if there are still non-blocking tasks being executed, the number of operational tasks indicated by the initial task execution status information can be reduced by 1.
[0074] In case (2), if the initial task execution status information indicates that there is a non-blocking task being executed and the number of operation tasks of the non-blocking operation task is equal to 1, that is, there is only one non-blocking task currently being executed. After the non-blocking task is executed, there is no operation task. Therefore, the initial task execution status information can be updated to indicate that there is no operation task being executed in the file.
[0075] In case (3), if the initial task execution status information indicates that there is a blocking task being executed, after the blocking task is executed, there is no operating task, so the initial task execution status information can be updated to indicate that there is no operating task being executed in the file.
[0076] The updated initial task execution status information is the task execution status information obtained above. Next, the scheduling result of the task to be executed can be determined based on the obtained task execution status information and the second task type of the task to be executed corresponding to the file, which may include the following situations:
[0077] (a) If the task execution status information indicates that there is no operation task being executed, the operation task to be executed is dispatched to the concurrent queue of the file; the operation tasks to be executed in the concurrent queue are executed synchronously.
[0078] (b) If the task execution status information indicates that there is a non-blocking task being executed and the pending operation task is a non-blocking task, the pending operation task is dispatched to the concurrent queue of the file.
[0079] (c) If the task execution status information indicates that there is a non-blocking task being executed and the operation task to be executed is a blocking task, the operation task to be executed is cached in the queue to be dispatched; wherein, the operation task to be executed in the queue to be dispatched is dispatched to the concurrent queue after the multiple blocking operation tasks being executed are completed.
[0080] (d) If the task execution status information indicates that there is a blocking task being executed, the operation task to be executed is cached in a queue to be dispatched.
[0081] In case (a), if the task execution status information indicates that there is no operation task being executed, the operation task to be executed can be dispatched to the concurrent queue of the file when it is a blocking task or a non-blocking task.
[0082] In case (b), if the task execution status information indicates that there is an ongoing non-blocking task and the pending task is also a non-blocking task, that is, the ongoing non-blocking task does not affect the execution of the pending task, and the pending task will not block the concurrent queue, then the pending task can be dispatched to the file's concurrent queue. The pending task in the concurrent queue can be executed synchronously with the ongoing non-blocking task.
[0083] In case (c), if the task execution status information indicates that there is a non-blocking task being executed and the pending operation task is a blocking task, that is, when the pending operation task is dispatched to the concurrent queue, the concurrent queue will be blocked. Therefore, the blocking task can only be dispatched to the concurrent queue after the non-blocking task is executed. Therefore, the pending operation task can be cached in the pending operation queue at this time. The pending operation task can wait in the pending operation queue until multiple non-blocking operation tasks are executed, and then it will be dispatched to the concurrent queue.
[0084] In case (d), if the task execution status information indicates that a blocking task is currently executing, that is, the blocking task is blocking the concurrent queue, then the pending operation task cannot be dispatched to the concurrent queue, even if it is a blocking task or a non-blocking task. Therefore, the pending operation task can be cached in the pending dispatch queue. The pending operation task can wait in the pending dispatch queue until the blocking task is completed, at which time it can be dispatched to the concurrent queue.
[0085] Here, after the pending operation tasks are cached in the pending dispatch queue, the task execution status information does not change, that is, the first task type and the number of operation tasks executed do not change. After the pending operation tasks are dispatched to the concurrent queue, the task execution status information may change, that is, the first task type and / or the number of operation tasks executed may change.
[0086] In one embodiment, if the task execution status information indicates that there is no operation task being executed, then after the operation task to be executed is dispatched to the concurrent queue of the file, the change in the task execution status information can be determined by the task type of the operation task to be executed, that is: if the operation task to be executed is a blocking task, then the first task type of the operation task being executed indicated by the task execution status information is updated to a blocking task; or, if the operation task to be executed is a non-blocking task, then the first task type of the operation task being executed indicated by the task execution status information is updated to a non-blocking task, and the number of operation tasks is set to 1.
[0087] That is, before the operation task to be executed is dispatched to the concurrent queue of the file, the task execution status information indicates that there is no operation task being executed. After the operation task to be executed is dispatched to the concurrent queue of the file, if the operation task to be executed is a blocking task, then the first task type of the operation task being executed indicated by the task execution status information may be the task type of the operation task being executed, that is, the blocking task.
[0088] Before the operation task to be executed is dispatched to the concurrent queue of the file, the task execution status information indicates that there is no operation task being executed. After the operation task to be executed is dispatched to the concurrent queue of the file, if the operation task to be executed is a non-blocking task, the first task type of the operation task being executed indicated by the task execution status information can be the task type of the operation task being executed, that is, a non-blocking task, and the number of operation tasks indicated by the task execution status information is 1.
[0089] In one embodiment, if the task execution status information indicates that there is a non-blocking task being executed and the pending operation task is a non-blocking task, after the pending operation task is dispatched to the concurrent queue, the number of operation tasks indicated by the task execution status information can be increased by 1.
[0090] That is, after dispatching the operation task to be executed to the concurrent queue, the concurrent queue can synchronously execute the non-blocking task being executed and the operation task to be executed, so the number of operation tasks increases by 1. At this time, the number of operation tasks indicated by the task execution status information can be increased by 1.
[0091] In one embodiment, after the to-be-executed operation task is dispatched to the concurrent queue of the file, the updated task execution status information may be stored in a target dictionary containing the correspondence between each file identifier and the task execution status information.
[0092] In an embodiment of the present disclosure, a concurrent queue class may be defined, which may utilize a concurrent queue to execute an operation task and store the file identifiers of each file executing the operation task and the corresponding updated task execution status information through a target dictionary.
[0093] like Figure 3 In the flowchart of another operation task scheduling shown, the concurrent queue class can dispatch the operation tasks to be executed to the concurrent queue corresponding to the file according to the file identifier of the file. Here, each file can correspond to a concurrent queue respectively. In the concurrent queue of each file, the blocking task can be implemented to exclusively occupy the entire concurrent queue, the non-blocking task before the blocking task can be executed concurrently, and the non-blocking task after the blocking task needs to wait until the blocking task is completed before it can be executed concurrently. The concurrent queues of each file can execute their own operation tasks respectively, that is, between different concurrent queues, the blocking task being executed by any concurrent queue does not affect the non-blocking tasks of other concurrent queues, and the blocking tasks of multiple concurrent queues can be executed simultaneously.
[0094] After any pending operation task in a file is completed, the task execution status information of the file can be updated. In a specific implementation, the task execution status can be updated based on the task type and the number of pending operation tasks executed. In one embodiment, updating the task execution status information of a file may include:
[0095] If the task execution status information indicates that there is a non-blocking task being executed, and the number of operation tasks of the non-blocking operation task is greater than 1, the number of operation tasks indicated by the task execution status information is reduced by 1.
[0096] If the task execution status information indicates that there is a non-blocking task being executed, and the number of operation tasks of the non-blocking operation task is equal to 1, the task execution status information is updated to indicate that there is no operation task being executed in the file.
[0097] If the task execution status information indicates that there is a blocking task being executed, the task execution status information is updated to indicate that there is no operation task being executed in the file.
[0098] Here, after the pending operation task is completed, the process of updating the task execution status information of the file is similar to the process of updating the initial task execution status information after the ongoing operation task is completed. The specific process can be referred to above and will not be repeated here.
[0099] In the disclosed embodiment, after the previous operation task is completed, the task execution status information needs to be updated, and after the next operation task is dispatched to the concurrent queue, the task execution status information also needs to be updated. Specifically, after the previous operation task is completed, the task execution status information can be updated based on the task type and number of operation tasks of the previous operation task; after the next operation task is dispatched to the concurrent queue, the task execution status information can be updated based on the task type and number of operation tasks indicated in the task execution status information after the previous operation task is completed, as well as the task type of the next operation task.
[0100] Those skilled in the art will understand that in the above-mentioned method of the specific implementation method, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0101] Based on the same inventive concept, an operation task scheduling device corresponding to the operation task scheduling method is also provided in the embodiment of the present disclosure. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned operation task scheduling method in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0102] Reference Figure 4 FIG. 4 is a schematic diagram of the architecture of an operation task scheduling device provided by an embodiment of the present disclosure. The operation task scheduling device 400 includes:
[0103] The execution module 401 is used to execute the following task scheduling process in parallel for multiple files:
[0104] In response to the file satisfying the operation task scheduling condition, task execution status information of the file is obtained; the task execution status information is used to indicate whether there is an operation task being executed in the file, and if there is an operation task being executed, the first task type and the number of operation tasks being executed; the task type of the operation task includes a blocking task and a non-blocking task;
[0105] Based on the task execution status information of the file and the second task type of the to-be-executed operation task corresponding to the file, a scheduling result for the to-be-executed operation task is determined.
[0106] When executing the step of determining the scheduling result of the to-be-executed operation task based on the task execution status information of the file and the second task type of the to-be-executed operation task corresponding to the file, the execution module 401 is specifically configured to:
[0107] If the task execution status information indicates that there is no operation task being executed, the operation task to be executed is dispatched to the concurrent queue of the file; the operation tasks to be executed in the concurrent queue are executed synchronously;
[0108] If the task execution status information indicates that there is a non-blocking task being executed, and the to-be-executed operation task is a non-blocking task, dispatching the to-be-executed operation task to the concurrent queue;
[0109] If the task execution status information indicates that there is a non-blocking task being executed and the pending operation task is a blocking task, the pending operation task is cached in a queue to be dispatched; wherein the pending operation task in the queue to be dispatched is dispatched to the concurrent queue after the multiple blocking operation tasks being executed are completed;
[0110] If the task execution status information indicates that there is a blocking task being executed, the to-be-executed operation task is cached in the to-be-dispatched queue.
[0111] In an optional embodiment, the apparatus further includes a first updating module 402, which is configured to: after the executing module 401 executes the step of dispatching the to-be-executed operation task to the concurrent queue of the file if the task execution status information indicates that there is no operation task being executed, the updating module 402 is configured to:
[0112] If the operation task to be executed is a blocking task, then the first task type of the operation task being executed indicated by the task execution status information is updated to the blocking task; or
[0113] If the operation task to be executed is a non-blocking task, the first task type of the operation task being executed indicated by the task execution status information is updated to the non-blocking task, and the number of operation tasks is set to 1.
[0114] In an optional embodiment, the apparatus further includes a processing module 403, which is configured to: after the execution module 401 executes the step of dispatching the to-be-executed operation task to the concurrent queue if the task execution status information indicates that there is a non-blocking task being executed and the to-be-executed operation task is a non-blocking task, the processing module 403 is configured to:
[0115] The number of the operation tasks indicated by the task execution status information is increased by 1.
[0116] In an optional embodiment, the device further includes:
[0117] The second updating module 404 updates the task execution status information of the file after any pending operation task in the file is completed.
[0118] In an optional implementation, the second updating module 404 is specifically configured to:
[0119] If the task execution status information indicates that there is a non-blocking task being executed, and the number of operation tasks of the non-blocking operation task is greater than 1, subtract 1 from the number of operation tasks indicated by the task execution status information;
[0120] If the task execution status information indicates that there is a non-blocking task being executed, and the number of operation tasks of the non-blocking operation task is equal to 1, updating the task execution status information to indicate that there is no operation task being executed in the file;
[0121] If the task execution status information indicates that there is a blocking task being executed, the task execution status information is updated to indicate that there is no operating task being executed in the file.
[0122] In an optional embodiment, the to-be-executed operation task corresponding to the file is extracted from a sub-scheduling queue corresponding to the file in a task scheduling queue;
[0123] The device further comprises:
[0124] A determination module 405 is configured to, in response to receiving the operation task to be executed, determine the file identifier of the target file corresponding to the operation task to be executed;
[0125] The storage module 406 is used to store the pending operation tasks in the task scheduling queue, in the sub-scheduling queue corresponding to the file identifier; the pending operation tasks in the sub-scheduling queue are arranged in order according to the chronological order of reception time.
[0126] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference can be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0127] Based on the same technical concept, the embodiment of the present disclosure also provides a computer device. Figure 5 FIG. 5 is a schematic diagram of the structure of a computer device 500 provided in an embodiment of the present disclosure, comprising a processor 501, a memory 502, and a bus 503. The memory 502 is used to store execution instructions and includes a memory 5021 and an external memory 5022. The memory 5021 is also referred to as internal memory and is used to temporarily store operation data in the processor 501 and data exchanged with an external memory 5022 such as a hard disk. The processor 501 exchanges data with the external memory 5022 via the memory 5021. When the computer device 500 is running, the processor 501 communicates with the memory 502 via the bus 503, so that the processor 501 executes the following instructions:
[0128] For multiple files, the following task scheduling process is executed in parallel:
[0129] In response to the file satisfying the operation task scheduling condition, task execution status information of the file is obtained; the task execution status information is used to indicate whether there is an operation task being executed in the file, and if there is an operation task being executed, the first task type and the number of operation tasks being executed; the task type of the operation task includes a blocking task and a non-blocking task;
[0130] Based on the task execution status information of the file and the second task type of the to-be-executed operation task corresponding to the file, a scheduling result for the to-be-executed operation task is determined.
[0131] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon. When executed by a processor, the computer program executes the steps of the method for scheduling operational tasks described in the above method embodiment. The storage medium may be a volatile or non-volatile computer-readable storage medium.
[0132] The embodiments of the present disclosure also provide a computer program product, which carries program code. The instructions included in the program code can be used to execute the steps of the operation task scheduling method described in the above method embodiment. For details, please refer to the above method embodiment and will not be repeated here.
[0133] The computer program product may be implemented in hardware, software, or a combination thereof. In one embodiment, the computer program product is implemented as a computer storage medium. In another embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0134] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems and devices described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0135] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0136] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0137] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0138] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The scope of protection of the present disclosure is not limited thereto. Although the present disclosure has been described in detail with reference to the above-described embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily conceive of changes to the technical solutions described in the above-described embodiments within the technical scope disclosed in the present disclosure, or replace some of the technical features therein with equivalents. Such modifications, changes, or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the scope of protection of the present disclosure. Therefore, the scope of protection of the present disclosure should be based on the scope of protection of the claims.
Claims
1. A method for scheduling operation tasks, characterized in that: include: For multiple files, the following task scheduling process is executed in parallel: In response to the file meeting the operation task scheduling condition, obtaining task execution status information of the file; The task execution status information is used to indicate whether there is an operating task being executed in the file, and if there is an operating task being executed, the first task type and the number of the operating tasks being executed; The task types of the operation tasks include blocking tasks and non-blocking tasks; Determine a scheduling result for the to-be-executed operation task based on the task execution status information of the file and the second task type of the to-be-executed operation task corresponding to the file, The determining of the scheduling result of the to-be-executed operation task based on the task execution status information of the file and the second task type of the to-be-executed operation task corresponding to the file includes: If the task execution status information indicates that there is no operation task being executed, the operation task to be executed is dispatched to the concurrent queue of the file; the operation tasks to be executed in the concurrent queue are executed synchronously; If the task execution status information indicates that there is a non-blocking task being executed, and the to-be-executed operation task is a non-blocking task, dispatching the to-be-executed operation task to the concurrent queue; If the task execution status information indicates that there is a non-blocking task being executed and the pending operation task is a blocking task, the pending operation task is cached in a queue to be dispatched; wherein the pending operation task in the queue to be dispatched is dispatched to the concurrent queue after the multiple blocking operation tasks being executed are completed; If the task execution status information indicates that there is a blocking task being executed, the to-be-executed operation task is cached in the to-be-dispatched queue.
2. The method according to claim 1, characterized in that If the task execution status information indicates that there is no operation task being executed, after dispatching the operation task to be executed to the concurrent queue of the file, the method further includes: If the operation task to be executed is a blocking task, then the first task type of the operation task being executed indicated by the task execution status information is updated to the blocking task; or If the operation task to be executed is a non-blocking task, the first task type of the operation task being executed indicated by the task execution status information is updated to the non-blocking task, and the number of operation tasks is set to 1.
3. The method according to claim 1, characterized in that If the task execution status information indicates that there is a non-blocking task being executed, and the pending operation task is a non-blocking task, after dispatching the pending operation task to the concurrent queue, the method further includes: The number of the operation tasks indicated by the task execution status information is increased by 1.
4. The method according to claim 1, characterized in that The method further comprises: After any pending operation task in the file is completed, the task execution status information of the file is updated.
5. The method according to claim 4, characterized in that The task execution status information of updating the file includes: If the task execution status information indicates that there is a non-blocking task being executed, and the number of operation tasks of the non-blocking operation task is greater than 1, subtract 1 from the number of operation tasks indicated by the task execution status information; If the task execution status information indicates that there is a non-blocking task being executed, and the number of operation tasks of the non-blocking operation task is equal to 1, updating the task execution status information to indicate that there is no operation task being executed in the file; If the task execution status information indicates that there is a blocking task being executed, the task execution status information is updated to indicate that there is no operating task being executed in the file.
6. The method according to claim 1, wherein The to-be-executed operation task corresponding to the file is extracted from the sub-scheduling queue corresponding to the file in the task scheduling queue; The method further comprises: In response to receiving the operation task to be executed, determining a file identifier of a target file corresponding to the operation task to be executed; The to-be-executed operation tasks are stored in a task scheduling queue, in a sub-scheduling queue corresponding to the file identifier; and the to-be-executed operation tasks in the sub-scheduling queue are arranged in sequence according to the order of reception time.
7. An operation task scheduling device, characterized in that: include: The execution module is used to execute the following task scheduling processes in parallel for multiple files: In response to the file satisfying the operation task scheduling condition, task execution status information of the file is obtained; the task execution status information is used to indicate whether there is an operation task being executed in the file, and if there is an operation task being executed, the first task type and the number of operation tasks being executed; The task types of the operation tasks include blocking tasks and non-blocking tasks; Determine a scheduling result for the to-be-executed operation task based on the task execution status information of the file and the second task type of the to-be-executed operation task corresponding to the file, The determining of the scheduling result of the to-be-executed operation task based on the task execution status information of the file and the second task type of the to-be-executed operation task corresponding to the file includes: If the task execution status information indicates that there is no operation task being executed, the operation task to be executed is dispatched to the concurrent queue of the file; the operation tasks to be executed in the concurrent queue are executed synchronously; If the task execution status information indicates that there is a non-blocking task being executed, and the to-be-executed operation task is a non-blocking task, dispatching the to-be-executed operation task to the concurrent queue; If the task execution status information indicates that there is a non-blocking task being executed and the pending operation task is a blocking task, the pending operation task is cached in a queue to be dispatched; wherein the pending operation task in the queue to be dispatched is dispatched to the concurrent queue after the multiple blocking operation tasks being executed are completed; If the task execution status information indicates that there is a blocking task being executed, the to-be-executed operation task is cached in the to-be-dispatched queue.
8. A computer device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the computer device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the operation task scheduling method according to any one of claims 1 to 6 are performed.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, executes the steps of the operation task scheduling method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Structure and method for realizing concurrent reading and concurrent writing of IP of synchronous dual-port memory
CN101770437A
Cache management based on types of I / O operations
US20190057037A1