CN116991586A - Job distribution method, scheduling system, electronic device, and computer storage medium - Google Patents

Job distribution method, scheduling system, electronic device, and computer storage medium Download PDF

Info

Publication number
CN116991586A
CN116991586A CN202311014419.8A CN202311014419A CN116991586A CN 116991586 A CN116991586 A CN 116991586A CN 202311014419 A CN202311014419 A CN 202311014419A CN 116991586 A CN116991586 A CN 116991586A
Authority
CN
China
Prior art keywords
queue
job
mode
head
main
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311014419.8A
Other languages
Chinese (zh)
Inventor
刘旻轩
何川
李春林
欧阳晔
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Asiainfo Technologies China Inc
Original Assignee
Asiainfo Technologies China Inc
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Asiainfo Technologies China Inc filed Critical Asiainfo Technologies China Inc
Priority to CN202311014419.8A priority Critical patent/CN116991586A/en
Publication of CN116991586A publication Critical patent/CN116991586A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/5038Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the execution order of a plurality of tasks, e.g. taking priority or time dependency constraints into consideration
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals

Abstract

The embodiment of the application provides a job distribution method, a dispatching system, electronic equipment and a computer storage medium, relates to the technical field of computers, and is applied to the dispatching system, wherein the method comprises the following steps: determining the number of jobs in a main queue, wherein the main queue is used for placing jobs with a first importance degree; determining a job distribution mode according to the number; according to the job distribution mode, indicating the main queue and the queue insertion queue to send the job to a critical area for processing the job; the queue inserting queue is used for placing jobs with a second importance degree, and the first importance degree is lower than the second importance degree; the job distribution mode includes: the first mode is that a vacancy is arranged in the main queue, when the head of the main queue is not the vacancy, the main queue is instructed to send the job to the critical area, and when the head of the main queue is the vacancy, the queue is instructed to send the job to the critical area; the second mode indicates that the main queue and the enqueue queue are alternately sent to the critical section. The application solves the balance of job distribution with different importance degrees.

Description

