CN111752692A - Multi-core task processing method and device under simulation environment - Google Patents

Multi-core task processing method and device under simulation environment Download PDF

Info

Publication number
CN111752692A
CN111752692A CN202010580398.6A CN202010580398A CN111752692A CN 111752692 A CN111752692 A CN 111752692A CN 202010580398 A CN202010580398 A CN 202010580398A CN 111752692 A CN111752692 A CN 111752692A
Authority
CN
China
Prior art keywords
task
tasks
core
periodic
user interface
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010580398.6A
Other languages
Chinese (zh)
Other versions
CN111752692B (en
Inventor
刘旭阳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingwei Hirain Tech Co Ltd
Original Assignee
Beijing Jingwei Hirain Tech Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingwei Hirain Tech Co Ltd filed Critical Beijing Jingwei Hirain Tech Co Ltd
Priority to CN202010580398.6A priority Critical patent/CN111752692B/en
Publication of CN111752692A publication Critical patent/CN111752692A/en
Application granted granted Critical
Publication of CN111752692B publication Critical patent/CN111752692B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/485Task life-cycle, e.g. stopping, restarting, resuming execution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • G06F9/505Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals considering the load
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/545Interprogram communication where tasks reside in different layers, e.g. user- and kernel-space

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention discloses a multi-core task processing method and a device under a simulation environment, wherein the method comprises the following steps: respectively constructing a multi-core user interface and a periodic task user interface which can be used in a target simulation environment, calling the user interfaces in a model file of the target simulation environment to configure tasks, and distributing a plurality of configured periodic tasks to at least two different cores; and for each core, taking the periodic task with the same execution period as an OS task, and configuring a task interface function for each OS task, so that the task interface function in one periodic task is only called once when the OS task runs. In the implementation, tasks with the same period in one core can be combined together, and a task interface function is uniformly configured for the tasks, so that all periodic tasks with the same period can be completed by calling the task interface function once in one execution period, and the condition that the periodic tasks are called repeatedly is avoided.

Description

Multi-core task processing method and device under simulation environment
Technical Field
The invention relates to a simulation processing technology, in particular to a multi-core task processing method and device in a simulation environment.
Background
The current multi-core processor is applied in some simulation environments, generally, configuration of an OS (Operating System) task is completed at an embedded part, when model simulation is performed in a corresponding simulation environment, an OS task module corresponding to the embedded part is directly provided, and the simulation System calls the provided OS task module to execute corresponding functional operations, so that multi-core application in the corresponding simulation environment is realized.
However, in the above implementation, since the configuration of the OS task is fixed in the embedded portion, that is, the software program corresponding to the OS task is fixed and written, and each task corresponds to an independent software code, when a plurality of task modules having the same execution cycle are called in any processing core, the task of the execution cycle may be called repeatedly in one execution cycle, which not only wastes system resources, but also affects the use experience of the user.
Disclosure of Invention
In view of this, the present invention provides a method and an apparatus for processing a multi-core task in a simulation environment, so as to overcome the problem in the prior art that a task is repeatedly called in an execution cycle.
In order to achieve the purpose, the invention provides the following technical scheme:
a multi-core task processing method in a simulation environment comprises the following steps:
respectively constructing user interfaces which can be used by the multi-core task and the periodic task in a target simulation environment to obtain a multi-core user interface and a periodic task user interface;
calling the multi-core user interface and the periodic task user interface in a model file of a target simulation environment to perform task configuration, wherein the task configuration comprises task content of the periodic tasks, and distributing the configured periodic tasks to at least two different cores, and the task content comprises task operation and execution cycles;
counting the execution cycle of the periodic task which needs to be executed by each core of the at least two different cores;
regarding each core, taking a periodic task with the same execution period as an OS task;
and configuring a task interface function for each OS task, and generating corresponding configuration codes, so that the task interface function is called only once in one execution period of each OS task when the OS task is simulated and run.
Optionally, the respectively constructing user interfaces that the multi-core task and the periodic task can use in the target simulation environment to obtain a multi-core user interface and a periodic task user interface includes:
respectively writing system functions of multi-core tasks and periodic tasks by using languages available in a target simulation environment;
and respectively packaging the system functions to obtain a multi-core user interface and a periodic task user interface which can be used in a target simulation environment.
Optionally, after configuring a task interface function for each OS task and generating a corresponding configuration code, the method further includes:
the following operations are performed for each OS task:
simulating and running the OS task;
determining whether the operation running time of the OS task is larger than the execution period of the OS task based on the simulation running result;
in the case of a greater than, some of the OS tasks are assigned to other OS tasks of the current core.
Optionally, the allocating part of the tasks of the OS task to other tasks of the current core includes:
newly establishing an OS task as an extended OS task in a current core, wherein the execution period of the extended OS task is the same as that of the OS task;
and distributing part of the OS tasks to the extended OS tasks.
Optionally, the allocating a part of the tasks in the OS tasks to the extended OS tasks includes:
and distributing part of the OS tasks to the extended OS tasks based on the execution cycle of the OS tasks and the running time of all the periodic tasks contained in the OS tasks, so that the running time of the distributed OS tasks and the running time of the extended OS tasks are not more than the execution cycle of the OS tasks.
Optionally, the method further includes:
and in the case that the load rate of the current core exceeds a first threshold value, distributing part of OS tasks in the cores with the load rates exceeding the first threshold value to other cores.
Optionally, the allocating, to other cores, part of OS tasks in the cores whose load rates exceed the first threshold includes:
and distributing part of OS tasks in the cores with the load rate exceeding the first threshold value to OS tasks in other cores with the same execution period of the OS tasks or distributing the part of OS tasks to other cores as a single OS task.
A multi-core task processing device in a simulation environment, comprising:
the interface construction module is used for respectively constructing user interfaces which can be used by the multi-core task and the periodic task in a target simulation environment to obtain a multi-core user interface and a periodic task user interface;
the task configuration module is used for calling the multi-core user interface and the periodic task user interface in a model file of a target simulation environment to perform task configuration, wherein the task configuration comprises task content of the periodic tasks, the configured periodic tasks are distributed to at least two different cores, and the task content comprises task operation and execution cycles;
the cycle counting module is used for counting the execution cycle of the cycle task which needs to be executed by each core in the at least two different cores;
the task determination module is used for regarding each core as an OS task, wherein the periodic tasks with the same execution period are used as the OS tasks;
and the calling configuration module is used for configuring a task interface function for each OS task and generating a corresponding configuration code, so that the task interface function is called only once in one execution period of each OS task when the OS task is simulated and run.
Optionally, the interface building module includes:
the function processing module is used for respectively writing system functions of multi-core tasks and periodic tasks by using languages available in the target simulation environment;
and the interface packaging module is used for respectively packaging the system functions to obtain a user interface which can be used by the multi-core and periodic tasks in the target simulation environment.
Optionally, the method further includes:
the task management module is used for carrying out task management on each OS task;
the task management module comprises:
an emulation run module to, for each OS task: simulating and running the OS task;
a time determination module for determining whether the operation running time of the OS task is greater than the execution cycle thereof based on the simulation running result of the simulation running module;
and the task allocation module is used for allocating part of tasks of the OS task to other OS tasks of the current core under the condition that the determination result of the time determination module is positive.
As can be seen from the foregoing technical solutions, compared with the prior art, an embodiment of the present invention discloses a method and an apparatus for processing a multi-core task in a simulation environment, where the method includes: the method comprises the steps of respectively constructing a multi-core user interface and a periodic task user interface which can be used in a target simulation environment, calling the multi-core user interface and the periodic task user interface in a model file of the target simulation environment to carry out task configuration, distributing a plurality of configured periodic tasks to at least two different cores, counting the execution period of the periodic task which needs to be executed by each core in the at least two different cores, regarding each core, taking the periodic task with the same execution period as an OS task, configuring a task interface function for each OS task, and generating a corresponding configuration code, so that when the configuration code is operated, the task interface function of each OS task in one execution period is called only once. In the implementation, the configuration of the OS task is performed in the target simulation environment, the tasks with the same period in one core can be merged together, and a task interface function is uniformly configured for the tasks, so that all the periodic tasks with the same period can be completed by calling the task interface function once in one execution period, the situation that the periodic tasks are repeatedly called is avoided, the system resources are saved, and the use experience of a user can be improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a flowchart of a multi-core task processing method in a Simulink environment disclosed in an embodiment of the present invention;
FIG. 2 is a flowchart of a user interface for constructing S-function modules of multi-core and periodic tasks according to an embodiment of the present invention;
FIG. 3 is a flowchart of another method for processing a multi-core task in a Simulink environment according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a multi-core task processing device in a Simulink environment according to an embodiment of the present invention;
FIG. 5 is a schematic structural diagram of an interface building module according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of another multi-core task processing device in a Simulink environment disclosed in the embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The invention provides a multi-core task processing method and device in a simulation environment, and aims to solve the problem that a task is repeatedly called in an execution cycle in the prior art. The multi-core task processing method and device in the simulation environment under the technical concept of the present invention are described in detail below by taking Simulink (corresponding to a target simulation environment) as an example. Certainly, the technical concept of the present invention is not limited to be implemented in a Simulink simulation environment in practical applications, and other known and future developed simulation environments can utilize the multi-core task processing method and apparatus in the technical concept of the present invention to overcome the problem that a task is repeatedly called in an execution cycle in the prior art.
For the sake of reference and clarity, the descriptions, abbreviations or abbreviations of the technical terms used hereinafter are summarized as follows:
simulink: simulink is a visual simulation tool in MATLAB, is a block diagram design environment based on MATLAB, is a software package for realizing dynamic system modeling, simulation and analysis, and is widely applied to modeling and simulation of linear systems, nonlinear systems, digital control and digital signal processing.
S-function: the S-Function is a short term for a System Function, and refers to a functional block described in a non-graphical manner (i.e., a computer language, different from a System module of Simulink). In addition to MATLAB, users can also write implementations in other languages (e.g., C/C + +/FORTRAN, etc.).
Fig. 1 is a flowchart of a multi-core task processing method in a Simulink environment disclosed in an embodiment of the present invention, and referring to fig. 1, the multi-core task processing method in the Simulink environment may include:
step 101: and respectively constructing user interfaces which can be used by the multi-core task and the periodic task in the Simulink environment to obtain the multi-core user interface and the periodic task user interface.
Since the multi-core and periodic tasks cannot be directly used in the Simulink environment, it is necessary to first construct user interfaces for the multi-core and periodic tasks so that the two can be used in the Simulink environment. In practical application, the system functions of the multi-core and periodic tasks, namely the S-functions of the multi-core and periodic tasks, can be constructed first, and then the constructed system functions are encapsulated to generate corresponding user interfaces, which is convenient for users to call directly.
Step 102: and calling the multi-core user interface and the periodic task user interface in a model file of Simulink to perform task configuration, wherein the task configuration comprises the task content of the periodic task, and the configured periodic tasks are distributed to at least two different cores, and the task content comprises the task operation and execution period.
The constructed multi-core user interface and periodic task user interface can be normally used in a Simulink environment, a user can construct a multi-core and periodic task relationship in a model file of the Simulink environment, and the execution cycles of all periodic tasks needing to be executed in the multi-core are configured in real time according to actual requirements.
The execution periods of tasks in different periods can be the same or different, for example, the period of sending a sensor signal by a first type of sensor in an automobile is 10 ms; the second type of sensor detects the electric quantity, and the period of the door and window state is 1 s. In addition, different cores may include periodic tasks with the same execution cycle, or may not have periodic tasks with the same execution cycle, and these may be determined according to the task allocation condition of each core and the execution cycles of the tasks in different cycles. If the tasks with the same execution cycle are distributed to the same core as much as possible, the tasks in each core are configured according to the processing capacity and the task distribution condition of the core.
In this embodiment, some parameters (such as an execution period) of the periodic task are not directly fixed and written in embedded software, but can be configured in real time in a Simulink environment, so that the manageability and the expandability of each periodic task are greatly improved, and great convenience is brought to users.
Step 103: and counting the execution cycle of the periodic task which needs to be executed by each core of the at least two different cores.
After the execution cycles of the execution cycles are configured, each core can automatically count the execution cycles of the cycle tasks required to be executed by the core through the MATLAB file, so as to provide support data for subsequent processing.
Step 104: for each core, a periodic task in which the execution period is the same is taken as one OS task.
Step 105: and configuring a task interface function for each OS task, and generating corresponding configuration codes, so that the task interface function is called only once in one execution period of each OS task when the OS task is simulated and run.
In one core, periodic tasks in the same period can be merged into one block, a task interface function of an embedded OS is configured for the merged whole, and a configuration code of a corresponding OS task is generated, so that in one execution period of the OS task, the task interface function is called only once, and each periodic task in the merged whole can be executed once. Therefore, for a plurality of periodic tasks with the same execution period, the periodic tasks with the same execution period do not need to be respectively and independently called, the periodic tasks with the same execution period are taken as a whole, the calling triggering is unified, and the repeated calling of the periodic tasks with the same execution period in one execution period is avoided.
In implementation, one or more periodic tasks can be called in any one or more cores through related configuration, and the execution period of all the periodic tasks to be executed is set. And calling an algorithm in each core to count the execution period and the execution frequency of the tasks in the calling period, putting the operations (namely the periodic tasks) executed in the same period into the same OS task, and ensuring that the OS task is called only once in one execution period when generating the configuration code of the corresponding OS task. Specifically, a user does not need to pay attention to how the multi-core OS embedded software is configured in the Simulink environment, and only needs to set the period of the periodic task operation in the built model. In the implementation, each core can automatically count which periodic tasks need to be periodically operated in the built model, and the calculation, classification and adjustment are automatically performed according to the execution period, so that the OS part for generating the embedded software is only generated once and is only called for 1 time.
In the multi-core task processing method in the Simulink environment, the OS task is configured in the Simulink environment, and the tasks with the same period can be combined together to configure a task interface function for the same in a unified manner, so that all periodic tasks with the same period can be completed by calling the task interface function once in an execution period, thereby avoiding a situation that the periodic tasks are called repeatedly, saving system resources, and improving user experience.
Fig. 2 is a flowchart of constructing a multi-core user interface and a periodic task user interface according to an embodiment of the present invention, and as shown in fig. 2, the flowchart may include:
step 201: and respectively writing system functions of multi-core tasks and periodic tasks by using MATLAB language.
Step 202: and respectively packaging the system functions to obtain a multi-core user interface and a periodic task user interface which can be used in the Simulink environment.
In specific implementation, a system function of a multi-core and periodic task can be written by using a self-contained MATLAB language in a Simulink system, so that the multi-core and periodic task can be used in a Simulink environment; and then, a user interface of an S-function module of multi-core and periodic tasks is customized according to requirements by combining the encapsulation function of the Simulink system. It is understood that, if other simulation environments are used, the system functions of the multi-core and periodic tasks are written by using a language friendly to the corresponding simulation environment.
In the realization, the user interface of the S-function module of the multi-core and periodic tasks can be constructed by adopting the self characteristic functions of the Simulink system, and no additional other processing device is needed, so that the user operation is convenient.
Fig. 3 is a flowchart of another method for processing a multi-core task in a Simulink environment disclosed in the embodiment of the present invention, and as shown in fig. 3, the method may include:
step 301: and respectively constructing user interfaces which can be used by the multi-core task and the periodic task in the Simulink environment to obtain the multi-core user interface and the periodic task user interface.
Step 302: and calling the multi-core user interface and the periodic task user interface in a model file of Simulink to perform task configuration, wherein the task configuration comprises the task content of the periodic task, and the configured periodic tasks are distributed to at least two different cores, and the task content comprises the task operation and execution period.
Step 303: and counting the execution cycle of the periodic task which needs to be executed by each core of the at least two different cores.
Step 304: for each core, a periodic task in which the execution period is the same is taken as one OS task.
Step 305: and configuring a task interface function for each OS task, and generating corresponding configuration codes, so that the task interface function is called only once in one execution period of each OS task when the OS task is simulated and run.
Step 306: for each of the OS tasks: and simulating and running the OS task.
In this implementation, the simulation run of the OS task is to obtain the execution time of each OS task, and whether the task amount of each OS task is too large can be determined according to the execution time.
Step 307: and determining whether the operation running time of the OS task is larger than the execution period of the OS task or not based on the simulation running result, and if so, entering step 308.
In the single core, the periodic tasks in the OS tasks are performed in a serial sequential execution mode, so that whether the operation running time of the OS tasks is greater than the execution period of the OS tasks is directly determined; when the operation running time of the OS task is larger than the execution period, the current core cannot complete all periodic tasks in the OS task in time in one execution period, which may cause the execution of the subsequent OS periodic task to be wrong.
For example, in the core 1, the OS task includes 5 periodic tasks, the periods of the 5 periodic tasks are the same and are all 1s, in the simulation process, the first periodic task executes for 0.3s, the second periodic task executes for 0.2s, the 3 rd periodic task executes for 0.4s, the 4 th periodic task executes for 0.2s, and the 5 th periodic task executes for 0.3s, it is obvious that, in the execution period of 1s, the core 1 can only complete 3 periodic tasks, if the 5 periodic tasks are put together to be called and executed in a unified manner, all the tasks need 0.3+0.2+0.4+0.2+0.3 s, which is equivalent to the time for completing one OS task exceeds the execution period of 1s and occupies the time of 0.4s of the next execution period, which may cause the execution period of the OS task to be confused, and the system cannot acquire accurate data, affecting the normal operation of the system.
Step 308: and distributing part of the tasks of the OS to other OS tasks of the current core.
Based on the above, when the operation runtime of a certain OS task is greater than the execution cycle, some tasks of the OS task need to be allocated to other OS tasks of the current core, so as to solve the problem that the execution time of the current OS task exceeds the execution cycle, and ensure accurate execution of the OS task.
The allocating part of the OS tasks to other OS tasks of the current core according to the foregoing embodiment may include: newly establishing an OS task as an extended OS task in a current core, wherein the execution period of the extended OS task is the same as that of the OS task; and distributing part of the OS tasks to the extended OS tasks.
The execution cycles are the same, so as to ensure that the distributed periodic tasks can be executed according to the normal cycle. The allocating a part of the OS tasks to the extended OS tasks may include: and distributing part of the OS tasks to the extended OS tasks based on the execution cycle of the OS tasks and the running time of all the periodic tasks contained in the OS tasks, so that the running time of the distributed OS tasks and the running time of the extended OS tasks are not more than the execution cycle of the OS tasks.
On the basis of the above disclosure, in one implementation, the method for processing a multi-core task in a Simulink environment may further include: and in the case that the load rate of the current core exceeds a first threshold value, distributing part of OS tasks in the cores with the load rates exceeding the first threshold value to other cores. Specifically, the method may include: and distributing part of OS tasks in the cores with the load rate exceeding the first threshold value to OS tasks in other cores with the same execution period of the OS tasks or distributing the part of OS tasks to other cores as a single OS task.
Usually, each period task can be completed in a corresponding period, but the inventor finds in development that: when some simulations are performed, some of the redistributed independent tasks cannot be executed and completed in the corresponding periods because resources needed by part of the periodic tasks are more, or the periods of many periodic tasks are the same. Therefore, when the periodic task allocation is not reasonable, that is, when the execution time of the periodic task among the OS tasks is too short, the periodic task allocation is performed again.
In a specific implementation, after the periodic tasks to be called and the operations to be executed in the tasks are configured in the Simulink model file, a simulation parameter rerun model for acquiring the runtime of each periodic task is set in the model file, whether the operations to be executed in the corresponding OS tasks are reasonable is evaluated according to the obtained runtime of each periodic task, and the operations to be executed in each OS task are distributed if the operations are unreasonable. The specific implementation method comprises the following steps:
1. calling a used multi-core S-function module in the model file, and calling a required OS task in the multi-core S-function module;
2. performing a required operation in the OS task of each core;
3. setting simulation parameters of the model file to obtain the running time of each periodic task, and clicking to run after the setting is finished;
4. the running time of each periodic task and the running load of each core can be obtained according to the running result of the previous step, the operation executed in each OS task (namely the periodic task) can be reasonably distributed according to the running time of each periodic task, and whether the operation executed in each OS task is reasonable or not can be evaluated;
5. under the condition that the judgment is unreasonable, the specific distribution idea of the periodic tasks is as follows: when the running time of all periodic tasks exceeds the running time (namely the execution period) set by the corresponding OS task, the task can be automatically split, the periodic tasks originally running in the same OS task are split into different OS tasks, and the execution periods of the two OS tasks are required to be ensured to be the same. When the load of the core where the OS task is located allows, the OS task is split to other tasks of the same core. And when the load of the core where the OS task is located is too high, the OS task is automatically split into tasks of different cores.
The multi-core task processing method in the Simulink environment enables the operation and execution of multi-core OS tasks to be more flexible, avoids the situation that periodic tasks are repeatedly called, provides the running time of each periodic task as the allocation basis of the operation to be executed in each OS task, and avoids the situation that the operation allocation in the OS tasks is unreasonable. All the work of the embodiment of the invention can be realized on Simulink software, and the embedded OS software does not need to be modified, thereby being convenient for users to use.
It should be noted that: the foregoing method embodiments are only some of the embodiments of the present invention, and other embodiments are also possible in practical applications. For example, when the operation running time of a certain OS task is larger than the execution period of the OS task, part of the OS task is directly distributed to other cores, and the OS task with the same execution period as the OS task is constructed. For another example, when the operation running time of a certain OS task is greater than the execution cycle thereof, before allocating a part of tasks of the OS task to other OS tasks of the current core, it is determined whether the load rate of the current core is too high (exceeds a certain threshold), and when the load rate is too high, the part of OS tasks in the current core is directly allocated to other cores, or the OS task is split, and the split part of tasks is allocated to other cores. For example, when the operation runtime of an OS task is greater than the execution cycle, it is determined whether an OS task having the same execution cycle as the OS task exists in the current core, and if the operation runtime of an OS task having the same execution cycle as the OS task exists and is less than the execution cycle, a part of the tasks of the OS task is allocated to the OS task having the same execution cycle as the OS task.
While, for purposes of simplicity of explanation, the foregoing method embodiments have been described as a series of acts or combination of acts, it will be appreciated by those skilled in the art that the present invention is not limited by the illustrated ordering of acts, as some steps may occur in other orders or concurrently with other steps in accordance with the invention. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required by the invention.
The method is described in detail in the embodiments disclosed in the invention, and the method of the invention can be realized by adopting devices in various forms, so that the invention also discloses corresponding device embodiments, and specific embodiments are given below for detailed description.
Fig. 4 is a schematic structural diagram of a multi-core task processing device in a Simulink environment disclosed in an embodiment of the present invention, and referring to fig. 4, the multi-core task processing device 40 in the Simulink environment may include:
the interface construction module 401 is configured to respectively construct user interfaces that can be used by the multi-core task and the periodic task in the Simulink environment, so as to obtain a multi-core user interface and a periodic task user interface.
A task configuration module 402, configured to invoke the multi-core user interface and the periodic task user interface in a Simulink model file to perform task configuration, where the task configuration includes configuring task content of a periodic task, and allocate the configured multiple periodic tasks to at least two different cores, where the task content includes task operation and execution cycle.
A cycle counting module 403, configured to count an execution cycle of a cycle task that needs to be executed by each core of the at least two different cores.
The task determination module 404 is configured to, for each core, regard a periodic task having the same execution period as one OS task.
A calling configuration module 405, configured to configure a task interface function for each OS task, and generate a corresponding configuration code, so that the task interface function is called only once in an execution cycle of each OS task when the OS task is subsequently simulated and run.
In the multi-core task processing device in the Simulink environment, the OS tasks are configured in the Simulink environment, and the tasks with the same period can be combined together to configure a task interface function for the same in a unified manner, so that all periodic tasks with the same period can be completed by calling the task interface function once in an execution period, the periodic tasks are prevented from being repeatedly called, system resources are saved, and user experience can be improved.
Fig. 5 is a schematic structural diagram of an interface building module disclosed in the embodiment of the present invention, and as shown in fig. 5, the interface building module 401 may include:
and the function processing module 501 is configured to use the MATLAB language to write system functions of multiple cores and periodic tasks, respectively.
An interface encapsulation module 502, configured to encapsulate the system functions respectively, so as to obtain a user interface that can be used by the multi-core and periodic tasks in the Simulink environment.
In the realization, the user interface of the S-function module of the multi-core and periodic tasks can be constructed by adopting the self characteristic functions of the Simulink system, and no additional other processing device is needed, so that the user operation is convenient.
Fig. 6 is a schematic structural diagram of another multi-core task processing device in a Simulink environment disclosed in an embodiment of the present invention, and referring to fig. 6, in addition to the interface construction module 401, the task configuration module 402, the period statistics module 403, the task determination module 404, and the call configuration module 405, the multi-core task processing device 60 in the Simulink environment may further include a task management module 601 for performing task management on each OS task.
Specifically, the task management module 601 may include:
a simulation run module 6011 configured to, for each os task: and simulating and running the OS task.
A time determining module 6012, configured to determine whether an operation running time of the OS task is greater than an execution cycle thereof based on a simulation running result of the simulation running module.
A task allocation module 6013, configured to, if a determination result of the time determination module 6012 is yes, allocate a part of tasks of the OS task to other OS tasks of the current core.
When the operation running time of the OS task is greater than the execution period, part of the OS task needs to be allocated to other OS tasks of the current core, so as to solve the problem that the execution time of the current OS task exceeds the execution period, and ensure accurate execution of the OS task.
In one implementation, the task allocation module 6013 may be specifically configured to: newly establishing an OS task as an extended OS task in a current core, wherein the execution period of the extended OS task is the same as that of the OS task; and distributing part of the OS tasks to the extended OS tasks. Specifically, part of the OS tasks may be allocated to the extended OS tasks based on the execution period of the OS tasks and the runtime of all the periodic tasks included therein, so that the allocated runtime of the OS tasks and the runtime of the extended OS tasks are not greater than the execution period thereof.
In other implementations, the task allocation module 6013 may be further configured to: and in the case that the load rate of the current core exceeds a first threshold value, distributing part of OS tasks in the cores with the load rates exceeding the first threshold value to other cores. The method can be specifically used for: and distributing part of OS tasks in the cores with the load rate exceeding the first threshold value to OS tasks in other cores with the same execution period of the OS tasks or distributing the part of OS tasks to other cores as a single OS task.
The multi-core task processing device in the Simulink environment enables the operation and execution of multi-core OS tasks to be more flexible, avoids the situation that periodic tasks are repeatedly called, provides the running time of each periodic task as the distribution basis of the operation to be executed in each OS task, and avoids the situation that the operation distribution in the OS tasks is unreasonable.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
It is further noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A multi-core task processing method in a simulation environment is characterized by comprising the following steps:
respectively constructing user interfaces which can be used by the multi-core task and the periodic task in a target simulation environment to obtain a multi-core user interface and a periodic task user interface;
calling the multi-core user interface and the periodic task user interface in a model file of a target simulation environment to perform task configuration, wherein the task configuration comprises task content of the periodic tasks, and distributing the configured periodic tasks to at least two different cores, and the task content comprises task operation and execution cycles;
counting the execution cycle of the periodic task which needs to be executed by each core of the at least two different cores;
regarding each core, taking a periodic task with the same execution period as an OS task;
and configuring a task interface function for each OS task, and generating corresponding configuration codes, so that the task interface function is called only once in one execution period of each OS task when the OS task is simulated and run.
2. The method of claim 1, wherein the constructing user interfaces that can be used by the multi-core task and the periodic task in the target simulation environment respectively to obtain a multi-core user interface and a periodic task user interface comprises:
respectively writing system functions of multi-core tasks and periodic tasks by using languages available in a target simulation environment;
and respectively packaging the system functions to obtain a multi-core user interface and a periodic task user interface which can be used in a target simulation environment.
3. The method of claim 1, after configuring a task interface function for each of the OS tasks and generating corresponding configuration code, further comprising:
the following operations are performed for each OS task:
simulating and running the OS task;
determining whether the operation running time of the OS task is larger than the execution period of the OS task based on the simulation running result;
in the case of a greater than, some of the OS tasks are assigned to other OS tasks of the current core.
4. The method of claim 3, wherein the assigning the portion of the OS tasks to other OS tasks of the current core comprises:
newly establishing an OS task as an extended OS task in a current core, wherein the execution period of the extended OS task is the same as that of the OS task;
and distributing part of the OS tasks to the extended OS tasks.
5. The method of claim 4, wherein said assigning a portion of the OS tasks to the extended OS tasks comprises:
and distributing part of the OS tasks to the extended OS tasks based on the execution cycle of the OS tasks and the running time of all the periodic tasks contained in the OS tasks, so that the running time of the distributed OS tasks and the running time of the extended OS tasks are not more than the execution cycle of the OS tasks.
6. The method of claim 3, further comprising:
and in the case that the load rate of the current core exceeds a first threshold value, distributing part of OS tasks in the cores with the load rates exceeding the first threshold value to other cores.
7. The method of claim 6, wherein the allocating the partial OS tasks in the cores with the load rate exceeding the first threshold to other cores comprises:
and distributing part of OS tasks in the cores with the load rate exceeding the first threshold value to OS tasks in other cores with the same execution period of the OS tasks or distributing the part of OS tasks to other cores as a single OS task.
8. A multi-core task processing apparatus in a simulation environment, comprising:
the interface construction module is used for respectively constructing user interfaces which can be used by the multi-core task and the periodic task in a target simulation environment to obtain a multi-core user interface and a periodic task user interface;
the task configuration module is used for calling the multi-core user interface and the periodic task user interface in a model file of a target simulation environment to perform task configuration, wherein the task configuration comprises task content of the periodic tasks, the configured periodic tasks are distributed to at least two different cores, and the task content comprises task operation and execution cycles;
the cycle counting module is used for counting the execution cycle of the cycle task which needs to be executed by each core in the at least two different cores;
the task determination module is used for regarding each core as an OS task, wherein the periodic tasks with the same execution period are used as the OS tasks;
and the calling configuration module is used for configuring a task interface function for each OS task and generating a corresponding configuration code, so that the task interface function is called only once in one execution period of each OS task when the OS task is simulated and run.
9. The apparatus of claim 8, wherein the interface construction module comprises:
the function processing module is used for respectively writing system functions of multi-core tasks and periodic tasks by using languages available in the target simulation environment;
and the interface packaging module is used for respectively packaging the system functions to obtain a user interface which can be used by the multi-core and periodic tasks in the target simulation environment.
10. The apparatus of claim 8, further comprising:
the task management module is used for carrying out task management on each OS task;
the task management module comprises:
an emulation run module to, for each OS task: simulating and running the OS task;
a time determination module for determining whether the operation running time of the OS task is greater than the execution cycle thereof based on the simulation running result of the simulation running module;
and the task allocation module is used for allocating part of tasks of the OS task to other OS tasks of the current core under the condition that the determination result of the time determination module is positive.
CN202010580398.6A 2020-06-23 2020-06-23 Multi-core task processing method and device in simulation environment Active CN111752692B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010580398.6A CN111752692B (en) 2020-06-23 2020-06-23 Multi-core task processing method and device in simulation environment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010580398.6A CN111752692B (en) 2020-06-23 2020-06-23 Multi-core task processing method and device in simulation environment

Publications (2)

Publication Number Publication Date
CN111752692A true CN111752692A (en) 2020-10-09
CN111752692B CN111752692B (en) 2024-04-12

Family

ID=72676832

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010580398.6A Active CN111752692B (en) 2020-06-23 2020-06-23 Multi-core task processing method and device in simulation environment

Country Status (1)

Country Link
CN (1) CN111752692B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101533262A (en) * 2009-04-22 2009-09-16 北京航空航天大学 Method for realizing associative simulation of machine and control system based on service
US20120072908A1 (en) * 2010-09-21 2012-03-22 Schroth David W System and method for affinity dispatching for task management in an emulated multiprocessor environment
JP2014102734A (en) * 2012-11-21 2014-06-05 Renesas Electronics Corp Performance verification program, performance verification method, and performance verification device
CN104111871A (en) * 2013-04-16 2014-10-22 济南概伦电子科技有限公司 Method and device used for executing dynamic load balancing in circuit simulation
US20150106819A1 (en) * 2013-10-14 2015-04-16 Electronics And Telecommunications Research Institute Task scheduling method for priority-based real-time operating system in multicore environment
CN107220107A (en) * 2017-06-29 2017-09-29 上海新跃联汇电子科技有限公司 A kind of multi-clock multi-task parallel real-time emulation system and method
EP3364296A1 (en) * 2017-02-20 2018-08-22 Paris-Lodron-Universität Salzburg Simulating execution-time variations and scheduling in a block-oriented simulation system
CN109086128A (en) * 2018-08-28 2018-12-25 迈普通信技术股份有限公司 Method for scheduling task and device

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101533262A (en) * 2009-04-22 2009-09-16 北京航空航天大学 Method for realizing associative simulation of machine and control system based on service
US20120072908A1 (en) * 2010-09-21 2012-03-22 Schroth David W System and method for affinity dispatching for task management in an emulated multiprocessor environment
JP2014102734A (en) * 2012-11-21 2014-06-05 Renesas Electronics Corp Performance verification program, performance verification method, and performance verification device
CN104111871A (en) * 2013-04-16 2014-10-22 济南概伦电子科技有限公司 Method and device used for executing dynamic load balancing in circuit simulation
US20150106819A1 (en) * 2013-10-14 2015-04-16 Electronics And Telecommunications Research Institute Task scheduling method for priority-based real-time operating system in multicore environment
EP3364296A1 (en) * 2017-02-20 2018-08-22 Paris-Lodron-Universität Salzburg Simulating execution-time variations and scheduling in a block-oriented simulation system
CN107220107A (en) * 2017-06-29 2017-09-29 上海新跃联汇电子科技有限公司 A kind of multi-clock multi-task parallel real-time emulation system and method
CN109086128A (en) * 2018-08-28 2018-12-25 迈普通信技术股份有限公司 Method for scheduling task and device

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
张云山;: "xPC实时半物理仿真平台中并行执行模型的设计", 电子设计工程, no. 18 *
林成江,李三立: "并行处理任务级仿真环境的研究及实现", 计算机学报, no. 07 *

Also Published As

Publication number Publication date
CN111752692B (en) 2024-04-12

Similar Documents

Publication Publication Date Title
US9405653B1 (en) Filtering data frames using program instrumentation
CN108958729B (en) Data processing method, device and storage medium
CN112214260A (en) Loading method and device of terminal application APP
CN110427258B (en) Resource scheduling control method and device based on cloud platform
CN112527404B (en) Configuration method, device, equipment and medium for chip relay protection general system
CN103092751A (en) Web application performance test system based on customer behavior model in cloud environment
CN111262753B (en) Method, system, terminal and storage medium for automatically configuring number of NUMA nodes
CN109522021B (en) Parameter callback processing method and device, electronic equipment and storage medium
CN110955434B (en) Software development kit processing method and device, computer equipment and storage medium
CN110888628A (en) Method, device, equipment and storage medium for generating control tool
CN110569154A (en) Chip interface function testing method, system, terminal and storage medium
CN111797025B (en) Application-oriented data processing method and device
CN111752692B (en) Multi-core task processing method and device in simulation environment
CN112214325A (en) FPGA task dynamic arrangement method, device, chip and storage medium
CN109462663B (en) Method for limiting system resource occupation, voice interaction system and storage medium
CN110704195A (en) CPU adjusting method, server and computer readable storage medium
CN112764729B (en) Application software development method, device, computer equipment and readable storage medium
CN110333870B (en) Simulink model variable distribution processing method, device and equipment
CN114115850A (en) Code generation method and device
CN112104716A (en) Method and device for collecting data of software project, readable storage medium and equipment
CN107273283A (en) A kind of automated software detection method and device
CN112114931A (en) Deep learning program configuration method and device, electronic equipment and storage medium
CN114296742B (en) Installation package creating method, installation package creating device, installation package creating equipment and installation package creating medium
CN117311999B (en) Resource scheduling method, storage medium and electronic equipment of service cluster
CN113704687B (en) Tensor calculation operation method, device and operation system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Address after: 4 / F, building 1, No.14 Jiuxianqiao Road, Chaoyang District, Beijing 100020

Applicant after: Beijing Jingwei Hengrun Technology Co.,Ltd.

Address before: 8 / F, block B, No. 11, Anxiang Beili, Chaoyang District, Beijing 100101

Applicant before: Beijing Jingwei HiRain Technologies Co.,Ltd.

GR01 Patent grant
GR01 Patent grant