Method for scheduling same-priority component tasks in component-based system
By applying genetic algorithms to optimize the scheduling and optimization of component tasks of the same priority in the component software system, the problems of low scheduling performance and resource utilization in the existing technology are solved, and more efficient resource utilization and system performance improvement are achieved.
Patent Information
- Application Number
- CN202411515713.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-02-21
AI Technical Summary
In the existing component software systems, the scheduling of component tasks at the same priority level has problems with low performance and resource utilization, making it difficult to effectively manage component resources in complex systems.
Genetic algorithms are used to schedule and optimize component tasks in component software systems, and combined with system resource requirements, component tasks of the same priority are sorted and scheduled to improve system performance and resource utilization.
Optimizing component task scheduling through genetic algorithms improves the system's resource utilization and overall performance, can better adapt to complex and changeable workloads, and improve the stability of the system.
Smart Images

Figure CN119493648A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of component software system and component task scheduling, and in particular relates to a method for scheduling component tasks with the same priority in a component system. Background Art
[0002] Component-based software systems are coupled by a series of independent, reusable components (assemblies). These components are the basic building blocks of the software system. They have well-defined interfaces and functions and can be independently designed, developed, tested, deployed and maintained. Each component is responsible for a specific task or function. Constructing software systems in a component-based manner helps improve the flexibility, maintainability and reusability of software development. The number of components in a software system is positively correlated with the complexity of the system's functions. Reasonable scheduling and management of the components of a complex system is an important factor in improving the resource utilization of component-based software systems and achieving load balancing.
[0003] Component tasks rely on components, and each component corresponds to a component task. Before the software system is started, each component and the corresponding component task need to be configured separately to follow consistent standards and specifications, so that they can be reused in different component-based systems to achieve reusability. The priority of each component task in the component-based software system and the size of the demand for system resources are factors that need to be considered during scheduling.
[0004] During the component configuration process, each component requires different system resources according to the complexity of its own functions, but the required comprehensive system resources cannot be clearly reflected. It can only be configured according to the attributes in the configuration file. While ensuring the priority, the component tasks with higher priority can be scheduled. However, in the case of equal priority, it is also necessary to comprehensively consider the configuration of relevant attributes in the component configuration file and the demand for system resources to obtain an optimal component task scheduling sequence; therefore, the existing technology has the problem of low performance and resource utilization. Summary of the invention
[0005] The purpose of the present invention is to provide a method for scheduling component tasks of the same priority in a componentized system. The method optimizes the task scheduling of component tasks of the componentized software system based on a genetic algorithm, and schedules component tasks of the same priority in the componentized software system in combination with system resource requirements to improve system performance and resource utilization.
[0006] In order to achieve the above tasks, the present invention adopts the following technical solutions:
[0007] A method for scheduling component tasks of the same priority in a component-based system, firstly configuring the configuration file of each component according to the unified configuration interface requirements given in advance by the component-based system, including the attribute information of the component and the configuration information of the component task corresponding to each component; the method comprises:
[0008] The first step is to initialize the componentized system;
[0009] The second step is to create a component task queue to store component tasks;
[0010] The third step is to read and parse the configuration file of each component task in the component task queue to obtain the attribute information of each component and the configuration information of the corresponding component task;
[0011] The fourth step is to traverse the component task queue, compare the priority of each component task with the priority of the remaining component tasks in the component task queue based on the component task priority in the component task configuration information, and sort the component tasks in the component task queue by priority, so that the component tasks in the task queue are arranged in descending order of priority;
[0012] Step 5: For the currently acquired build task, insert it into the build task queue according to the priority of the build task;
[0013] The sixth step is to compare the number of component tasks in the current component task queue with the total number of components in the componentized system. If the number of component tasks is less than the total number of components, it means that the component has not been read completely, and return to step three to continue reading the configuration file of the next component. If the number of component tasks is equal to the total number of components, all components have been read, and component tasks with the same priority are scheduled.
[0014] Furthermore, the scheduling of component tasks with the same priority level includes:
[0015] (1) Read the component task queue and obtain component tasks with the same priority as the component task targets optimized by the genetic algorithm;
[0016] (2) Encoding component tasks of the same priority level to obtain a chromosome representation of the component tasks of the same priority level, wherein the chromosome includes the component task numbers of the same priority level;
[0017] (3) Initializing the component task population; generating the component task population using a random method according to the chromosome representation of the component tasks with the same priority in the previous step;
[0018] (4) Calculate the individual fitness in the component task population.
[0019] A fitness function is constructed as a fitness evaluation, and according to the requirements of the stack size and the component task refresh cycle in the configuration file of the component task, the constraints of the component task stack size and the component task cycle in the component task scheduling problem are met;
[0020] (5) Determine whether the termination condition is met; if the preset termination condition is met, directly proceed to step (9); otherwise, go to step (6);
[0021] (6) Selection operation: performing chromosome selection operation by tournament selection method;
[0022] (7) Crossover operation: Each chromosome in the component task population must perform a crossover operation with a probability of μ c crossover; select two chromosomes from the component task population and generate a random number RN∈[0,1] for each chromosome; if RN<μ c , the chromosome will use one of two crossover methods for crossover operation, namely single-point crossover and sequential crossover, where μ c is the preset crossover probability;
[0023] (8) Mutation operation, in this case, the reverse mutation operation is used;
[0024] (9) After the preset termination condition is met, the chromosome with the maximum fitness value is the optimal individual;
[0025] (10) Component tasks of the same priority in the component task queue are sorted according to the component task numbers in the optimal individual, so as to obtain the optimal component task scheduling sequence while ensuring the priority.
[0026] Furthermore, the componentized system initialization includes:
[0027] Read the system configuration file, and read the information required for initialization of the componentized system including system name, system version, supported operating system, processor, system operation mode, component library path, and database path from the system configuration file.
[0028] Furthermore, the chromosome representation of the component tasks of the same priority level includes:
[0029] Component tasks of the same priority are numbered with integers to ensure that each component task has a unique integer identifier; an integer is assigned to each component task so that the value range of the integer is consistent with the number of component tasks of the same priority; the length of the chromosome is set to the number of component tasks of the same priority, which means that the value at each integer position corresponds to the component task at the corresponding position; in this way, the chromosome becomes an integer array, in which each integer represents the number of the component task of the same priority.
[0030] Furthermore, during the initial population generation process, the component task numbers in each chromosome are randomly generated and sorted until a specified number of chromosomes are generated to form a complete initial population.
[0031] Furthermore, the fitness function is expressed as follows:
[0032]
[0033] Among them, F is the fitness value, N is the chromosome length, i is the i-th sequence of the component task in the chromosome, t i is the estimated execution time of the i-th sequence component task in the chromosome, τ i is the refresh cycle of the i-th sequence component task in the chromosome, S is the preset single component task stack size threshold of the componentized system, S i is the stack size required for the i-th sequence component task in the chromosome, and α is the preset weight coefficient.
[0034] Furthermore, the crossover operation includes:
[0035] (7-1) Select two chromosomes, denoted as chromosome 1 and chromosome 2;
[0036] (7-2) Generate a random number RN, the value range of RN is [0,1];
[0037] (7-3) Comparison between RN and μ c , if RN<μ c , chromosome 1 and chromosome 2 perform a single-point crossover operation; if RN ≥ μ c , chromosome 1 and chromosome 2 perform sequential crossover operations.
[0038] Furthermore, the sequential crossover method includes:
[0039] Two intersections are randomly selected from component task sequence chromosome 1 and component task sequence chromosome 2, and the component task number segments between these intersections will be retained in the offspring; between the determined intersections, the corresponding component task number segments in chromosome 1 are directly copied to the offspring chromosome, and this part of the component task number segments remains unchanged; from chromosome 2, unused component task numbers are selected according to their order, and filled into the offspring chromosome in order, skipping the component task numbers that already exist in the offspring; after the unused component task numbers are filled, the duplicate component task numbers need to be processed, which can be done by looping through the chromosome starting from the end of the intersection, and filling the unused component task numbers into the offspring chromosome in the order of the second parent, and finally forming two new chromosome offspring.
[0040] Furthermore, the reverse mutation operation includes:
[0041] A position on the chromosome is randomly selected as the mutation point, and a segment of component task numbers starting from this point will be reversed; specifically, a new random integer RN is randomly generated, and RN is less than the remaining chromosome length to the right of the mutation point; starting from the mutation point, the component task numbers of length RN are reversed, and the reversed component task number segment replaces the original component task number segment to obtain the mutated chromosome.
[0042] A computer-readable storage medium stores a computer program; when the computer program is executed by a processor, the method for scheduling component tasks with the same priority level in the componentized system is implemented.
[0043] Compared with the prior art, the present invention has the following technical features:
[0044] The present invention is oriented to a componentized system. When the componentized system is initialized, the method for scheduling component tasks suitable for the componentized system is provided by reading the information of a component configuration file. Under the condition of ensuring the priority, the execution order of component tasks with the same priority is optimized by considering the demand of each component task for system resources and its own refresh cycle, so that the componentized system can better adapt to complex and changeable workloads, which is helpful to improve the resource utilization of the system and improve the overall performance and stability of the system. The flexibility and scalability of the method make it suitable for different types of componentized systems, and provide strong support for the design and implementation of the componentized system. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 It is a schematic diagram of component configuration;
[0046] Figure 2 It is a flowchart of component task queue initialization;
[0047] Figure 3 It is a flowchart for scheduling tasks of components with the same priority level. DETAILED DESCRIPTION
[0048] The technical problem solved by the present invention is to obtain the optimal scheduling sequence for component tasks of the same priority in a componentized system through a genetic algorithm. The specific implementation steps are divided into two parts. The first is as follows: Figure 2 The component task queue is initialized as shown. After the initialization is completed, the following steps are performed: Figure 3 The same priority component task queue scheduling shown in the figure, the specific implementation steps are as follows:
[0049] like Figure 1As shown, according to the unified configuration interface requirements given in advance by the component-based system, the configuration file of each component is configured through the XML file format type, including the attribute information of the component and the configuration information of the component task corresponding to each component. The attribute information of each component and the configuration information of the corresponding component task are uniformly configured in a component configuration file for easy management.
[0050] In this embodiment, the attribute information of the component includes the component name, component version, component mode, supported operating systems, supported processor architecture types, file name, component entry function, and component description; the configuration information of the component task includes the component task name, the associated component name, the component task priority, the component task stack size, the component task cycle, the component task mode, the operating system on which the component task runs, and the processor architecture type on which the component task runs.
[0051] The first step is to initialize the componentized system; read the system configuration file, and read the information required for the initialization of the componentized system from the system configuration file, including the system name, system version, supported operating system, processor, system operation mode, component library path, database path, etc.
[0052] The second step is to create a component task queue to store component tasks, and use a queue to facilitate task scheduling.
[0053] By using queues, component tasks can be added and removed at both ends of the queue, which complies with the first-in-first-out (FIFO) principle and ensures the orderly execution of component tasks. The characteristics of the queue enable newly read component tasks to be quickly added to the tail of the queue, while the system can easily obtain component tasks from the head of the queue for scheduling.
[0054] The third step is to read and parse the configuration file of each component task in the component task queue to obtain the attribute information of each component and the configuration information of the corresponding component task; a key step in this process is to ensure that the format of the configuration file meets the consistency specifications and requirements of the component-based system design, which means that the file structure, data format, and attribute definition specified by the system must be followed to ensure that the extracted information can be correctly identified and used by the system. This kind of normative compliance is crucial to ensure that the system can efficiently and accurately manage component attributes, so strict compliance with the specifications is a crucial link when reading and parsing configuration files.
[0055] The fourth step is to traverse the component task queue, and based on the component task priority in the component task configuration information, compare the priority of each component task with the priority of the remaining component tasks in the component task queue, and sort the component tasks in the component task queue by priority, so that the component tasks in the task queue are arranged in descending order of priority.
[0056] This comparison process may include checking whether the priority of the current component task is greater than or equal to the priority of the existing component task and less than the priority of the previously existing element. This ensures that the component tasks in the task queue are arranged in descending order of priority so as to effectively manage and execute the component tasks.
[0057] The fifth step is to insert the currently acquired build task into the build task queue according to the priority of the build task.
[0058] Step 6: Compare the number of component tasks in the current component task queue with the total number of components in the componentized system. If the number of component tasks is less than the total number of components, it means that the component has not been read completely, and return to step 3 to continue reading the configuration file of the next component. If the number of component tasks is equal to the total number of components, all components have been read, and component tasks with the same priority are scheduled. The details are as follows:
[0059] (1) Read the component task queue and obtain component tasks with the same priority as the component task targets optimized by the genetic algorithm.
[0060] (2) Encode component tasks of the same priority and obtain the chromosome representation of component tasks of the same priority.
[0061] Component tasks of the same priority are numbered with integers to ensure that each component task has a unique integer identifier; this process usually assigns an integer to each component task so that the value range of the integer is consistent with the number of component tasks of the same priority; the length of the chromosome (individual) is set to the number of component tasks of the same priority, which means that the value at each integer position corresponds to the component task at the corresponding position; in this way, the chromosome becomes an integer array, in which each integer represents the number of component tasks of the same priority.
[0062] (3) Initialize the component task population; according to the chromosome representation of the component tasks of the same priority in the previous step, use a random method to generate a component task population of size S; during the initial population generation process, the component task numbers in each chromosome are randomly generated and sorted until the specified number of chromosomes are generated to form a complete initial population.
[0063] (4) Calculate the individual fitness in the component task population.
[0064] A fitness function is constructed as a fitness evaluation. According to the requirements of the stack size and the component task refresh cycle in the configuration file of the component task, the constraints of the component task stack size and the component task cycle in the component task scheduling problem are met. Specifically,
[0065]
[0066] Among them, F is the fitness value, N is the chromosome length, i is the i-th sequence of the component task in the chromosome, t i is the estimated execution time of the i-th sequence component task in the chromosome, τ i is the refresh cycle of the i-th sequence component task in the chromosome, S is the preset single component task stack size threshold of the componentized system, S i is the stack size required for the i-th sequence component task in the chromosome, and α is the preset weight coefficient.
[0067] (5) Determine whether the termination condition is met; if the preset termination condition is met, directly proceed to step (9); otherwise, go to step (6);
[0068] (6) Selection operation: performing chromosome selection operation through tournament selection method.
[0069] (7) Crossover operation: Each chromosome in the component task population must perform a crossover operation with a probability of μ c crossover; select two chromosomes from the component task population and generate a random number RN∈[0,1] for each chromosome; if RN<μ c , the chromosome will use one of two crossover methods for crossover operation, namely single-point crossover and sequential crossover, where μ c is the preset crossover probability; the specific crossover operation steps are as follows:
[0070] (7-1) Select two chromosomes, denoted as chromosome 1 and chromosome 2;
[0071] (7-2) Generate a random number RN, the value range of RN is [0,1];
[0072] (7-3) Comparison between RN and μ c , if RN<μ c , chromosome 1 and chromosome 2 perform a single-point crossover operation; if RN ≥ μ c , chromosome 1 and chromosome 2 perform sequential crossover operations.
[0073] The single-point crossover method is: generate an integer from 1 to the length of the chromosome, called the crossover point, retain the left half of the crossover point of chromosome 1, subtract the component task number of the left half of chromosome 1 from chromosome 2, and merge the remaining part with the left half of chromosome 1 at crossover point 1 to form a new offspring; similarly, chromosome 1 and chromosome 2 are swapped, and the crossover point swap operation is performed to also obtain a new offspring, and finally two new offspring are obtained through the single-point crossover operation.
[0074] The sequential crossover method is: randomly select two crossover points from component task sequence chromosome 1 and component task sequence chromosome 2, and the component task number fragments between these crossover points will be retained in the offspring; between the determined crossover points, the corresponding component task number fragments in the first parent chromosome (chromosome 1) are directly copied to the offspring chromosome, and this part of the component task number fragments remains unchanged; from the second parent chromosome (chromosome 2), select unused component task numbers according to their order, and fill them into the offspring chromosome in order, skipping the component task numbers that already exist in the offspring; after filling the unused component task numbers, it is necessary to deal with duplicate component task numbers, which can be done by looping through the chromosome starting from the end of the crossover point, and filling the unused component task numbers into the offspring chromosome in the order of the second parent, and finally forming two new chromosome offspring, combining the characteristics of the two parent chromosomes.
[0075] (8) Mutation operation: a reverse mutation operation is used here; a position on the chromosome is randomly selected as the mutation point, and a segment of component task numbers starting from this point will be reversed; specifically, a new random integer RN is randomly generated, and RN is less than the remaining chromosome length to the right of the mutation point; starting from the mutation point, the component task numbers of length RN are reversed, and the reversed component task number segment replaces the original component task number segment to obtain the mutated chromosome.
[0076] (9) After the preset termination condition is met, the chromosome with the maximum fitness value is the optimal individual, that is, the optimal component task scheduling sequence of the same priority obtained by using the genetic algorithm based on constraints such as stack size and component task refresh time.
[0077] (10) Component tasks of the same priority in the component task queue are sorted according to the component task numbers in the optimal individual, so as to obtain the optimal component task scheduling sequence while ensuring the priority.
[0078] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for scheduling component tasks with the same priority in a component-based system, characterized in that: First, according to the unified configuration interface requirements given in advance by the component-based system, the configuration file of each component is configured, including the attribute information of the component and the configuration information of the component task corresponding to each component; the method includes: The first step is to initialize the componentized system; The second step is to create a component task queue to store component tasks; The third step is to read and parse the configuration file of each component task in the component task queue to obtain the attribute information of each component and the configuration information of the corresponding component task; The fourth step is to traverse the component task queue, compare the priority of each component task with the priority of the remaining component tasks in the component task queue based on the component task priority in the component task configuration information, and sort the component tasks in the component task queue by priority, so that the component tasks in the task queue are arranged in descending order of priority; Step 5: For the currently acquired build task, insert it into the build task queue according to the priority of the build task; The sixth step is to compare the number of component tasks in the current component task queue with the total number of components in the componentized system. If the number of component tasks is less than the total number of components, it means that the component has not been read completely, and return to step three to continue reading the configuration file of the next component. If the number of component tasks is equal to the total number of components, all components have been read, and component tasks with the same priority are scheduled.
2. The method for scheduling component tasks with the same priority level in a component-based system according to claim 1, characterized in that: The scheduling of component tasks with the same priority level includes: (1) Read the component task queue and obtain component tasks with the same priority as the component task targets optimized by the genetic algorithm; (2) Encoding component tasks of the same priority level to obtain a chromosome representation of the component tasks of the same priority level, wherein the chromosome includes the component task numbers of the same priority level; (3) Initializing the component task population; generating the component task population using a random method according to the chromosome representation of the component tasks with the same priority in the previous step; (4) Calculate the individual fitness in the component task population. A fitness function is constructed as a fitness evaluation, and according to the requirements of the stack size and the component task refresh cycle in the configuration file of the component task, the constraints of the component task stack size and the component task cycle in the component task scheduling problem are met; (5) Determine whether the termination condition is met; if the preset termination condition is met, directly proceed to step (9); otherwise, go to step (6); (6) Selection operation: performing chromosome selection operation by tournament selection method; (7) Crossover operation: Each chromosome in the component task population must perform a crossover operation with a probability of μ c crossover; select two chromosomes from the component task population and generate a random number RN∈[0,1] for each chromosome; if RN<μ c , the chromosome will use one of two crossover methods for crossover operation, namely single-point crossover and sequential crossover, where μ c is the preset crossover probability; (8) Mutation operation, in this case, the reverse mutation operation is used; (9) After the preset termination condition is met, the chromosome with the maximum fitness value is the optimal individual; (10) Component tasks of the same priority in the component task queue are sorted according to the component task numbers in the optimal individual, so as to obtain the optimal component task scheduling sequence while ensuring the priority.
3. The method for scheduling component tasks with the same priority level in a component-based system according to claim 1, characterized in that: The componentized system initialization includes: Read the system configuration file, and read the information required for initialization of the componentized system including system name, system version, supported operating system, processor, system operation mode, component library path, and database path from the system configuration file.
4. The method for scheduling component tasks with the same priority level in a component-based system according to claim 2, characterized in that: The chromosome representation of the component tasks of the same priority level includes: Component tasks of the same priority are numbered with integers to ensure that each component task has a unique integer identifier; an integer is assigned to each component task so that the value range of the integer is consistent with the number of component tasks of the same priority; the length of the chromosome is set to the number of component tasks of the same priority, which means that the value at each integer position corresponds to the component task at the corresponding position; in this way, the chromosome becomes an integer array, in which each integer represents the number of the component task of the same priority.
5. The method for scheduling component tasks with the same priority level in a component-based system according to claim 2, characterized in that: During the initial population generation process, the component task numbers in each chromosome are randomly generated and sorted until the specified number of chromosomes are generated to form a complete initial population.
6. The method for scheduling component tasks with the same priority level in a component-based system according to claim 2, characterized in that: The fitness function is expressed as follows: Among them, F is the fitness value, N is the chromosome length, i is the i-th sequence of the component task in the chromosome, t i is the estimated execution time of the i-th sequence component task in the chromosome, τ i is the refresh cycle of the i-th sequence component task in the chromosome, S is the preset single component task stack size threshold of the componentized system, S i is the stack size required for the i-th sequence component task in the chromosome, and α is the preset weight coefficient.
7. The method for scheduling component tasks with the same priority level in a component-based system according to claim 2, characterized in that: The crossover operation includes: (7-1) Select two chromosomes, denoted as chromosome 1 and chromosome 2; (7-2) Generate a random number RN, the value range of RN is [0,1]; (7-3) Comparison between RN and μ c , if RN<μ c , chromosome 1 and chromosome 2 perform a single-point crossover operation; if RN ≥ μ c , chromosome 1 and chromosome 2 perform sequential crossover operations.
8. The method for scheduling component tasks with the same priority level in a component-based system according to claim 7, characterized in that: The sequential crossover method includes: Two intersections are randomly selected from component task sequence chromosome 1 and component task sequence chromosome 2, and the component task number segments between these intersections will be retained in the offspring; between the determined intersections, the corresponding component task number segments in chromosome 1 are directly copied to the offspring chromosome, and this part of the component task number segments remains unchanged; from chromosome 2, unused component task numbers are selected according to their order, and filled into the offspring chromosome in order, skipping the component task numbers that already exist in the offspring; after the unused component task numbers are filled, the duplicate component task numbers need to be processed, which can be done by looping through the chromosome starting from the end of the intersection, and filling the unused component task numbers into the offspring chromosome in the order of the second parent, and finally forming two new chromosome offspring.
9. The method for scheduling component tasks with the same priority level in a component-based system according to claim 2, characterized in that: The reverse mutation operation includes: A position on the chromosome is randomly selected as the mutation point, and a segment of component task numbers starting from this point will be reversed; specifically, a new random integer RN is randomly generated, and RN is less than the remaining chromosome length to the right of the mutation point; starting from the mutation point, the component task numbers of length RN are reversed, and the reversed component task number segment replaces the original component task number segment to obtain the mutated chromosome.
10. A computer-readable storage medium, wherein a computer program is stored in the medium; characterized in that: When the computer program is executed by a processor, the method for scheduling component tasks with the same priority level in a component-based system according to any one of claims 1 to 9 is implemented.