Job distribution method, scheduling system, electronic device, and computer storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a job distribution method, a scheduling system, an electronic device, and a computer storage medium.
Background
In the job scheduling algorithm, when a scheduling system is used for scheduling the jobs, one machine can only process one job, if a plurality of jobs are initiated at the same time, the jobs are queued, but if the importance degree of the jobs is higher, the jobs which are queued at the end of the queue according to the queuing order can be processed only after all the jobs which are queued at the front are processed, so that a scheduling system capable of distributing the jobs according to the importance degree of the jobs is needed to ensure that the important jobs can be processed as early as possible.
However, in the conventional job distribution method, a priority is generally given to each job, and the next job to be executed is determined in the order of the priority, however, in the conventional method, there are problems that the job with low priority cannot be solved for a long time, fairness among jobs with different priorities, and balance of job distribution with different priorities are poor.
Disclosure of Invention
The embodiment of the application provides a job distribution method, a scheduling system, electronic equipment and a computer storage medium, which are used for solving the technical problems that jobs with low priority cannot be solved for a long time, fairness among jobs with different priorities is poor, and balance of job distribution with different priorities is poor.
According to a first aspect of an embodiment of the present application, there is provided a job distributing method, applied to a scheduling system, the method including:
determining the number of jobs in a main queue, wherein the main queue is used for placing jobs with a first importance degree;
determining a current job distribution mode according to the number of the jobs;
according to the current job distribution mode, indicating the main queue and the queue insertion queue to distribute the job to a critical area for processing the job;
the queue inserting queue is used for placing jobs with a second importance degree, the first importance degree is lower than the second importance degree, and the main queue and the queue inserting queue are both first-in first-out queues;
the job distribution mode includes at least one of:
the first mode is that at least one vacancy is set in the main queue, when the head of the main queue is not the vacancy, the main queue is instructed to distribute the head of the job to the critical section, and when the head of the main queue is the vacancy, the queue insertion queue is instructed to distribute the head of the job to the critical section;
And a second mode, namely, instructing the main queue and the queue insertion queue to alternately distribute the head jobs to the critical section.
In one possible implementation, the indication module includes:
the first indicating unit is used for indicating the main queue to send the head job to the critical area when the critical area is empty and the head of the main queue is the job in the state to be sent;
the second indicating unit is used for indicating the queue to send the head job to the critical area when the critical area is empty, the head of the main queue is not the job in the state to be sent, and the head of the queue to be inserted is the job in the state to be sent;
a third indicating unit, configured to indicate, when the critical section is empty, the head of the main queue is empty, and the head of the enqueue queue is a job in a state to be sent, that the enqueue queue sends the job at the head to the critical section;
the job in the state to be sent is a job allowed to be sent to the critical section.
In another possible implementation, the indication module further includes:
a changing unit, configured to change a current job distribution mode to a first mode when the number of jobs in the main queue is not greater than a preset threshold;
And the sending unit is used for sending the head job to the critical section by the main queue when the head job of the queue insertion queue is not in a state to be sent.
In yet another possible implementation, the second determining module includes:
the first judging unit is used for judging that the job distribution mode is the second mode when the number of the jobs is larger than a preset threshold value;
and the second judging unit is used for judging that the job distribution mode is the first mode when the number of the jobs is not greater than a preset threshold value.
In yet another possible implementation, the number of slots is determined based on a number of jobs of at least one of the main queue and the enqueue queue.
In yet another possible implementation, the indication module includes:
the processing unit is used for indicating the main queue and the queue inserting to distribute the job to the critical section for processing the job according to the current job distribution mode when the state update of the job of the critical section is completed;
the critical section is also used for removing the completed operation.
In yet another possible implementation, the scheduling system further includes:
the generation module is used for generating a new job and updating the state of the new job to be started;
A first updating module, configured to determine a target queue of the new job according to the importance level of the new job; the target queue is the main queue or the queue inserting queue;
the second updating module is used for adding the new operation to the tail of the target queue when the new operation starts to be initialized, and updating the state of the new operation to be initialized;
a third updating module, configured to determine that the new job completes initialization, and update a state of the new job as waiting if the new job is located at a head of a queue and the critical section has a job;
the jobs in the initialization state and the waiting state are the jobs in the state to be sent.
In yet another possible implementation, the second determining module includes:
a mode determining unit configured to determine a mode according to the number of jobs in the main queue; the mode is a first mode or a second mode, and when the mode is the first mode, the current job distribution mode is represented as the first mode; when the mode is the second mode, representing that the current job distribution mode is the second mode;
the indication unit includes:
the mutex determining unit is used for determining the mutex according to whether the critical section has the operation or not; the mutex comprises a first mutex and a second mutex, when the mutex is the first mutex, the operation is characterized in that the operation is not allowed to be sent to the critical section, and when the mutex is the second mutex, the operation is characterized in that the operation is allowed to be sent to the critical section;
A semaphore determining unit configured to determine a semaphore according to at least one of the mode, a status of a head job in the main queue, whether a head in the main queue is a null, and a status of a head job in the enqueue queue; the semaphore is a first semaphore or a second semaphore; characterizing that the main queue transmits a job to the critical section when the semaphore is a first semaphore, and characterizing that the queue transmits a job to the critical section when the semaphore is a second semaphore;
and when the mutex is a second mutex, transmitting the semaphore to at least the queue indicated by the semaphore.
In yet another possible implementation, the signal determining unit includes:
a semaphore first determination unit: the signal quantity is a first signal quantity when the mode is a first mode and the operation of the head of the main queue is in a state to be sent;
when the mode is a first mode, the operation at the head of the main queue is not in a state to be transmitted, and the operation at the head of the queue insertion queue is in a state to be transmitted, the signal is a second signal quantity;
when the mode is a first mode, the head of the main queue has a vacancy, and the operation of the head of the queue insertion queue is in a state to be transmitted, the semaphore is a second semaphore;
When the mode is a second mode, the job at the head of the main queue is in a state to be sent, and the job is sent to the critical area by the queue for the previous round, the semaphore is a first semaphore;
when the mode is a second mode, the job at the head of the queue insertion queue is in a to-be-sent state, and the job is sent to the critical area from the main queue for the previous round, the semaphore is a second semaphore;
when the mode is the second mode and the head operation of the enqueue queue is not in a state to be sent, the semaphore is the first semaphore.
According to a second aspect of an embodiment of the present application, there is provided a scheduling system, the apparatus comprising:
the first determining module is used for determining the number of the jobs in the main queue, and the main queue is used for placing the jobs with the first importance degree;
the second determining module is used for determining a current job distribution mode according to the job number;
the indication module is used for indicating the main queue and the queue inserting queue to distribute the job to a critical area for processing the job according to the current job distribution mode;
the queue inserting queue is used for placing jobs with a second importance degree, the first importance degree is lower than the second importance degree, and the main queue and the queue inserting queue are both first-in first-out queues;
The job distribution mode includes at least one of:
the first mode is that at least one vacancy is set in the main queue, when the head of the main queue is not the vacancy, the main queue is instructed to distribute the head of the job to the critical section, and when the head of the main queue is the vacancy, the queue insertion queue is instructed to distribute the head of the job to the critical section;
and a second mode, namely, instructing the main queue and the queue insertion queue to alternately distribute the head jobs to the critical section.
According to a third aspect of embodiments of the present application, there is provided an electronic device comprising a memory, a processor and a computer program stored on the memory, the processor implementing the steps of the method as provided in the first aspect when the program is executed.
According to a fourth aspect of embodiments of the present application, there is provided a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method as provided by the first aspect.
According to a fifth aspect of embodiments of the present application, there is provided a computer program product comprising computer instructions stored in a computer readable storage medium, which when read from the computer readable storage medium by a processor of a computer device, the computer instructions are executed by the processor causing the computer device to perform the steps of the method as provided by the first aspect.
The technical scheme provided by the embodiment of the application has the beneficial effects that:
according to the job distribution method provided by the embodiment of the application, based on the importance degree of the jobs, the jobs are classified into the jobs with the first importance degree and the jobs with the second importance degree, the jobs with the first importance degree with the lower importance degree are placed in the main queue, the jobs with the second importance degree with the higher importance degree are placed in the queue for inserting the queue, and the current job distribution mode is determined according to the number of the jobs in the current main queue, namely the busy degree of the jobs in the current main queue, wherein the job distribution mode comprises a first mode and a second mode, the first mode indicates the main queue and the queue for inserting the jobs to be distributed to a critical area for processing the jobs, a vacancy is set in the main queue, when the head in the main queue is not the vacancy, the job is continuously sent to the critical area by the main queue, and when the head in the main queue is the vacancy, the job with the head is indicated by the queue, so that the job with the higher importance degree in the main queue can be ensured to be processed in time according to the setting under the condition that the jobs with the lower importance degree in the main queue cannot be processed for a long time; the second mode indicates the main queue and the queue inserting to distribute the job to the critical area for processing the job, and the main queue and the queue inserting alternately send the job to the critical area for processing the job, so that the balance of job distribution in the main queue and the queue inserting is ensured, long-time queuing caused by lower importance of the job is avoided, and the job cannot be processed; the method solves the technical problems that the operation with low importance degree cannot be solved for a long time, the fairness among the operations with different importance degrees and the balance of the operation distribution with different importance degrees are poor.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings that are required to be used in the description of the embodiments of the present application will be briefly described below.
Fig. 1 is a schematic diagram of a system architecture for implementing a job distribution method according to an embodiment of the present application;
fig. 2 is a flow chart of a job distributing method according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a head job of a main queue being a null bit according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a status update procedure of a header operation in a primary queue according to an embodiment of the present application;
FIG. 5 is a schematic diagram of a status update process of a head job in a queue for enqueuing according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a scheduling system according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Embodiments of the present application are described below with reference to the drawings in the present application. It should be understood that the embodiments described below with reference to the drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application, and the technical solutions of the embodiments of the present application are not limited.
As used herein, the singular forms "a", "an", "the" and "the" are intended to include the plural forms as well, unless expressly stated otherwise, as understood by those skilled in the art. It will be further understood that the terms "comprises" and "comprising," when used in this specification, specify the presence of stated features, information, data, steps, operations, elements, and/or components, but do not preclude the presence or addition of other features, information, data, steps, operations, elements, components, and/or groups thereof, all of which may be included in the present specification. It will be understood that when an element is referred to as being "connected" or "coupled" to another element, it can be directly connected or coupled to the other element or intervening elements may be present. Further, "connected" or "coupled" as used herein may include wirelessly connected or wirelessly coupled. The term "and/or" as used herein indicates that at least one of the items defined by the term, e.g., "a and/or B" may be implemented as "a", or as "B", or as "a and B".
For the purpose of making the objects, technical solutions and advantages of the present application more apparent, the embodiments of the present application will be described in further detail with reference to the accompanying drawings.
The following description of the terminology and related art related to the application:
and (3) operation: a job is a collection of work that a user requires a computer system to do during a calculation of a question or in a transaction. Job is a broader concept than program, which not only contains usual programs and data, but also should be equipped with a job instruction. The system controls the programs and data in the form of files through the job specification to be executed and operated, and establishes a data structure of the job control block in the system. In a batch processing system, memory is transferred from memory to memory in units of operations.
The following description will explain the related art, which generally has the following problems:
in the related art, the cyclic inquiry is usually carried out according to the queue, the queue adopts a first-in first-out structure, when the queue is overlong, some important jobs are arranged at the back, the waiting time is longer, therefore, the problem that the waiting processing time of the important jobs is overlong exists,
when two queues are used for placing the jobs, the problem of resource preemption can occur, and in addition, when the queues of the important tasks can perform the queue inserting operation, the distribution of the queues of the common tasks can be affected, so that the problem of poor fairness of job distribution is caused.
In view of at least one of the above-mentioned technical problems or needs to be improved, the present application proposes a job distributing method, in which a main queue is used for placing jobs of a first importance level by determining the number of jobs in the main queue; determining a current job distribution mode according to the number of jobs; according to the current job distributing mode, indicating a main queue and an enqueue queue to distribute the job to a critical section for processing the job; the queue inserting queue is used for placing the operation with the second importance degree, the first importance degree is lower than the second importance degree, and the main queue and the queue inserting queue are both first-in first-out queues; the job distribution mode includes at least one of: the first mode is that at least one vacancy is set in the main queue, when the head of the main queue is not the vacancy, the main queue is instructed to distribute the head of the job to the critical area, and when the head of the main queue is the vacancy, the queue is instructed to distribute the head of the job to the critical area; the second mode, which is to instruct the main queue and the enqueue queue to alternately distribute the head job to the critical section. The method can solve the technical problems that the operation with low importance degree cannot be solved for a long time, the fairness among the operations with different importance degrees and the balance of the operation distribution with different importance degrees are poor.
The technical solutions of the embodiments of the present application and technical effects produced by the technical solutions of the present application are described below by describing several exemplary embodiments. It should be noted that the following embodiments may be referred to, or combined with each other, and the description will not be repeated for the same terms, similar features, similar implementation steps, and the like in different embodiments.
Fig. 1 is a schematic diagram of a system architecture for implementing job distribution according to an embodiment of the present application, where the system architecture includes: a terminal 120 and a server 140.
The terminal 120 installs and runs an application program having a job distribution method.
The terminal 120 is connected to the server 140 through a wireless network or a wired network.
Server 140 includes at least one of a server, a plurality of servers, a cloud computing platform, and a virtualization center. Illustratively, the server 140 includes a processor 144 and a memory 142, the memory 142 including a display module 1421, a control module 1422, and a receiving module 1423. The server 140 is used to provide a background service for an application program of the job distribution method. Optionally, the server 140 takes on primary computing work and the terminal 120 takes on secondary computing work; alternatively, the server 140 takes on secondary computing work and the terminal 120 takes on primary computing work; alternatively, the server 140, the terminal 120, and the server are cooperatively computed using a distributed computing architecture.
Optionally, the device types of the terminal include: at least one of a smart phone, a tablet computer, an electronic book reader, a dynamic video expert compression standard audio layer 3 (MovingPicture Experts Group Audio Layer III, MP 3) player, a dynamic video expert compression standard audio layer 4 (Moving Picture Experts Group Audio Layer IV, MP 4) player, a laptop portable computer, and a desktop computer.
Those skilled in the art will recognize that the number of terminals may be greater or lesser. Such as the above-mentioned terminals may be only one, or the above-mentioned terminals may be several tens or hundreds, or more. The embodiment of the application does not limit the number of terminals and the equipment type.
The embodiment of the application provides a job distribution method, as shown in fig. 2, applied to a scheduling system, wherein the scheduling system can be arranged on a terminal in fig. 1, a server in fig. 1, and a terminal and a server in fig. 1, and the method comprises the following steps:
s101, determining the number of jobs in a main queue, wherein the main queue is used for placing jobs with a first importance degree. The queue inserting queue is used for placing the operation with the second importance degree, the first importance degree is lower than the second importance degree, and the main queue and the queue inserting queue are both first-in first-out queues;
In the embodiment of the application, the jobs are divided into the jobs with the first importance degree and the jobs with the second importance degree, wherein the jobs with the first importance degree are lower than the jobs with the second importance degree, and the jobs with the different importance degrees are respectively placed in a main queue and an inserting queue, and the main queue and the inserting queue are both first-in first-out queues, so that the jobs which enter first in the inserting queue and the main queue are processed first.
The embodiment of the application provides a possible implementation mode, a new job is generated, and the state of the new job is updated to be started; determining a target queue of the new job according to the importance degree of the new job; the target queue is a main queue or an enqueue queue; when the new operation starts to be initialized, adding the new operation at the tail of the target queue, and updating the state of the new operation to be initialized; determining that the new operation is initialized, and if the new operation is positioned at the head of the queue and the operation exists in the critical area, updating the state of the new operation to be waiting; the jobs in the initialization state and the waiting state are the jobs in the state to be sent.
In the embodiment of the application, when the generation of a new job is completed and the state of the new job in the generation process is set as the starting state, a queue to be added to the new job, namely a target queue, is determined based on the importance degree, after the target queues of each new job are determined, when the new job completes the starting state and starts to initialize, the new job is added to the tail of the corresponding target queue, at this time, the state of the job is set as the initialization state, the job after the initialization state is completed, and if the job after the initialization is completed at this time, the job is in the head of the queue and the job exists in the critical area, therefore, the job is set as the waiting state.
The state of the job in the queue can be used for timely knowing whether the job which can be sent to the critical area for processing exists in the current queue, and when the job which runs the state to be sent to the critical area does not exist in the queue, other queues can be sent timely, so that the problem that the critical area is idle and the job distribution of other queues is affected is avoided.
S102, determining a current job distribution mode according to the number of the jobs.
The embodiment of the application provides a possible implementation mode, and when the number of the jobs is greater than a preset threshold, the job distribution mode is a second mode; when the number of jobs is not greater than a preset threshold, the job distribution mode is a first mode.
In the embodiment of the present application, since the job distribution mode is the second mode when the number of jobs in the main queue is greater than the preset threshold, the job distribution mode is the first mode when both the enqueue queue and the main queue are in the empty initial state, that is, the job is distributed based on the first mode at the beginning, and as the number of jobs in the main queue increases above the preset threshold, the job starts to be distributed based on the second mode.
In the embodiment of the application, the preset threshold value can be set based on the duty ratio of the jobs in the main queue to all the queued jobs.
S103, according to the current job distribution mode, the main queue and the queue inserting queue are instructed to distribute the job to a critical section for processing the job.
The embodiment of the application provides a possible implementation way, when the state of the job of the critical section is updated to be finished, according to the current job distribution mode, a main queue and an enqueue queue are instructed to distribute the job to the critical section for processing the job; the critical section is also used for removing completed operation.
In the embodiment of the application, the critical section processes one job at a time, when the critical section has a job being processed, the main queue and the queue insertion queue cannot send the job to the critical section, so when the status of the job in the critical section is updated from being processed to being completed, the critical section removes the completed job from the critical section, and then the main queue or the queue insertion queue can send the job to the critical section based on the current job distribution mode.
In an embodiment of the present application, the job distribution mode includes at least one of:
the first mode is that at least one vacancy is set in the main queue, when the head of the main queue is not the vacancy, the main queue is instructed to distribute the head of the job to the critical area, and when the head of the main queue is the vacancy, the queue is instructed to distribute the head of the job to the critical area;
The second mode, which is to instruct the main queue and the enqueue queue to alternately distribute the head job to the critical section.
In the embodiment of the application, when the current job distribution mode is the first mode, a vacancy is set in the main queue, the vacancy is a blank space for not placing a job in the main queue, the vacancy is queued to the head of the queue along with the job in the main queue and then sent to the critical section, when the critical section is empty and the head of the main queue has a job, the job at the head is sent to the critical section by the main queue, when the critical section of the main queue is empty, the vacancy in the main queue is sent to the critical section, and the job is sent to the critical section by the queue in the queue, namely, when the job is sent to the critical section by the queue, the job is sent to the queue by the queue in turn, that is, when the head of the main queue is the job, the priority of the main queue is higher than the queue in the queue, and when the head of the main queue is the vacancy, the priority of the queue is higher than the main queue.
In the embodiment of the application, when the current job distribution mode is the second mode, the jobs in the main queue and the jobs in the queue insertion queue are distributed alternately, when the jobs which are round to the main queue are distributed, the priority of the main queue is higher than that of the queue insertion queue, and when the jobs which are round to the queue insertion queue are distributed, the priority of the queue insertion queue is higher than that of the main queue.
In one example, the alternate distribution may be to send one job to the critical section for the main queue and the queue inserting wheel, or may be to send a plurality of jobs to the critical section for the main queue and the queue inserting wheel in turn, where the purpose of the alternate distribution is to ensure that the main queue and the queue inserting wheel halve the distribution times of the jobs.
In the embodiment of the application, when the critical area is empty and the head of the main queue is the job in the state to be sent, the main queue is instructed to send the job at the head to the critical area under the condition that the job distribution mode is the first mode; the job to be sent is a job allowed to be sent to the critical section.
In the embodiment of the application, the jobs in the main queue and the queue insertion queue have multiple states, and when the jobs in the queues are in a to-be-sent state, the jobs represent all preparations before the jobs are processed, and can be sent to a critical area by the queues for processing.
In one example, when the job distribution mode is the first mode, the critical section is empty, which indicates that a job can be sent to the critical section at this time, and when the job at the head of the main queue is a job in a state to be sent, the main queue is instructed to send the job at the head to the critical section for processing.
In the embodiment of the application, when the critical area is empty, the head of the main queue is not the job in the state to be sent, and the head of the queue is the job in the state to be sent under the condition that the job distribution mode is the first mode, the queue is instructed to send the job at the head to the critical area.
In one example, when the job distribution mode is the first mode, the critical section is empty, which indicates that a job can be sent to the critical section at this time, and if the job at the head of the main queue is not in a state to be sent, which indicates that no job can be sent at this time in the main queue, so that the enqueue queue is instructed to send the job at the head to the critical section.
In the embodiment of the application, when the critical area is empty, the head of the main queue is empty, and the head of the queue is a job in a state to be sent, the queue is instructed to send the job at the head to the critical area when the job distribution mode is the first mode.
In one example, when the job distribution mode is the first mode, the fact that the critical section is empty indicates that a job can be sent to the critical section at this time, and if the job at the head of the main queue is empty, it indicates that the round-robin queue sends a job to the critical section at this time, and if at the same time, the round-robin queue sends a job to the critical section. The head job of the queue is in a state to be sent, which indicates that the job allowed to be sent to the critical section exists in the queue, so that the queue is instructed to send the head job to the critical section.
Referring to fig. 3, there is schematically shown a schematic diagram in which, in the case of the first mode, a null appears at the head of the main queue, specifically as follows:
the vertical queue is an inserting queue, the horizontal queue is a main queue, the black filling area is a critical area, (1) the job with an initialization or waiting state in the head of the inserting queue; (2) and when the critical area is empty, the head of the main queue is empty, and the head of the queue insertion queue has an operation in an initialization or waiting state, the queue insertion queue sends (1) to the critical area, and the main queue sends (2) to the critical area to be empty, so that (1) in the queue insertion queue enters a processing state.
One possible implementation manner is provided in the embodiment of the application, and the number of the empty spaces is determined according to the number of the jobs of at least one of the main queue and the queue insertion queue.
In the embodiment of the application, when the head of the main queue is the empty space, the job is sent to the critical area by the queue insertion queue, so that the more the empty space is arranged in the main queue, the more the job which can be sent to the critical area by the queue insertion queue, the more the job in the queue insertion queue can be processed, and a large number of queues can be avoided.
In the embodiment of the application, the vacancy setting is only used when the job distribution mode is the first mode, so that the number of jobs in the main queue is not increased, the number of jobs in the current main queue and the queue insertion queue is required to be considered in the setting of the vacancy, when the number of jobs in the queue insertion queue is increased compared with the number of jobs in the main queue, the frequency of placing the vacancy and the number of placing the vacancy each time are required to be considered to be increased, the jobs in the queue insertion queue can be processed as soon as possible, and when the number of jobs in the queue insertion queue is reduced compared with the number of jobs in the main queue, the frequency of setting the vacancy can be reduced, and the jobs in the main queue and the queue insertion queue can be uniformly distributed to a critical area; when the number of the jobs in the queue insertion queue is smaller than that in the main queue, the setting frequency of the vacant positions is reduced, and the jobs in the main queue can be processed as soon as possible without backlog.
In one example, in the case that the current job distribution mode is the first mode, when the number of jobs in the main queue is 6 and the number of jobs in the enqueue queue is 2, a vacancy is placed at the tail of the main queue, and when the main queue generates three new jobs, a vacancy is set thereafter; when the number of the jobs in the main queue is 6 and the number of the jobs in the queue inserting queue is 7, a vacancy is placed at the tail of the main queue, and when the main queue generates a new job, a vacancy is arranged at the tail of the main queue; when the number of the jobs in the main queue is 6 and the number of the jobs in the queue insertion queue is 12, 2 empty spaces are placed at the tail of the main queue, and when the main queue generates 1 new job, 2 empty spaces are set at the tail of the main queue.
It should be noted that, in the first mode, a vacancy may be randomly inserted into the tail of the main queue, or alternatively, a vacancy may be inserted into the tail of the main queue according to a rule.
In the embodiment of the application, a possible implementation manner is provided, when the number of the jobs in the main queue is not greater than a preset threshold value under the condition that the job distribution mode is the second mode, the current job distribution mode is changed into the first mode; and when the head job of the queue insertion queue is not in a state to be sent, sending the head job to the critical section by the main queue.
In the embodiment of the application, when the current job distribution mode is the second mode, the main queue and the queue inserting queue alternately send the jobs to the critical area, and when the number of the jobs in the main queue is not greater than a preset threshold value in the process of executing the job distribution, the current job distribution mode is modified to be the first mode, and the main queue and the queue inserting queue distribute the jobs according to the first mode.
In the embodiment of the application, when the current job distribution mode is the second mode, the main queue and the queue insertion queue alternately send the jobs to the critical area, and in the process of executing the job distribution, if the job at the head of the queue insertion queue is not in a to-be-sent state or no job exists, the job which is not required to be sent to the critical area for processing by the queue insertion queue at the moment is indicated, so that the job is not sent to the critical area in an alternate distribution mode of the main queue and the queue insertion queue, and at the moment, the job is sent to the critical area by the main queue until the job in the to-be-sent state exists at the head of the queue insertion.
When the number of the jobs in the main queue is large, the jobs are alternately sent to the critical area through the main queue and the queue inserting queues, and as no empty space is arranged in the second mode, the jobs in the main queue with large number of the jobs are prevented from being frequently queued, the long-time queuing of the jobs in the main queue is avoided, the jobs in the queue inserting queues are prevented from being queued for a long time in an alternative distributing mode, the jobs in the queue inserting queues cannot be processed, and the job distributing balance of the main queue and the queue inserting queues is ensured.
The embodiment of the application provides a possible implementation mode, and the mode is determined according to the number of the jobs in the main queue; the mode is a first mode or a second mode, and when the mode is the first mode, the current job distribution mode is characterized as the first mode; and when the mode is the second mode, the current job distribution mode is represented as the second mode.
In one example, the mode is a first mode when the number of jobs in the master queue is not greater than a preset threshold; and when the number of the jobs summarized by the main queue is greater than a preset threshold value, the mode is a second mode.
The embodiment of the application provides a possible implementation mode, and the mutex is determined according to whether the operation exists in the critical section; the mutex includes a first mutex and a second mutex, and the token does not allow sending the job to the critical section when the mutex is the first mutex, and the token allows sending the job to the critical section when the mutex is the second mutex.
In one example, since a critical section processes one job at a time, when there is a job in the critical section, the job is not allowed to be sent to the critical section, the mutex is a first mutex, and when there is no job in the critical section, the job is allowed to be sent to the critical section, and the mutex is a second mutex.
The embodiment of the application provides a possible implementation manner, and the semaphore is determined according to at least one of a mode, a state of head operation in a main queue, whether the head in the main queue is a vacant position or not and a state of head operation in an inserting queue; the semaphore is a first semaphore or a second semaphore; when the semaphore is a first semaphore, the main queue is characterized to send the job to the critical section, and when the semaphore is a second semaphore, the queue is characterized to send the job to the critical section; when the mutex is the second mutex, the semaphore is sent to at least the queue indicated by the semaphore.
In the embodiment of the application, the signal quantity is determined according to at least one of the current mode, the state of the head operation in the main queue, whether the head in the main queue is a vacant position or not and the state of the head operation in the queue insertion, so that the task is determined to be sent to the critical area by which queue.
The embodiment of the application provides a possible implementation manner, and when the mode is a first mode and the operation of the head of the main queue is in a state to be sent, the signal quantity is a first signal quantity.
In one example, when the mode is the first mode, it is described that the current job distribution mode is the first mode, and when the job distribution mode is the first mode, the head job of the main queue is transmitted to the critical section by the main queue when the head job of the main queue is in the ready-to-transmit state, and therefore, the semaphore is the first semaphore at this time.
The embodiment of the application provides a possible implementation manner, and when the mode is the first mode, the operation of the head of the main queue is not in a state to be transmitted, and the operation of the head of the queue is in the state to be transmitted, the signal is the second semaphore.
In one example, when the mode is the first mode, it indicates that the current job distribution mode is the first mode, when the job distribution mode is the first mode, the head job of the main queue is not in a to-be-transmitted state, it indicates that no job capable of being transmitted to the critical section is in the main queue, the head job of the queue is in a to-be-transmitted state, and it indicates that there is a job capable of being transmitted to the critical section in the queue, so that at this time, the job is transmitted to the critical section by the queue, and the semaphore is the second semaphore.
The embodiment of the application provides a possible implementation mode, and when the mode is a first mode, the head of the main queue has a vacancy, and the operation of the head of the queue is in a state to be transmitted, the semaphore is a second semaphore.
In one example, when the mode is the first mode, the current job distribution mode is the first mode, when the job distribution mode is the first mode, the head of the main queue has a vacancy, which indicates that the job is sent to the queue in a round-robin mode, the head job of the queue in a state to be sent is indicated, and the job which can be sent to the critical section for processing is indicated in the queue in a round-robin mode, therefore, the job is sent from the queue in a round-robin mode, and the signal is the second signal.
The embodiment of the application provides a possible implementation mode, and when the mode is the second mode, the job at the head of the main queue is in a state to be sent, and the job is sent to the critical area by the queue for the previous round, the semaphore is a first semaphore.
In one example, when the mode is the second mode, the current job distribution mode is the second mode, when the job distribution mode is the second mode, the job is transmitted to the critical section by the queue insertion queue for the previous round, the job is transmitted to the critical section by the main queue for the previous round, the job at the head of the main queue is the job in the state to be transmitted, and the job which can be transmitted to the critical section for processing is indicated by the main queue, therefore, the job is transmitted by the main queue at this time, and the signal quantity is the first signal quantity.
The embodiment of the application provides a possible implementation manner, and when the mode is the second mode, the job at the head of the queue insertion queue is in a state to be sent, and the job is sent to the critical area from the main queue in the previous round, the semaphore is a second semaphore.
In one example, when the mode is the second mode, the current job distribution mode is the second mode, when the job distribution mode is the second mode, the job is sent to the critical section by the main queue in the previous round, the job is sent to the critical section by the queue insertion queue in the previous round, the head job of the queue insertion queue is in a to-be-sent state, the job which can be sent to the critical section for processing is indicated in the queue insertion queue, at the moment, the job is sent to the critical section by the queue insertion queue, and the signal quantity is the second signal quantity.
The embodiment of the application provides a possible implementation manner, and when the mode is the second mode and the head operation of the queue is not in a state to be transmitted, the signal quantity is the first signal quantity.
In one example, when the mode is the second mode, it indicates that the current job distribution mode is the second mode, and when the job distribution mode is the second mode, the head job of the enqueue queue is not in a to-be-transmitted state, which indicates that no job that can be transmitted to the critical section is in the enqueue queue, so that at this time, the job is transmitted to the critical section by the main queue, and the semaphore is the first semaphore.
Referring to FIG. 4, a flow chart for status update of head jobs in a main queue is shown, as follows:
1. when the operation is started, the state is changed from starting to initializing;
2. when there is a job in the critical section and the head job of the main queue is in the initialized state, the state of the head job is updated to be waiting.
3. The current job distribution mode is a second mode, the job distribution is carried out by taking turns to the queue insertion queue, and when the head job of the main queue is initialized, the state is updated to be waiting.
4. When the current job distribution mode is the first mode, the critical section is empty, and the head job of the main queue is in an initialized or waiting state, the job is sent to the critical section, and the status of the job is updated to be in process.
5. When the current job distribution mode is a second mode, the job is distributed by taking turns to the main queue, the critical area is empty, and the head job state of the main queue is initialized or in-waiting state, the job is sent to the critical area, and the job state is updated to be in process.
6. The current job distribution mode is a second mode, the job of the queue is distributed after the job is rolled to the queue, the head job state of the queue is not initialized or waiting, the head job state of the main queue is initialized or waiting, the job is sent to a critical area, and the job state is updated to be in process.
7. The critical section completes the processing of the job, and the state update is the processing completion.
Referring to FIG. 5, a flow chart for updating the status of a head job in a queue for enqueue is shown, and the details are as follows:
a. when the operation is started, the state is changed from starting to initializing;
b. when there is a job in the critical section and the head job of the queue is in the initialized state, the state of the head job is updated to be waiting.
c. The current job distribution mode is a first mode, the head job of the queue is in an initialized state, and the state of the update job is in waiting.
d. The current job distributing mode is a second mode, the jobs which are round to the main queue are distributed, the head job of the queue insertion is in an initialized state, and the state of the head job is updated to be waiting.
e. The current job distribution mode is a second mode, the jobs which take turns to the queue for queue insertion are distributed, the head job of the queue for queue insertion is in an initialized or waiting state, the critical area is empty, and the state of the update job is in process.
f. The current job distribution mode is a first mode, the critical section is empty, no job in an initialized or waiting state exists in the main queue, and after the job is sent to the critical section, the state of the job is updated to be in process.
g. The current job distributing mode is a first mode, the critical area is empty, the head of the main queue is provided with a vacancy, the state of the head job of the queue insertion queue is waiting, the job is sent to the critical area, and the state of the job is updated to be in process.
h. The current job distributing mode is a second mode, the job is sent by turning to the main queue, the critical area is empty, the head job of the main queue is not in an initialized or waiting state, the head job of the queue inserting queue is in a waiting state, the job is sent to the critical area, and the job updating state is in processing.
i. The critical section completes the processing of the job, and the state update is the processing completion.
According to the job distribution method provided by the embodiment of the application, the jobs are classified into the jobs with the first importance degree and the jobs with the second importance degree based on the importance degree of the jobs, the jobs with the first importance degree with the lower importance degree are placed in the main queue, the jobs with the second importance degree with the higher importance degree are placed in the queue with the insertion degree, and the current job distribution mode is determined according to the number of the jobs in the current main queue, namely the busy degree of the jobs in the current main queue; the second mode indicates the main queue and the queue inserting to distribute the job to the critical area for processing the job, and the main queue and the queue inserting alternately send the job to the critical area for processing the job, so that the balance of job distribution in the main queue and the queue inserting is ensured, long-time queuing caused by lower importance of the job is avoided, and the job cannot be processed; before the job distribution is carried out, when the job which is not being processed in the critical section is determined, the queue insertion queue or the main queue can be instructed to send the job to the critical section, so that the phenomenon that the job is sent out and cannot be processed is avoided.
An embodiment of the present application provides a scheduling system, as shown in fig. 6, the scheduling system 60 may include: a first determination module 601, a second determination module 602, and an indication module 603, wherein,
the first determining module is used for determining the number of the jobs in the main queue, and the main queue is used for placing the jobs with the first importance degree;
the second determining module is used for determining a current job distribution mode according to the number of the jobs;
the instruction module is used for instructing the main queue and the queue inserting queue to distribute the job to a critical area for processing the job according to the current job distribution mode;
the queue inserting queue is used for placing the operation with the second importance degree, the first importance degree is lower than the second importance degree, and the main queue and the queue inserting queue are both first-in first-out queues;
the job distribution mode includes at least one of:
the first mode is that at least one vacancy is set in the main queue, when the head of the main queue is not the vacancy, the main queue is instructed to distribute the head of the job to the critical area, and when the head of the main queue is the vacancy, the queue is instructed to distribute the head of the job to the critical area;
the second mode, which is to instruct the main queue and the enqueue queue to alternately distribute the head job to the critical section.
The scheduling system provided by the embodiment of the application classifies the jobs into the jobs with the first importance degree and the jobs with the second importance degree based on the importance degree of the jobs, places the jobs with the first importance degree with lower importance degree in the main queue, places the jobs with the second importance degree with higher importance degree in the queue insertion queue, determines the current job distribution mode according to the number of the jobs in the current main queue, namely the busyness degree of the jobs in the current main queue, wherein the job distribution mode comprises a first mode and a second mode, the first mode indicates the main queue and the queue inserting queue to distribute the jobs to the critical area for processing the jobs, a vacancy is set in the main queue, when the head part in the main queue is not the vacancy, the main queue continuously sends the jobs to the critical area, when the head part of the main queue is the vacancy, the queue inserting queue is indicated to send the jobs at the head part to the critical area, and therefore the situation that the jobs with lower importance in the main queue cannot be processed for a long time can be achieved, and the jobs with higher importance in the queue inserting queue can be timely processed according to the setting of the vacancy; the second mode indicates the main queue and the queue inserting to distribute the job to the critical area for processing the job, and the main queue and the queue inserting alternately send the job to the critical area for processing the job, so that the balance of job distribution in the main queue and the queue inserting is ensured, long-time queuing caused by lower importance of the job is avoided, and the job cannot be processed; the method solves the technical problems that the operation with low importance degree cannot be solved for a long time, the fairness among the operations with different importance degrees and the balance of the operation distribution with different importance degrees are poor.
The device of the embodiment of the present application may perform the method provided by the embodiment of the present application, and its implementation principle is similar, and actions performed by each module in the device of the embodiment of the present application correspond to steps in the method of the embodiment of the present application, and detailed functional descriptions of each module of the device may be referred to the descriptions in the corresponding methods shown in the foregoing, which are not repeated herein.
Further, in one possible implementation, the indication module includes:
the first indicating unit is used for indicating the main queue to send the job at the head to the critical area when the critical area is empty and the head of the main queue is the job in the state to be sent;
the second indicating unit is used for indicating the queue to send the head job to the critical area when the critical area is empty, the head of the main queue is not the job in the state to be sent, and the head of the queue to be inserted is the job in the state to be sent;
the third indicating unit is used for indicating the queue to send the job at the head to the critical area when the critical area is empty, the head of the main queue is empty and the head of the queue is the job in the state to be sent;
the job to be sent is a job allowed to be sent to the critical section.
In another possible implementation, the indication module further includes:
a changing unit, configured to change a current job distribution mode to a first mode when the number of jobs in the main queue is not greater than a preset threshold;
and the sending unit is used for sending the head job to the critical section by the main queue when the head job of the queue insertion queue is not in a state to be sent.
In yet another possible implementation, the second determining module includes:
the first judging unit is used for judging that the job distribution mode is a second mode when the number of jobs is larger than a preset threshold value;
and the second judging unit is used for judging that the job distribution mode is the first mode when the number of the jobs is not more than a preset threshold value.
In yet another possible implementation, the number of slots is determined based on a number of jobs of at least one of the main queue and the enqueue queue.
In yet another possible implementation, the indication module includes:
the processing unit is used for indicating the main queue and the queue insertion queue to distribute the job to the critical section for processing the job according to the current job distribution mode when the state update of the job of the critical section is completed;
the critical section is also used for removing completed operation.
In yet another possible implementation, the scheduling system further includes:
the generating module is used for generating a new job, and updating the state of the new job to be started;
the first updating module is used for determining a target queue of the new job according to the importance degree of the new job; the target queue is a main queue or an enqueue queue;
the second updating module is used for adding a new job to the tail of the target queue when the new job starts to be initialized, and updating the state of the new job to be initialized;
the third updating module is used for determining that the new operation is initialized, and updating the state of the new operation to be waiting if the new operation is positioned at the head of the queue and the operation exists in the critical area;
the jobs in the initialization state and the waiting state are the jobs in the state to be sent.
In yet another possible implementation, the second determining module includes:
a mode determining unit for determining a mode according to the number of jobs in the main queue; the mode is a first mode or a second mode, and when the mode is the first mode, the current job distribution mode is characterized as the first mode; when the mode is the second mode, representing that the current job distribution mode is the second mode;
the indication unit includes:
The mutex determining unit is used for determining the mutex according to whether the operation exists in the critical section; the mutex comprises a first mutex and a second mutex, when the mutex is the first mutex, the token is not allowed to send the operation to the critical section, and when the mutex is the second mutex, the token is allowed to send the operation to the critical section;
a semaphore determining unit configured to determine a semaphore according to at least one of a mode, a state of a head job in the main queue, whether a head in the main queue is a null, and a state of a head job in the enqueue queue; the semaphore is a first semaphore or a second semaphore; when the semaphore is a first semaphore, the main queue is characterized to send the job to the critical section, and when the semaphore is a second semaphore, the queue is characterized to send the job to the critical section;
when the mutex is the second mutex, the semaphore is sent to at least the queue indicated by the semaphore.
In yet another possible implementation, the signal determining unit includes:
a semaphore first determination unit: when the mode is the first mode and the operation of the head of the main queue is in a state to be transmitted, the semaphore is a first semaphore;
when the mode is the first mode, the operation of the head of the main queue is not in a state to be transmitted, and the operation of the head of the queue insertion is in a state to be transmitted, the signal is a second signal quantity;
When the mode is the first mode, the head of the main queue has a vacancy, and the operation of the head of the queue insertion is in a state to be transmitted, the semaphore is a second semaphore;
when the mode is the second mode, the operation at the head of the main queue is in a state to be transmitted, and the operation is transmitted to the critical area from the queue for the previous round, the semaphore is a first semaphore;
when the mode is the second mode, the job at the head of the queue insertion queue is in a to-be-transmitted state, and the job is transmitted to the critical area from the main queue in the previous round, the semaphore is a second semaphore;
when the mode is the second mode and the head operation of the queue is not in a state to be transmitted, the semaphore is the first semaphore.
The embodiment of the application provides an electronic device (computer device/system), which comprises a memory, a processor and a computer program stored on the memory, wherein the processor executes the computer program to realize the steps of a job distribution method, and compared with the related technology, the method can realize the steps of the job distribution method: based on the importance degree of the operation, classifying the operation into the operation with the first importance degree and the operation with the second importance degree, placing the operation with the first importance degree with the lower importance degree in the main queue, placing the operation with the second importance degree with the higher importance degree in the queue, determining a current operation distribution mode according to the number of the operation in the current main queue, namely the busyness degree of the operation in the current main queue, wherein the operation distribution mode comprises a first mode and a second mode, indicating the main queue and the queue with the first mode to distribute the operation to a critical area for processing the operation, setting a vacancy in the main queue, continuously sending the operation to the critical area by the main queue when the head part in the main queue is not the vacancy, and indicating the queue with the head part to send the operation to the critical area when the head part of the main queue is the vacancy, so that the operation with the higher importance degree in the queue can be ensured to be processed in time according to the setting the vacancy under the condition that the operation with the lower importance degree in the main queue cannot be processed for a long time; the second mode indicates the main queue and the queue inserting to distribute the job to the critical area for processing the job, and the main queue and the queue inserting alternately send the job to the critical area for processing the job, so that the balance of job distribution in the main queue and the queue inserting is ensured, long-time queuing caused by lower importance of the job is avoided, and the job cannot be processed; the method solves the technical problems that the operation with low importance degree cannot be solved for a long time, the fairness among the operations with different importance degrees and the balance of the operation distribution with different importance degrees are poor.
In an alternative embodiment, an electronic device is provided, as shown in fig. 7, the electronic device 4000 shown in fig. 7 includes: a processor 4001 and a memory 4003. Wherein the processor 4001 is coupled to the memory 4003, such as via a bus 4002. Optionally, the electronic device 4000 may further comprise a transceiver 4004, the transceiver 4004 may be used for data interaction between the electronic device and other electronic devices, such as transmission of data and/or reception of data, etc. It should be noted that, in practical applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 is not limited to the embodiment of the present application.
The processor 4001 may be a CPU (Central Processing Unit ), general purpose processor, DSP (Digital Signal Processor, data signal processor), ASIC (Application Specific Integrated Circuit ), FPGA (Field Programmable Gate Array, field programmable gate array) or other programmable logic device, transistor logic device, hardware components, or any combination thereof. Which may implement or perform the various exemplary logic blocks, modules and circuits described in connection with this disclosure. The processor 4001 may also be a combination that implements computing functionality, e.g., comprising one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.
Bus 4002 may include a path to transfer information between the aforementioned components. Bus 4002 may be a PCI (Peripheral Component Interconnect, peripheral component interconnect standard) bus or an EISA (Extended Industry Standard Architecture ) bus, or the like. The bus 4002 can be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in fig. 7, but not only one bus or one type of bus.
Memory 4003 may be, but is not limited to, ROM (Read Only Memory) or other type of static storage device that can store static information and instructions, RAM (Random Access Memory ) or other type of dynamic storage device that can store information and instructions, EEPROM (Electrically Erasable Programmable Read Only Memory ), CD-ROM (Compact Disc Read Only Memory, compact disc Read Only Memory) or other optical disk storage, optical disk storage (including compact discs, laser discs, optical discs, digital versatile discs, blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store a computer program and that can be Read by a computer.
The memory 4003 is used for storing a computer program for executing an embodiment of the present application, and is controlled to be executed by the processor 4001. The processor 4001 is configured to execute a computer program stored in the memory 4003 to realize the steps shown in the foregoing method embodiment.
Among them, the electronic device package may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 7 is merely an example, and should not impose any limitations on the functionality and scope of use of embodiments of the present disclosure.
Embodiments of the present application provide a computer readable storage medium having a computer program stored thereon, which when executed by a processor, implements the steps of the foregoing method embodiments and corresponding content. Compared with the prior art, can realize: based on the importance degree of the operation, classifying the operation into the operation with the first importance degree and the operation with the second importance degree, placing the operation with the first importance degree with the lower importance degree in the main queue, placing the operation with the second importance degree with the higher importance degree in the queue, determining a current operation distribution mode according to the number of the operation in the current main queue, namely the busyness degree of the operation in the current main queue, wherein the operation distribution mode comprises a first mode and a second mode, indicating the main queue and the queue with the first mode to distribute the operation to a critical area for processing the operation, setting a vacancy in the main queue, continuously sending the operation to the critical area by the main queue when the head part in the main queue is not the vacancy, and indicating the queue with the head part to send the operation to the critical area when the head part of the main queue is the vacancy, so that the operation with the higher importance degree in the queue can be ensured to be processed in time according to the setting the vacancy under the condition that the operation with the lower importance degree in the main queue cannot be processed for a long time; the second mode indicates the main queue and the queue inserting to distribute the job to the critical area for processing the job, and the main queue and the queue inserting alternately send the job to the critical area for processing the job, so that the balance of job distribution in the main queue and the queue inserting is ensured, long-time queuing caused by lower importance of the job is avoided, and the job cannot be processed; the method solves the technical problems that the operation with low importance degree cannot be solved for a long time, the fairness among the operations with different importance degrees and the balance of the operation distribution with different importance degrees are poor.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The embodiment of the application also provides a computer program product, which comprises a computer program, wherein the computer program can realize the steps and corresponding contents of the embodiment of the method when being executed by a processor. Compared with the prior art, can realize: based on the importance degree of the operation, classifying the operation into the operation with the first importance degree and the operation with the second importance degree, placing the operation with the first importance degree with the lower importance degree in the main queue, placing the operation with the second importance degree with the higher importance degree in the queue, determining a current operation distribution mode according to the number of the operation in the current main queue, namely the busyness degree of the operation in the current main queue, wherein the operation distribution mode comprises a first mode and a second mode, indicating the main queue and the queue with the first mode to distribute the operation to a critical area for processing the operation, setting a vacancy in the main queue, continuously sending the operation to the critical area by the main queue when the head part in the main queue is not the vacancy, and indicating the queue with the head part to send the operation to the critical area when the head part of the main queue is the vacancy, so that the operation with the higher importance degree in the queue can be ensured to be processed in time according to the setting the vacancy under the condition that the operation with the lower importance degree in the main queue cannot be processed for a long time; the second mode indicates the main queue and the queue inserting to distribute the job to the critical area for processing the job, and the main queue and the queue inserting alternately send the job to the critical area for processing the job, so that the balance of job distribution in the main queue and the queue inserting is ensured, long-time queuing caused by lower importance of the job is avoided, and the job cannot be processed; the method solves the technical problems that the operation with low importance degree cannot be solved for a long time, the fairness among the operations with different importance degrees and the balance of the operation distribution with different importance degrees are poor.
The terms "first," "second," "third," "fourth," "1," "2," and the like in the description and in the claims and in the above figures, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate, such that the embodiments of the application described herein may be implemented in other sequences than those illustrated or otherwise described.
It should be understood that, although various operation steps are indicated by arrows in the flowcharts of the embodiments of the present application, the order in which these steps are implemented is not limited to the order indicated by the arrows. In some implementations of embodiments of the application, the implementation steps in the flowcharts may be performed in other orders as desired, unless explicitly stated herein. Furthermore, some or all of the steps in the flowcharts may include multiple sub-steps or multiple stages based on the actual implementation scenario. Some or all of these sub-steps or phases may be performed at the same time, or each of these sub-steps or phases may be performed at different times, respectively. In the case of different execution time, the execution sequence of the sub-steps or stages can be flexibly configured according to the requirement, which is not limited by the embodiment of the present application.
The foregoing is merely an optional implementation manner of some of the implementation scenarios of the present application, and it should be noted that, for those skilled in the art, other similar implementation manners based on the technical ideas of the present application are adopted without departing from the technical ideas of the scheme of the present application, and the implementation manner is also within the protection scope of the embodiments of the present application.

Claims (12)

1. A job distribution method, applied to a scheduling system, the method comprising:
determining the number of jobs in a main queue, wherein the main queue is used for placing jobs with a first importance degree;
determining a current job distribution mode according to the number of the jobs;
according to the current job distribution mode, indicating the main queue and the queue insertion queue to distribute the job to a critical area for processing the job;
the queue inserting queue is used for placing jobs with a second importance degree, the first importance degree is lower than the second importance degree, and the main queue and the queue inserting queue are both first-in first-out queues;
the job distribution mode includes at least one of:
the first mode is that at least one vacancy is set in the main queue, when the head of the main queue is not the vacancy, the main queue is instructed to distribute the head of the job to the critical section, and when the head of the main queue is the vacancy, the queue insertion queue is instructed to distribute the head of the job to the critical section;
And a second mode, namely, instructing the main queue and the queue insertion queue to alternately distribute the head jobs to the critical section.
2. The job distribution method according to claim 1, wherein, in the case where the job distribution mode is the first mode, instructing the main queue and the enqueue queue to distribute the job to the critical section for processing the job according to the current job distribution mode includes:
when the critical section is empty and the head of the main queue is a job in a state to be sent, indicating the main queue to send the job of the head to the critical section;
when the critical section is empty, the head of the main queue is not the job in the state to be sent, and the head of the queue insertion queue is the job in the state to be sent, the queue insertion queue is instructed to send the job at the head to the critical section;
when the critical section is empty, the head of the main queue is empty, and the head of the queue insertion queue is a job in a state to be sent, indicating the queue insertion queue to send the job of the head to the critical section;
the job in the state to be sent is a job allowed to be sent to the critical section.
3. The job distribution method according to claim 1, wherein, in the case where the job distribution mode is the second mode, the instructing the main queue and the enqueue queue to distribute the job to the critical section for processing the job according to the current job distribution mode further comprises:
When the number of the jobs in the main queue is not greater than a preset threshold, changing a current job distribution mode into a first mode;
and when the head operation of the queue insertion queue is not in a state to be sent, sending the head operation to the critical section by the main queue.
4. The job distribution method according to claim 1, wherein the determining the job distribution mode of the job according to the job number comprises:
when the number of the jobs is greater than a preset threshold, the job distribution mode is the second mode;
and when the number of the jobs is not greater than a preset threshold, the job distribution mode is the first mode.
5. The job distribution method according to claim 1, wherein the number of slots is determined according to the job number of at least one of the main queue and the enqueue queue.
6. The job distribution method according to claim 1, wherein the instructing the main queue and the enqueue queue to distribute the job to the critical section for processing the job according to the current job distribution mode includes:
when the state of the job of the critical section is updated to be finished, indicating the main queue and the queue insertion queue to distribute the job to the critical section for processing the job according to the current job distribution mode;
The critical section is also used for removing the completed operation.
7. The job distribution method according to claim 1, further comprising:
generating a new operation, and updating the state of the new operation to be started;
determining a target queue of the new job according to the importance degree of the new job; the target queue is the main queue or the queue inserting queue;
when the new operation starts to be initialized, adding the new operation at the tail of the target queue, and updating the state of the new operation to be initialized;
determining that the new operation is initialized, and if the new operation is positioned at the head of the queue and the operation exists in the critical area, updating the state of the new operation to be waiting;
the jobs in the initialization state and the waiting state are the jobs in the state to be sent.
8. The job distribution method according to claim 1, wherein the determining the current job distribution mode according to the job number comprises:
determining a mode according to the number of jobs in the main queue; the mode is a first mode or a second mode, and when the mode is the first mode, the current job distribution mode is represented as the first mode; when the mode is the second mode, representing that the current job distribution mode is the second mode;
The instruction, according to the current job distribution mode, of the main queue and the enqueue queue to distribute the job to a critical section for processing the job includes:
determining a mutex according to whether the critical section has the operation or not; the mutex comprises a first mutex and a second mutex, when the mutex is the first mutex, the operation is characterized in that the operation is not allowed to be sent to the critical section, and when the mutex is the second mutex, the operation is characterized in that the operation is allowed to be sent to the critical section;
determining a semaphore according to at least one of the mode, a state of a head job in the master queue, whether a head in the master queue is empty, and a state of a head job in the enqueue queue; the semaphore is a first semaphore or a second semaphore; characterizing that the main queue transmits a job to the critical section when the semaphore is a first semaphore, and characterizing that the queue transmits a job to the critical section when the semaphore is a second semaphore;
and when the mutex is a second mutex, transmitting the semaphore to at least the queue indicated by the semaphore.
9. The job distribution method according to claim 8, wherein the determining the signal amount according to at least one of the mode, the state of the head job in the main queue, whether the head in the main queue is empty, and the state of the head job in the enqueue queue comprises:
When the mode is a first mode and the operation of the head of the main queue is in a state to be sent, the semaphore is a first semaphore;
when the mode is a first mode, the operation at the head of the main queue is not in a state to be transmitted, and the operation at the head of the queue insertion queue is in a state to be transmitted, the signal is a second signal quantity;
when the mode is a first mode, the head of the main queue has a vacancy, and the operation of the head of the queue insertion queue is in a state to be transmitted, the semaphore is a second semaphore;
when the mode is a second mode, the job at the head of the main queue is in a state to be sent, and the job is sent to the critical area by the queue for the previous round, the semaphore is a first semaphore;
when the mode is a second mode, the job at the head of the queue insertion queue is in a to-be-sent state, and the job is sent to the critical area from the main queue for the previous round, the semaphore is a second semaphore;
when the mode is the second mode and the head operation of the enqueue queue is not in a state to be sent, the semaphore is the first semaphore.
10. A scheduling system, comprising:
The first determining module is used for determining the number of the jobs in the main queue, and the main queue is used for placing the jobs with the first importance degree;
the second determining module is used for determining a current job distribution mode according to the job number;
the indication module is used for indicating the main queue and the queue inserting queue to distribute the job to a critical area for processing the job according to the current job distribution mode;
the queue inserting queue is used for placing jobs with a second importance degree, the first importance degree is lower than the second importance degree, and the main queue and the queue inserting queue are both first-in first-out queues;
the job distribution mode includes at least one of:
the first mode is that at least one vacancy is set in the main queue, when the head of the main queue is not the vacancy, the main queue is instructed to distribute the head of the job to the critical section, and when the head of the main queue is the vacancy, the queue insertion queue is instructed to distribute the head of the job to the critical section;
and a second mode, namely, instructing the main queue and the queue insertion queue to alternately distribute the head jobs to the critical section.
11. An electronic device comprising a memory, a processor and a computer program stored on the memory, characterized in that the processor executes the computer program to carry out the steps of the method according to any one of claims 1-9.
12. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method according to any one of claims 1-9.
CN202311014419.8A 2023-08-11 2023-08-11 Job distribution method, scheduling system, electronic device, and computer storage medium Pending CN116991586A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311014419.8A CN116991586A (en) 2023-08-11 2023-08-11 Job distribution method, scheduling system, electronic device, and computer storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311014419.8A CN116991586A (en) 2023-08-11 2023-08-11 Job distribution method, scheduling system, electronic device, and computer storage medium

Publications (1)

Publication Number Publication Date
CN116991586A true CN116991586A (en) 2023-11-03

Family

ID=88521198

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311014419.8A Pending CN116991586A (en) 2023-08-11 2023-08-11 Job distribution method, scheduling system, electronic device, and computer storage medium

Country Status (1)

Country Link
CN (1) CN116991586A (en)

Similar Documents

Publication Publication Date Title
EP2783490B1 (en) Time-sensitive data delivery
CN107832143B (en) Method and device for processing physical machine resources
CN110750341B (en) Task scheduling method, device, system, terminal equipment and storage medium
CN112905342B (en) Resource scheduling method, device, equipment and computer readable storage medium
US20190158575A1 (en) Platform as a service cloud server and multi-tenant operating method thereof
CN111736957A (en) Multi-type service mixed deployment method, device, equipment and storage medium
CN111221638A (en) Scheduling processing method, device, equipment and medium for concurrent tasks
CN111026552B (en) Resource scheduling method and device, electronic equipment and computer readable storage medium
CN108304272B (en) Data IO request processing method and device
CN114168302A (en) Task scheduling method, device, equipment and storage medium
CN116991586A (en) Job distribution method, scheduling system, electronic device, and computer storage medium
CN110895517B (en) Method, equipment and system for transmitting data based on FPGA
CN116483584A (en) GPU task processing method and device, electronic equipment and storage medium
CN115878333A (en) Method, device and equipment for judging consistency between process groups
CN111694670B (en) Resource allocation method, apparatus, device and computer readable medium
CN110825342A (en) Memory scheduling device and system, method and apparatus for processing information
CN111813541B (en) Task scheduling method, device, medium and equipment
CN114675954A (en) Task scheduling method and device
CN114138626A (en) Horizontally scalable distributed system for automated firmware testing and method thereof
US11797342B2 (en) Method and supporting node for supporting process scheduling in a cloud system
CN112114971A (en) Task allocation method, device and equipment
CN111401992A (en) Data distribution method and device, storage medium and terminal
US20230195546A1 (en) Message Management Method and Apparatus, and Serverless System
US11432303B2 (en) Method and apparatus for maximizing a number of connections that can be executed from a mobile application
CN117234989A (en) Data transmission method, system, medium and terminal based on high-speed serial bus

Legal Events

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