Task scheduling method and system of application system, storage medium and electronic equipment
Through a task scheduling method, the complexity and coupling problems of traditional AUTOSAR AP middleware in application development are solved, and the rationality of task management and development flexibility are realized.
Patent Information
- Application Number
- CN202411746370.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-02
- Publication Date
- 2025-03-21
AI Technical Summary
In application development, traditional AUTOSAR AP middleware has problems such as many configuration options, difficulty in getting started, and high coupling between applications and middleware, which leads to difficulty in debugging and development.
A task scheduling method for application systems is proposed. By identifying the message information of the task description file, generating configuration files and task content, initializing the framework library, dynamic runtime library and component applications, creating a task execution framework, loading plug-ins for component applications, dynamically setting the execution time of the task and triggering the module to detect trigger information.
It realizes that task control is more reasonable, has low coupling, is easier to replace algorithms and improves debugging efficiency, provides a variety of task triggering methods and tools, and simplifies the application development process.
Smart Images

Figure CN119668808A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of intelligent vehicles, and in particular to a task scheduling method, system, storage medium and electronic equipment for an application system. Background Art
[0002] The EEA (electronic and electrical architecture) of the whole vehicle is developing from traditional distribution to domain / central integration, making the traditional electronic and electrical architecture of the whole vehicle evolve towards a new intelligent electronic and electrical architecture. Under the service-oriented architecture (SOA), the demand for computing power of deeply embedded systems has greatly increased. At the same time, chip platforms with higher bandwidth and higher computing power such as Ethernet have been widely used, the functions of the whole vehicle have begun to diversify, and the application, update and iteration of software in automobiles have become more complex and frequent.
[0003] The AUTOSAR AP basic software platform is based on the POSIX standard operating system. It adopts a service-oriented (SOA) architecture design, is dynamically deployed through software components, and interacts with non-vehicle systems to ensure the flexibility of vehicle applications. At the same time, it can reflect new functions and relevant regulatory requirements, providing better technical support and solutions for automotive software.
[0004] However, application development based on traditional AUTOSAR AP middleware has many configuration options and is difficult to get started. If an application wants to achieve specific functions, in addition to paying attention to its own algorithms, it also needs to pay attention to various irrelevant functions such as the program life cycle, service discovery process, and cumbersome message receiving and sending interfaces. In addition, the degree of coupling between the application and the middleware is high, and some plug-ins cannot be freely replaced, which will bring great difficulties in the debugging and development stage. Summary of the invention
[0005] The purpose of the present invention is to solve the shortcomings of the prior art and to propose a task scheduling method, system, storage medium and electronic device for an application system.
[0006] In order to achieve the above object, the present invention adopts the following technical solution: a task scheduling method for an application system, comprising:
[0007] Identify the message information of the task description file and obtain the configuration file and task;
[0008] The application process is started and the configuration file is written;
[0009] Initialize the framework library, dynamic runtime library and component applications;
[0010] Based on the configuration file, the framework library creates a task execution framework;
[0011] Based on the task, loading the framework library and component application;
[0012] The dynamic runtime library sets the task execution time, executes the task, and the trigger module detects whether the trigger information is received. If yes, the trigger strategy is determined and the plug-in in the component application is called.
[0013] As a further description of the above technical solution: the message information of the identification task description file includes: the framework library receives and parses the task description file, obtains the configuration file, parses the configuration file, generates the task content, and determines the corresponding component application according to the task content.
[0014] As a further description of the above technical solution: the framework library creates a task execution framework including:
[0015] The framework library reads the content of the configuration file, creates a task in the task creation module and / or sets an instance of trigger judgment in the trigger module;
[0016] The dynamic runtime library establishes a read-write object of the interface, loads the plug-in of the component application, and obtains the task content rewritten by the application process.
[0017] As a further description of the above technical solution: the execution task includes: starting the timer and running the task, generating a timer task corresponding to the task, setting the execution time of the task, judging whether the task is executed within the time interval, if not, sending a trigger message, if yes, after the task is executed, the application process sends an exit signal to the framework library, dynamic runtime library and component application to exit execution.
[0018] As a further description of the above technical solution: the trigger module detects whether the trigger information is received, including:
[0019] If yes, the trigger type is determined to be that the task is not executed within the time interval.
[0020] Or, the tasks are arranged with at least two in the time interval;
[0021] Determine a trigger strategy according to the trigger type, and determine the trigger strategy to be timer trigger, single message trigger, multi-message asynchronous trigger or multi-message synchronous trigger;
[0022] If not, continue executing the task.
[0023] Also included is a task scheduling system for automotive software applications, the scheduling system being applicable to the scheduling method described in any one of the above technical solutions, including:
[0024] Application process, controls the start and stop of the application, and calls the task content of the framework library when it starts;
[0025] Framework library, reads configuration files and task contents, and establishes an execution framework for task operation;
[0026] The dynamic runtime library calls the corresponding components in the component application according to the task content and trigger information;
[0027] The component application configures the corresponding components according to the execution framework of the task operation, compiles the components into plug-ins, and loads the plug-ins after each application process is started.
[0028] As a further description of the above technical solution: the framework library includes a first interface layer and an implementation layer;
[0029] The first interface layer comprises:
[0030] The framework interface module encapsulates the task content and provides calling interfaces for initialization, task start, and task end;
[0031] The component running module calls the corresponding component application according to the task content or trigger information;
[0032] The implementation layer includes:
[0033] The framework implementation module parses the task description file to determine the task content, determine the task operation process, and generate the configuration file and execution framework;
[0034] The task creation module saves the task creation method. After the application process is started and the task content is read, the corresponding task creation method is found and the task execution framework is created;
[0035] The task running module runs the task according to the task content or trigger information of the task creation module. As a further description of the above technical solution: the dynamic runtime library includes a second interface layer, an architecture middle layer and a base layer;
[0036] The second interface layer comprises:
[0037] The plug-in module calls, loads, unloads and manages the plug-ins compiled by the component;
[0038] Component base class module, providing calling interface for framework library and components;
[0039] The task base class module provides a base for the tasks in the framework library and is managed by the task management module;
[0040] The timer management module provides a timer interface for the application process and manages the timer tasks of each application process;
[0041] The middle layer of the architecture includes:
[0042] Interface module, setting communication mode and message reading method;
[0043] The trigger module sets the trigger strategy and selects to call the corresponding component application according to the task content and the received trigger information;
[0044] The task management module manages the triggering and task status of each task and sends the task to the corresponding thread pool for execution;
[0045] The timer module detects whether there is a timed-out task within the time interval, or whether there are multiple tasks at the same time, generates a timer task corresponding to the task, and sends the timer task to the base layer;
[0046] The base layer includes:
[0047] The thread pool executes the tasks sent by the task management module or sends them to the coroutine pool according to the received timer tasks;
[0048] Time wheel, set the time interval, and schedule and call the task within the time interval;
[0049] The coroutine pool sets the number of coroutines according to the tasks sent by the timer module and the thread pool, and executes the tasks.
[0050] It also includes a computer-readable storage medium storing a computer program for running the scheduling method, wherein the computer program enables a computer to execute the scheduling method as described in any one of the above technical solutions.
[0051] Also included is an electronic device, comprising:
[0052] one or more processors; memory; and
[0053] One or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the programs include a method for executing a scheduling method as described in any one of the above technical solutions.
[0054] The above technical solution has the following advantages or beneficial effects:
[0055] 1. Task control is more reasonable. Process tasks are uniformly controlled by the task management module and processed in the thread pool, which avoids the problem of applications randomly opening threads to execute tasks, and the task status can be monitored and reported in real time.
[0056] 2. Low coupling. Multiple tasks of the application are scheduled to the dynamic runtime library during execution, which reduces the impact of changes and reduces the size of the code file. In addition, the introduction of component application plug-ins makes it easier to change different algorithms and improves debugging efficiency.
[0057] 3. After the dispatching system designed by this application is connected to the AP system, the message receiving can be connected to the mainstream communication mode in the market, using the two modes of reading the latest and reading the buffer. In addition, multiple task triggering modes also provide more choices for application development in various scenarios, and the provision of tools such as timers can also provide more convenience for application development. BRIEF DESCRIPTION OF THE DRAWINGS
[0058] Figure 1 The process of the scheduling method proposed by the present invention is Figure 1 ;
[0059] Figure 2 The process of the scheduling method proposed by the present invention is Figure 2 ;
[0060] Figure 3 A schematic diagram of the structure of the scheduling system proposed by the present invention;
[0061] Figure 4 It is a schematic diagram of the structure of the framework library in the present invention;
[0062] Figure 5 It is a schematic diagram of the structure of the dynamic runtime library in the present invention.
[0063] Legend:
[0064] 1. Application process; 2. Framework library; 21. First interface layer; 211. Framework interface module; 212. Component running module; 22. Implementation layer; 221. Framework implementation module; 222. Task creation module; 223. Task running module; 3. Dynamic runtime library; 31. Second interface layer; 311. Plug-in module; 312. Component base class module; 313. Task base class module; 314. Timer management module; 32. Architecture middle layer; 321. Interface module; 322. Trigger module; 323. Task management module; 324. Timer module; 33. Base layer; 331. Thread pool; 332. Time wheel; 333. Coroutine pool; 4. Component application. DETAILED DESCRIPTION
[0065] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0066] The applicant found in the research that the traditional AUTOSAR AP middleware for application development has many configuration options and is difficult to get started. If an application wants to achieve specific functions, in addition to paying attention to its own algorithms, it also needs to pay attention to various irrelevant functions such as the program life cycle, service discovery process, and cumbersome message receiving and sending interfaces. In addition, the degree of coupling between the application and the middleware is high, and some plug-ins cannot be freely replaced, which will bring great difficulties in the debugging and development stage.
[0067] Therefore, based on the AP system framework, this application provides a task scheduling system for applications to facilitate their development, so that applications only need to complete the simple process of receiving messages, processing messages, and sending messages, without paying attention to any other AUTOSAR AP features. At the same time, the scheduling system also provides components such as timers and thread pools to help applications develop more conveniently.
[0068] Reference Figure 1 , an embodiment of the present invention provides: a task scheduling method for an application system, comprising:
[0069] S1: Identify the message information of the task description file, obtain the configuration file and task; start the application process and write the configuration file; initialize the framework library, dynamic runtime library and component application; based on the configuration file, the framework library creates a task execution framework; based on the task, load the framework library and component application;
[0070] In the present embodiment, the task description file usually adopts a specific format to organize the message information therein, and the common format may be XML (Extensible Markup Language), JSON (JavaScript, Object Notation), etc. The application needs to use the corresponding parsing library or tool to read and parse the task description file. For files in XML format, DOM (Document Object Model) parser or SAX (Simple XML Application Programming Interface) parser, etc. can be used; for files in JSON format, most programming languages provide built-in JSON parsing functions. These formats can clearly represent the structure and hierarchical relationship of data, which is convenient for computer programs to parse and process. The present application adopts prototxt files, and the system uses tools to draw DAG block diagrams and generate task description files. The task description files are identified and parsed by message code generation tools to obtain the message information of each component in the framework library 2.
[0071] When application process 1 starts, it calls the init interface of framework library 2 for initialization and passes in the path of the configuration file to initialize framework library 2. Framework library 2 is the foundation of the entire application architecture. It provides a series of functional modules, interfaces and specifications to support the development and operation of applications. When initializing framework library 2, it is usually necessary to load related configuration files, set some global parameters and variables, and initialize some core functional modules.
[0072] During the initialization of framework library 2, first read the content in the topic list to obtain the correspondence between topic name and topic id. Topic list is a header file. Each message in the vector parsing tool will have a corresponding ID, which is parsed from the arxml file by the message code generation tool. The content is a mapping table of all message names and message IDs contained in this application process 1. Its function is to register the messages that need to be processed within the program by ID classification, which is more efficient than using string classification marking.
[0073] Read the content of the configuration file, create tasks and trigger instances through the task creation method in the task creation module 222, and the dynamic runtime library 3 creates the "reader" and "writer" read-write objects of the com interface;
[0074] The dynamic runtime library 3 loads the plug-in corresponding to the component application 4, obtains the task content rewritten by the application process, and completes the initialization.
[0075] S2: The dynamic runtime library sets the task execution time, executes the task, and the trigger module detects whether the trigger information is received. If yes, the trigger strategy is determined and the plug-in in the component application is called.
[0076] In this embodiment, the application process 1 starts running, the framework library 2 establishes a task execution framework, the dynamic runtime library 3 starts the timer and the thread pool, sets the task execution time through the timer, and executes the task through the thread pool 331.
[0077] The task is triggered by a timer or by receiving message information, the triggering strategy for task execution is determined, the plug-in in the component application 4 is called, the triggered task is executed through the thread pool 331 or the coroutine pool 333, and the task is scheduled.
[0078] Once the task is created and the relevant framework library 2, dynamic runtime library 3 and component application 4 are loaded, the task can be executed. The execution of a task usually involves processing the input data according to the predetermined logic and steps to achieve the goals set in the task description file. For example, if the task is to sort a set of data, then the process of executing the task may be to call the corresponding sorting algorithm to sort the data.
[0079] The dynamic runtime library 3 can control the task execution time during the task execution process. It can set the task execution start time and execution time limit according to the nature of the task, system resource conditions and other related factors.
[0080] Trigger information usually comes from other parts of the system, external devices or user operations. In order to detect whether the trigger information is received, a corresponding detection mechanism needs to be set up in the application. The trigger strategy refers to determining what specific action plan should be taken to respond to the trigger information based on the received trigger information. The formulation of the trigger strategy usually needs to consider factors such as the type of trigger information, the execution status of the current task, the system resource situation, and the overall goal of the application.
[0081] Plug-ins are extensible functional modules in component applications 4. They can be dynamically inserted into applications to implement specific functions according to different requirements and application scenarios. Plug-ins usually have relatively independent functional logic and interfaces, which facilitate integration with component applications 4.
[0082] The task scheduling method of the present application makes the execution of tasks more reasonably controlled. The process tasks are uniformly controlled by the task management module and processed in the thread pool, avoiding the problem of the application randomly opening threads to execute tasks, and the task status can be monitored and reported in real time.
[0083] The message information of identifying the task description file includes: the framework library receives and parses the task description file, obtains the configuration file, parses the configuration file, generates the task content, and determines the corresponding component application according to the task content.
[0084] In this embodiment, the prototxt file is parsed by a generation tool (generated by writing Python) to generate a json configuration file and the code of each component in the framework library 2. The arxml file of the AP system is configured (configured by vector's supporting visualization tool, including process configuration, message type, etc.), mainly the message name and message type used by each task. The message code generation tool parses the configured arxml file and generates a message header file of the datatype.h type. The generation tool includes vector's arxml configuration tool, which generates arxml files through a visualization interface configuration; vector's code generation tool, which parses arxml files to generate header files of message types; prototxt generation tool, which generates prototxt files through DAG diagrams; framework generation tool, which outputs the code of the framework library and the JSON runtime configuration file according to the prototxt file. The configuration file can be directly deployed to the task scheduling system. The generated code of each component in the framework library 2 needs to be provided to the external development environment, which compiles it into a plug-in after completing the actual function, sends it to the dynamic runtime library 3, and deploys it to the task scheduling system.
[0085] The execution framework of a framework library refers to a set of infrastructure built to perform specific tasks. It includes a series of modules, functions, classes, and their organization and calling relationships, as well as related process control logic. Generating an execution framework usually needs to be based on the type and complexity of the task and the system structure that the framework library is adapted to.
[0086] The framework library creates a task execution framework including:
[0087] The framework library reads the content of the configuration file, creates a task in the task creation module and / or sets an instance of the trigger judgment in the trigger module;
[0088] The dynamic runtime library establishes the read-write objects of the interface, loads the plug-in of the component application, and obtains the task content rewritten by the application process.
[0089] In this embodiment, in the framework library, a task instance represents a specific task to be performed, which contains various parameters, methods, and execution flow information required to perform the task. By creating a task instance, the abstract task description can be converted into an object that can be actually operated and executed, which is used to determine under what conditions a specific task or operation should be triggered. It will decide whether to trigger the corresponding task based on pre-set rules and the current system status (such as received message information, relevant settings in the configuration file, etc.).
[0090] The read and write objects of the interface are used for data exchange between the dynamic runtime library 3 and other components (such as component application 4, framework library 2, etc.). Through these read and write objects, the interface can be easily read and written to realize functions such as data transmission, acquisition or update.
[0091] The plug-in of the component application 4 can extend the function of the application. Loading the plug-in can enable the application process 1 to obtain additional functional modules during operation to meet different task requirements or adapt to different application scenarios.
[0092] The application process 1 may rewrite the original task content according to its own running state, user needs or other factors. The rewritten task content may change in task parameters, execution order, goals, etc. to better adapt to the specific situation.
[0093] Executing a task includes: starting a timer and running the task, generating a timer task corresponding to the task, setting the execution time of the task, determining whether the task is executed within the time interval, if not, sending a trigger message, if yes, after the task is executed, the application process sends an exit signal to the framework library, dynamic runtime library and component application to exit execution.
[0094] In this embodiment, the timer can trigger the corresponding operation according to a preset time interval or a specific time. By starting the timer, it can be ensured that the task starts to be executed at a suitable time point, and the execution time of the task can be monitored and controlled.
[0095] In order to ensure that the task can be completed within the set time interval as expected, it is necessary to monitor the execution of the task. If the task fails to execute within the specified time interval, it may affect the arrangement of subsequent tasks or the operating efficiency of the entire system. Therefore, it is necessary to take appropriate measures in time, such as sending trigger information for subsequent processing. After starting the timer to execute the task, the relationship between the current time and the set execution time is monitored through a cyclic time interval. If the task is not executed within the time interval when the task should be executed (judged by checking whether the task execution function is called), a trigger message is sent.
[0096] The trigger information usually contains some information related to the task not being executed as expected, such as the task name, the reason for not executing, the current system status, etc. The purpose of sending the trigger information is to let other related components (such as the framework library 2, component application 4, etc.) know that there is a problem with the task execution so that they can take appropriate measures to deal with it.
[0097] When the task is completed, the application process 1 sends an exit signal to inform other related components (framework library 2, dynamic runtime library 3, component application 4) that the task has ended and can perform corresponding cleanup work (such as releasing resources, closing related connections, etc.) or continue to execute subsequent tasks. The component that receives the exit signal will process the signal according to its own logic to ensure the normal operation of the system.
[0098] Reference Figure 2 , detecting whether the trigger information is received includes:
[0099] S21: If yes, determine the trigger type as the task is not executed within the time interval,
[0100] Or, the task is set with at least two in the time interval;
[0101] S22: Determine a trigger strategy according to the trigger type, and determine the trigger strategy to be timer trigger, single message trigger, multi-message asynchronous trigger, or multi-message synchronous trigger;
[0102] S23: If no, continue to execute the task.
[0103] In this embodiment, the task is not executed within the time interval: when the trigger information is detected, it is first necessary to determine whether it is triggered because the task is not executed as expected within the set time interval. This may be because the execution time set by the timer has arrived, but the task has not been started or completed due to some reasons (such as insufficient resources, program errors, etc.).
[0104] There are at least two tasks set in a time interval: In the same time interval, for the same application process, multiple different conditions or operation tasks may be set, which may become the source of trigger information. For example, in a data processing process, data backup and data verification may be required in a specific time interval. When any one or more of these conditions are met, trigger information will be generated.
[0105] Trigger strategies include timer trigger, single message trigger, multi-message asynchronous trigger or multi-message synchronous trigger; timer trigger means to trigger a single or multiple execution of a task according to the configuration of the timer. Single message trigger means that a task is triggered after receiving a specific message. Multi-message asynchronous trigger means that any one of multiple messages can trigger the task. Multi-message synchronous trigger means that after a main message is triggered, if other messages arrive within a certain period of time, the task is triggered, otherwise the task is triggered after waiting for timeout. Rich task trigger strategies can meet a variety of application scenarios.
[0106] When it is detected that no trigger information is received, the task continues to execute as originally planned.
[0107] Reference Figure 3 , and also includes an embodiment of a task scheduling system for an automotive software application, the scheduling system being applicable to the scheduling method of any one of the above technical solutions, including:
[0108] Application process 1 controls the start and stop of the application and calls the task content of framework library 2 when it starts;
[0109] Framework library 2, reads configuration files and task contents, and establishes an execution framework for task operation;
[0110] The dynamic runtime library 3 calls the corresponding component in the component application 4 according to the task content and the trigger information;
[0111] The component application 4 configures the corresponding components according to the execution framework of the task operation, compiles the components into plug-ins, and loads the plug-ins after each application process 1 is started.
[0112] In this embodiment, the application process 1 (AP EXE) provides process start and stop control, signal capture processing, service discovery mechanism, bottom cross-device and cross-process communication interface, etc., and has two main functions in the task scheduling system. One is to start and stop the application process, and call the API interface of the framework library 2 during the startup process to complete the start and stop of the task scheduling system. The second is to provide a communication interface ara::com, and the actual message sending and receiving of the task scheduling system is still based on ara::com. The framework library 2 (framework) will read the dynamic configuration file, combine various components to build a complete task execution framework, and the dynamic runtime library 3 (frrt, Framework Run Time) provides various basic components, including timers, plug-in loaders, task and component base classes, thread pools, coroutine pools, etc. The component application 4 (componentApp) is loaded from the basic components in the framework library 2, and provides a framework for running plug-in functions. Each application task is set with a corresponding component. The component will be compiled into a plug-in separately in the task scheduling system, and the corresponding plug-in can be written and loaded according to actual needs. After each application process 1 is started, these plug-ins will be loaded and the application rewrite method will be called.
[0113] Reference Figure 4 The framework library 2 includes a first interface layer 21 and an implementation layer 22; the first interface layer 21 is an AP interface layer (API), which provides an API interface for the top-level AP system and component application 4, and the implementation layer 22 is used to implement specific task operation and scheduling processes.
[0114] The first interface layer 21 includes:
[0115] The framework interface module 211 encapsulates the task content and provides a calling interface for initialization, task start, and task end;
[0116] Specifically, it is used to encapsulate specific tasks and provide API interfaces such as initialization, task start, and task end for the outermost application process 1 to call and control the life cycle of the task. In fact, it encapsulates the internal detailed implementation through the implementation detail mode (Impl mode) and only exposes the necessary interfaces to the outside.
[0117] The component running module 212 calls the corresponding component application 4 according to the task content or trigger information;
[0118] Specifically, the data of the base layer 33 of the dynamic runtime library 3 is loaded, some functional interfaces of the COM interface are provided, and the base is loaded and registered as a plug-in of the component application 4. When the dynamic runtime library 3 is called internally, its subclass component is actually called.
[0119] The implementation layer 22 includes:
[0120] The framework implementation module 221 parses the task description file to determine the task content, determines the task operation process, and generates a configuration file and an execution framework;
[0121] Specifically, it is used for specific task implementation, including reading the configuration files of the application process 1 and the log, initializing the components of each dynamic runtime library 3, loading application components, starting and stopping timers and thread pool threads, etc. Its main function is to connect the specific internal implementations of various components and external frameworks in series.
[0122] The task creation module 222 saves the task creation method, finds the corresponding task creation method after the application process is started and reads the task content, and creates a task execution framework;
[0123] Specifically, in order to implement software deployment, only one framework library 2 file is required in the task scheduling system, so all task creation methods need to be stored in the task creation module 222. After an application process 1 is started and reads relevant message information from the configuration file, it will find the corresponding task creation method from this component, and then create the specified task running function. Using this method, the application only needs to focus on its own plug-in and component application 4, without paying attention to other components.
[0124] The task running module 223 runs the task according to the task content or trigger information of the task creating module 222;
[0125] Specifically, the specific task content is realized, including sending and receiving project data, running the functional functions in the application, etc. Each task corresponds to a task running module 223, and each task running module 223 corresponds to a component running module. The running function in the component application 4 is actually executed in the corresponding task running module 223.
[0126] Reference Figure 5 , the dynamic runtime library 3 includes a second interface layer 31, an architecture middle layer 32 and a base layer 33;
[0127] Specifically, the second interface layer 31 is the outermost interface layer, and its main function is to provide an API to facilitate the framework library 2 and plug-in calls. The architecture middle layer 32 is mainly used to implement specific task triggering, task scheduling, and various communication methods. The base layer 33 sets the components required for task operation to implement the corresponding functions.
[0128] The second interface layer 31 includes:
[0129] The plug-in module 311 calls, loads, unloads and manages the plug-ins compiled by the component;
[0130] Specifically, it is responsible for operations such as loading, unloading, querying and calling of plug-ins. It may also provide plug-in lifecycle management functions, such as plug-in initialization and cleanup. Using the plug-in module 311, it is convenient to register a subclass of a component into the abstract class interface. After the application is started, the corresponding plug-in will be dynamically loaded according to the configuration or demand. Once the plug-in is loaded, the application can call the functions provided by the plug-in through the interface, which increases the flexibility and scalability of the system.
[0131] The component base class module 312 provides a calling interface for the framework library 2 and components;
[0132] Specifically, an abstract class interface is provided for the framework interface module 211 and the component application 4. The component application 4 needs to load the component base class module 312 and rewrite its virtual interface, and register itself and its inherited base layer 33 through the plug-in module 311, thereby realizing a complete plug-in management mechanism.
[0133] The task base class module 313 provides a base layer 33 for tasks in the framework library 2 and is managed by the task management module 323;
[0134] Specifically, the base layer 33 is provided for the tasks in the framework interface module 211 and is managed by the task management module 323. The specific tasks in the component application 4 need to load the task base class module 313 and rewrite its virtual interface.
[0135] The timer management module 314 provides a timer interface for the application process 1 and manages the timer tasks of each application process 1;
[0136] Specifically, a timer interface is provided for the application to manage the timer tasks of each application. Each time an application user creates a timer instance, the timer management module 314 automatically assigns an ID to the user. The user can set the callback function, set the timeout time, start and stop the timer, etc. according to the ID, which facilitates the application to manage various timer tasks.
[0137] The architecture middle layer 32 includes:
[0138] Interface module 321, setting communication mode and message reading method;
[0139] Specifically, the interface module 321 provides two communication modes: publish-subscribe mode and request-response mode. The interface module 321 is a special encapsulation of the AP's COM interface. In addition to the original functions, reading messages can be implemented in two ways, namely, reading the latest message and reading the cached message. While reducing the difficulty of development, more message processing strategies are provided.
[0140] The trigger module 322 sets the trigger strategy and selects to call the corresponding component application according to the task content and the received trigger information;
[0141] Specifically, the trigger module 322 provides four strategies for triggering tasks, namely timer triggering, single message triggering, multi-message asynchronous triggering, and multi-message synchronous triggering. The timer triggering mode is to trigger a single or multiple execution of a task according to the configuration of the timer. Single message triggering means that a task is triggered after receiving a specific message. Multi-message asynchronous triggering means that any one of multiple messages can trigger the task. Multi-message synchronous triggering means that after a main message is triggered, if other messages arrive within a certain period of time, the task is triggered, otherwise the task is triggered after waiting for timeout. Rich task triggering strategies can meet a variety of application scenarios.
[0142] The task management module 323 manages the triggering and task status of each task and sends the task to the corresponding thread pool 331 for execution;
[0143] Specifically, the task management module 323 is a singleton implementation that manages the triggering and task status of each task. When the framework library 2 creates a task execution framework according to the configuration file, it will associate the task id and the specific task content with the task management module 323 and register them with different trigger modules 322. With the invocation of various triggering methods, the task management module 323 will send a specific task to the thread pool 331 for execution according to the task id.
[0144] The timer module 324 detects whether there is a timed-out task within the time interval, or whether there are multiple tasks at the same time, generates a timer task corresponding to the task, and sends the timer task to the base layer 33;
[0145] Specifically, it is internally divided into two categories: task class and application class, which avoids mutual blocking between timers. Each category of timer contains two thread pools 331. One thread pool 331 runs the time wheel 332, and will periodically detect whether there is a timeout task in the slot of the time wheel 332 that needs to be processed. If there is, the task will be sent to another thread pool 331; the other thread pool 331 is specifically used to process these timed tasks. The thread pool 331 also introduces the coroutine pool 333. If there are multiple tasks that need to be processed in parallel at the same time, the task thread will send these tasks to the coroutine pool 333. Because the current scenario where the timer needs to process a large number of tasks is only the sending and receiving tasks of the I / O port, using the coroutine pool 333 can save more resources than opening multiple thread pools 331, while improving the task processing speed.
[0146] Base layer 33 includes:
[0147] The thread pool 331 executes the task sent by the receiving task management module 323 or sends it to the coroutine pool 333 according to the received timer task;
[0148] Specifically, the thread pool 331 is managed by the task management module 323, created and called by the task management module 323, and the task will be sent to the thread pool 331 for execution after being triggered, which is the actual running position of the task. The number of threads in the thread pool 331 and the length of the waiting queue can be initialized according to the configuration. The tasks in the process can be set with different priorities, and the value calculated by the triggering task time + priority coefficient together determines the position of the task in the waiting queue. This algorithm can ensure that when multiple tasks are triggered and waiting in the queue, tasks with high priority and long waiting time can be executed first.
[0149] The time wheel 332 sets the time interval and schedules and calls the tasks within the time interval;
[0150] Specifically, the time wheel 332 is an efficient timed task scheduling algorithm, which manages timed tasks through a cyclic, hierarchical time wheel structure. It consists of multiple "slots", each slot represents a time interval. The time wheel moves forward at a fixed speed. When the time wheel rotates to a slot, it checks whether there are timed tasks in the slot that have expired. If so, these tasks are executed. The time wheel 332 used in this system is divided into a main wheel and an auxiliary wheel. The main wheel has 512 slots and the auxiliary wheel has 64 slots. Each slot differs by 1ms, so the range of the timer is between 1 and 512*64ms.
[0151] The coroutine pool 333 sets the number of coroutines according to the tasks sent by the timer module 324 and the thread pool 331, and executes the tasks.
[0152] Specifically, the coroutine pool 333 is the actual execution body of the timer task. The number of its coroutines can be specified, and by reusing the created coroutines, there is no need to frequently create and destroy coroutines, thereby improving resource utilization.
[0153] It is understandable that the scheduling system provided in the embodiment of the present invention corresponds to the above-mentioned scheduling method, and the explanations, examples, beneficial effects and other parts of its relevant contents can refer to the corresponding contents in the scheduling method, which will not be repeated here.
[0154] Also included is a computer-readable storage medium storing a computer program for running the scheduling method, wherein the computer program causes a computer to execute the following steps:
[0155] S1: Identify the message information of the task description file, obtain the configuration file and task; start the application process and write the configuration file; initialize the framework library, dynamic runtime library and component application; based on the configuration file, the framework library creates a task execution framework; based on the task, load the framework library and component application;
[0156] S2: The dynamic runtime library sets the task execution time, executes the task, and the trigger module detects whether the trigger information is received. If yes, the trigger strategy is determined and the plug-in in the component application is called.
[0157] Among them, the computer-readable storage medium can be a computer storage medium or a communication medium. The communication medium includes any medium that facilitates the transmission of a computer program from one place to another. The computer storage medium can be any available medium that can be accessed by a general-purpose or special-purpose computer. For example, a computer-readable storage medium is coupled to a processor so that the processor can read information from the computer-readable storage medium and write information to the computer-readable storage medium. Of course, the computer-readable storage medium can also be a component of the processor. The processor and the computer-readable storage medium can be located in an application-specific integrated circuit (ASIC). In addition, the ASIC can be located in a user device. Of course, the processor and the computer-readable storage medium can also exist in a communication device as discrete components.
[0158] Specifically, the computer-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0159] Also included is an electronic device, comprising:
[0160] one or more processors; memory; and
[0161] One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by one or more processors, the programs comprising steps for performing the following steps:
[0162] S1: Identify the message information of the task description file, obtain the configuration file and task; start the application process and write the configuration file; initialize the framework library, dynamic runtime library and component application; based on the configuration file, the framework library creates a task execution framework; based on the task, load the framework library and component application;
[0163] S2: The dynamic runtime library sets the task execution time, executes the task, and the trigger module detects whether the trigger information is received. If yes, the trigger strategy is determined and the plug-in in the component application is called.
[0164] Memory is used to store computer programs. The memory may include high-speed random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a disk or an optical disk.
[0165] A processor is used to execute a computer program stored in a memory to implement the scheduling method in the above embodiment. The processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor can be a microprocessor or the processor can be any conventional processor, etc. The steps of the method disclosed in the invention can be directly embodied as being executed by a hardware processor, or can be executed by a combination of hardware and software modules in the processor.
[0166] Optionally, the memory can be independent or integrated with the processor.
[0167] When the memory is a device independent of the processor, the electronic device may further include a bus. The bus is used to connect the memory and the processor. The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, and the like.
[0168] It should be noted that, through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiment. In this article, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the term "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements that are not explicitly listed, or also includes elements inherent to such process, method, article or device. Without more constraints, an element defined by the phrase "comprising a..." does not exclude the existence of other identical elements in the process, method, article or apparatus comprising the element.
[0169] Finally, it should be noted that the above is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, it is still possible for those skilled in the art to modify the technical solutions described in the aforementioned embodiments or to make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A task scheduling method for an application system, characterized in that: include: Identify the message information of the task description file and obtain the configuration file and task; The application process is started and the configuration file is written; Initialize the framework library, dynamic runtime library and component applications; Based on the configuration file, the framework library creates a task execution framework; Based on the task, loading the framework library and component application; The dynamic runtime library sets the task execution time and executes the task. The trigger module detects whether the trigger information is received. If yes, the trigger strategy is determined and the plug-in in the component application is called.
2. The scheduling method according to claim 1, characterized in that: The message information of identifying the task description file includes: the framework library receives and parses the task description file, obtains the configuration file, parses the configuration file, generates the task content, and determines the corresponding component application according to the task content.
3. The scheduling method according to claim 1, characterized in that: The framework library creates a task execution framework including: The framework library reads the content of the configuration file, creates a task in the task creation module and / or sets an instance of trigger judgment in the trigger module; The dynamic runtime library establishes a read-write object of the interface, loads the plug-in of the component application, and obtains the task content rewritten by the application process.
4. The scheduling method according to claim 1, characterized in that: The task execution includes: starting the timer and running the task, generating a timer task corresponding to the task, setting the task execution time, determining whether the task is executed within the time interval, if not, sending a trigger message, if yes, after the task execution is completed, the application process sends an exit signal to the framework library, dynamic runtime library and component application to exit execution.
5. The scheduling method according to claim 1, characterized in that: The trigger module detects whether the trigger information is received, including: If yes, the trigger type is determined to be that the task is not executed within the time interval. Or, the tasks are set to have at least two in the time interval; Determine a trigger strategy according to the trigger type, and determine the trigger strategy to be timer trigger, single message trigger, multi-message asynchronous trigger or multi-message synchronous trigger; If not, continue executing the task.
6. A task scheduling system for automotive software applications, characterized in that: The scheduling system is applicable to the scheduling method described in any one of claims 1 to 5, including: The application process (1) controls the start and stop of the application and calls the task content of the framework library (2) when it starts; Framework library (2), reads configuration files and task contents, and establishes an execution framework for task operation; The dynamic runtime library (3) calls the corresponding component in the component application (4) according to the task content and trigger information; The component application (4) configures the corresponding components according to the execution framework of the task operation, compiles the components into plug-ins, and loads the plug-ins after each application process (1) is started.
7. The dispatching system according to claim 6, characterized in that: The framework library (2) comprises a first interface layer (21) and an implementation layer (22); The first interface layer (21) comprises: The framework interface module (211) encapsulates the task content and provides a calling interface for initialization, task start and task end; The component running module (212) calls the corresponding component application (4) according to the task content or trigger information; The implementation layer (22) comprises: The framework implementation module (221) parses the task description file to determine the task content, determines the task operation process, and generates a configuration file and an execution framework; The task creation module (222) stores the task creation method, and after the application process is started and the task content is read, the corresponding task creation method is found to create a task execution framework; The task running module (223) runs the task according to the task content or trigger information of the task creating module (222).
8. The dispatching system according to claim 6, characterized in that: The dynamic runtime library (3) comprises a second interface layer (31), an architecture middle layer (32) and a base layer (33); The second interface layer (31) comprises: The plug-in module (311) calls, loads, unloads and manages the plug-ins compiled by the component; The component base class module (312) provides a calling interface for the framework library (2) and components; A task base class module (313) provides a base layer (33) for tasks in the framework library (2) and is managed by a task management module (323); A timer management module (314) provides a timer interface for the application process (1) and manages the timer tasks of each application process (1); The architecture middle layer (32) comprises: An interface module (321) is used to set a communication mode and a message reading method; A trigger module (322) sets a trigger strategy and selects to call a corresponding component application according to the task content and the received trigger information; The task management module (323) manages the triggering and task status of each task and sends the task to the corresponding thread pool (331) for execution; The timer module (324) detects whether there is a timed-out task within a time interval, or whether there are multiple tasks at the same time, generates a timer task corresponding to the task, and sends the timer task to the base layer (33); The base layer (33) comprises: The thread pool (331) executes the task sent by the task management module (323) or sends it to the coroutine pool (333) according to the received timer task; The time wheel (332) sets the time interval and schedules and calls the tasks within the time interval; The coroutine pool (333) sets the number of coroutines according to the tasks sent by the timer module (324) and the thread pool (331), and executes the tasks.
9. A computer-readable storage medium, characterized in that: It stores a computer program for running the scheduling method, wherein the computer program enables a computer to execute the scheduling method according to any one of claims 1 to 5.
10. An electronic device, characterized in that: include: one or more processors; Memory; as well as One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the programs comprising instructions for executing the scheduling method according to any one of claims 1 to 5.
Citation Information
Cited By
Application program running method and device and electronic equipment
CN121579180A