Multi-task processing method and system, storage medium and equipment
By introducing mapping relationship tables into the controller system, user tasks are bound to the input and output modules, solving the problem of frequent unlocking in existing multitasking processing, improving performance and reducing deadlock risks.
Patent Information
- Application Number
- CN202510283523.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-11
- Publication Date
- 2025-06-13
AI Technical Summary
The existing multitasking mechanism requires frequent unlocking of memory resources when the task is running, resulting in poor performance and deadlock risks.
By introducing a mapping relationship table into the controller system, user tasks are bound to the input and output modules, and user tasks have exclusive memory areas, reducing the additional unlocking operation.
Improves multitasking performance, reduces deadlock risk, and enables user tasks to efficiently perform module redundant data voting in private memory areas.
Smart Images

Figure CN120144306A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technologies, and particularly to a multitasking method, system, storage medium, and device. Background Art
[0002] Currently, most controllers of safety instrument systems support the multitasking mode, that is, the logic programs on the controller are divided into multiple independent tasks, and different scheduling cycles and priorities can be assigned to the tasks according to their characteristics. The controller can process multiple tasks in parallel according to the scheduling time and priority. The multitasking mechanism aims to reasonably schedule and allocate resources.
[0003] Correspondingly, there are two existing multitasking memory mechanisms. The first is that multiple tasks share memory, and when a task is executed, it locks the used memory to exclusively occupy resources. The advantage is that all tasks can use memory more freely and can access all data, but it requires frequent locking and unlocking, which is time-consuming. The second is that each task has its own independent memory, and tasks do not interfere with each other. Tasks can exchange a small amount of resources through communication. This method does not require frequent locking and unlocking during task execution, which optimizes time, but the memory used is extremely limited. Summary of the Invention
[0004] The purpose of this application is to provide a multitasking method, system, computer-readable storage medium, and electronic device, which can ensure that user tasks can exclusively occupy memory resources during operation, reduce resource locking and unlocking operations, and improve task processing performance.
[0005] To solve the above technical problems, this application provides a multitasking method applied to a controller system. The controller system includes configuration software, an input / output module, and a controller. The configuration software runs on a host computer and supports input / output tasks and multiple user tasks. The input / output tasks are executed by the controller and are used to manage the relationship between the input / output module and the user logic program. The method includes:
[0006] When the configuration software compiles configuration data, the input / output task obtains a mapping relationship table between the user tasks and the input / output module.
[0007] When the input / output module transmits module data to the controller, the host computer sends the mapping relationship table to the controller.
[0008] When the controller receives the mapping relation table and the module data, the input / output task copies the module data to the corresponding memory, and stores the module data in the private memory area corresponding to the user task according to the mapping relation table, so that each user task performs module redundant data voting in the private memory area, and takes the generated voting result as the logical input data; the private memory area is used.
[0009] Optionally, if an access request for the logical input data by the second user task is detected, it further includes:
[0010] The first user task to which the logical input data belongs sends the logical input data to the inter-task shared memory, so that the second user task can access the logical input data on the inter-task shared memory.
[0011] Optionally, after the first user task to which the logical input data belongs sends the logical input data to the inter-task shared memory, it further includes:
[0012] Obtain the input / output data used crosswise in the configuration logic between user tasks to obtain a cross-reference table;
[0013] Download the cross-reference table to the controller, so that the controller sends all the logical input data that has been referenced to the inter-task shared memory according to the cross-reference table.
[0014] Optionally, the inter-task shared memory supports multiple user tasks to read and access simultaneously, and only supports a single task to write to the inter-task shared memory.
[0015] Optionally, the process of the input / output module transmitting module data to the controller includes:
[0016] The input / output module obtains setting data, generated data based on the user configuration, and uploaded data; the setting data includes configuration data of hardware devices, logic programs, and communication data; the generated data includes a cross-reference table, the mapping relation table, an input / output address mapping table, and a default device logic program; the uploaded data includes channel values and diagnostic values; wherein, the mapping relation table is generated when the configuration software compiles the configuration data;
[0017] The input / output module transmits the setting data, generated data based on the user configuration, and uploaded data to the controller.
[0018] Optionally, it further includes:
[0019] Enable redundant configuration for the power supply and the processor, and set the master-slave switching logic in the redundant configuration.
[0020] Optionally, after the input / output module obtains the setting data, it further includes:
[0021] Monitoring the input / output status and analog quantity change of the configuration data; the input / output status includes sensor values and output signals;
[0022] Performing single-step execution debugging on the configuration data to obtain a debugging result;
[0023] Using the default device logic program to send redundant devices to the controller so that the controller can call the redundant data voting algorithm to obtain a test result;
[0024] If there are no abnormalities in both the debugging result and the test result, confirm that the configuration data is valid.
[0025] This application also provides an application for a controller system. The controller system includes configuration software, an input / output module, and a controller. The configuration software runs on a host computer and supports input / output tasks and multiple user tasks; the input / output tasks are executed by the controller and are used to manage the relationship between the input / output module and the user logic program. The multi-task processing system includes:
[0026] A mapping relationship acquisition module, which is used to obtain a mapping relationship table between the user task and the input / output module when the input / output task obtains the mapping relationship table between the user task and the input / output module when the configuration software compiles the configuration data;
[0027] A mapping relationship downloading module, which is used to download the mapping relationship table to the controller by the host computer when the input / output module transmits module data to the controller;
[0028] A task processing module, which is used when the controller receives the mapping relationship table and the module data, the input / output task copies the module data to the corresponding memory, and stores the module data in the private memory area corresponding to the user task according to the mapping relationship table, so that each user task performs module redundant data voting in the private memory area and uses the generated voting result as logical input data; the private memory area is used to store a copy of the module data of the input / output module to which the user task belongs.
[0029] This application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described above are implemented.
[0030] This application also provides an electronic device, including a memory and a processor. When the processor calls the computer program stored in the memory, the steps of the method described above are implemented.
[0031] The present application provides a multitasking method, which is applied to a controller system. The controller system includes configuration software, an input / output module, and a controller. The configuration software runs on a host computer and supports input / output tasks and multiple user tasks. The input / output tasks are executed by the controller and are used to manage the relationship between the input / output module and the user logic program. The method includes: when the configuration software compiles configuration data, the input / output task obtains a mapping relationship table between the user tasks and the input / output module; when the input / output module transmits module data to the controller, the host computer sends the mapping relationship table to the controller; when the controller receives the mapping relationship table and the module data, the input / output task copies the module data to the corresponding memory and stores the module data in the private memory area corresponding to the user task according to the mapping relationship table, so that each user task performs module redundant data voting in the private memory area and uses the generated voting result as logical input data. The private memory area is used to store a copy of the module data of the input / output module to which the user task belongs.
[0032] In view of the actual application scenario that the input / output module is only written by a single user task in the present application, the user task is bound to the input / output module, so that the user task has its own exclusive memory area. When the user logic program runs, it can exclusively occupy the memory resources of the user task, reducing the frequent locking and unlocking processes of the memory resources during task conflicts, thereby optimizing the performance of the multitasking process, avoiding the deadlock problem that may be caused by frequent locking and unlocking, and improving the multitasking performance.
[0033] The present application also provides a multitasking system, a computer-readable storage medium, and an electronic device, which have the above beneficial effects and will not be elaborated here. Description of the Drawings
[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained according to the provided drawings without creative efforts.
[0035] Figure 1 It is a flowchart of a multitasking method provided by an embodiment of the present application;
[0036] Figure 2 It is a data flow diagram of the input / output module provided by an embodiment of the present application;
[0037] Figure 3Schematic diagram of a mapping relation table structure provided by an embodiment of the present application;
[0038] Figure 4 Schematic diagram of a multi-task processing system structure provided by an embodiment of the present application;
[0039] Figure 5 Schematic diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners
[0040] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Apparently, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.
[0041] Please refer to Figure 1 , Figure 1 which is a flowchart of a multi-task processing method provided by an embodiment of the present application. The method includes:
[0042] S101: When the configuration software compiles configuration data, the input / output task obtains a mapping relation table between the user task and the input / output module;
[0043] S102: When the input / output module transmits module data to the controller, the host computer sends the mapping relation table to the controller;
[0044] S103: When the controller receives the mapping relation table and the module data, the input / output task copies the module data to the corresponding memory, and stores the module data in the private memory area corresponding to the user task according to the mapping relation table, so that each user task performs module redundant data voting in the private memory area, and uses the generated voting result as logical input data; the private memory area is used to store a copy of the module data of the input / output module to which the user task belongs.
[0045] This application is applied to a controller system, which includes configuration software, input / output modules, and a controller. The configuration software runs on a host computer and supports input / output tasks and multiple user tasks. The input / output tasks are used to manage the input / output modules and user logic programs. The purpose of this application is to improve the performance and flexibility of task memory management by refining the data management of input / output modules for each user task. In the configuration software, the input / output modules are managed under the user tasks, so that data can be exchanged between user tasks by reference. Both the input / output modules and the controller are hardware devices. In practical applications, the input / output modules can be further divided into input modules and output modules. The input modules are also called sensor modules, including analog input modules and digital input modules. The output modules can also include digital output modules and analog output modules. In addition, the hardware device can also include a communication module, which is used to complete the communication between different modules, including but not limited to the communication between the controller and the host computer.
[0046] The controller manages the internal memory of the controller in units of tasks. The tasks are divided into input / output tasks (also called IO tasks) and user tasks. The input / output tasks are tasks in the controller used to manage the relationship between the input / output modules and user tasks. The user tasks are tasks provided for users. Users can associate input / output devices with user tasks through the configuration software, or add logic programs under the user tasks.
[0047] It can be seen that this application mainly includes a hardware architecture and a software part. The hardware architecture requires the application hardware to support multitasking, while the software part is mainly applied to the configuration software corresponding to the input / output modules. The configuration software needs to provide multitasking configuration, including supporting specifying the input / output modules under a certain user task. In the multitasking model, the configuration software needs to support one input / output task and multiple user tasks. The input / output tasks are used to manage the relationship between tasks and modules, and the user tasks are used to manage the input / output modules and user logic programs. The user logic program is the control logic code written by users (such as engineers or programmers) in an industrial automation system, which is used to implement specific device control, process management, or data processing functions. It usually runs on a programmable logic controller (PLC), an industrial computer (IPC), or other embedded controllers.
[0048] Specifically, during compilation, the configuration software generates a set of device default logic programs (system POU) for each user task. The device default logic program is the basic unit for the controller to execute the user task. The system POU includes: the logic program for diagnosing all devices under the user task, the input data voting logic under the user task, the scheduling logic for sequentially scheduling the user POU, and the logic for performing output voting under the user task. The mapping relationship table in this embodiment can include information such as module ID, module data length, and task index.
[0049] There is no limitation on how to compile configuration data using configuration software here. The compiled configuration data mainly includes hardware device configuration and logic configuration, and specifically may include the following processes:
[0050] The user configures the hardware device using the configuration software, and sets the communication protocol and IP address between the controller and the input / output module; defines the input / output address mapping, writes the control program, and obtains the configuration data including hardware device configuration and logic configuration.
[0051] When compiling the configuration data, it is first necessary to add and connect the hardware devices. Hardware devices such as controllers (such as PLC, DCS controllers, etc.) and input / output modules (I / O modules) need to be connected to the system. Devices are usually connected through network interfaces (such as Ethernet), serial interfaces (such as RS485), or other communication buses. The configuration software scans the network or communication bus to identify the connected hardware devices. The configuration software will list all the identified devices and display information such as their models and versions.
[0052] After that, it is necessary to configure the communication protocol and IP address, and set the communication protocol and IP address. The communication protocol can be selected according to the communication capabilities of the hardware devices, and a suitable communication protocol can be chosen. Common communication protocols include Modbus TCP / IP, Profibus, EtherNet / IP, etc. For example, if the Modbus TCP / IP protocol is used, it is necessary to ensure that both the controller and the I / O module support this protocol. And the IP address configuration is to assign IP addresses to the controller and the I / O module. The IP addresses must be in the same network segment and cannot conflict.
[0053] At the same time, in the configuration software, addresses are assigned to the input / output modules to identify specific signals in the modules (such as digital input, digital output, analog input, analog output, etc.). For example, the address of a digital input module can be defined as I0.0, I0.1, etc., and the address of an analog input module can be defined as AI0, AI1, etc.
[0054] Defining the input / output address mapping is to connect the input / output addresses with the actual physical signals. For example, map I0.0 to the signal input end of the sensor, and map Q0.0 to the signal output end of the actuator. After that, the control program can be written according to the control requirements. The control program can use programming languages such as ladder diagram, function block diagram, instruction list, etc.
[0055] The module data transmitted to the controller at this time may include setting data, generated data based on the user configuration, and uploaded data. The setting data includes configuration data of hardware devices, logic programs, and communication data. The generated data based on the user configuration includes cross-reference tables, mapping relation tables, input / output address mapping tables, and default device logic programs. The uploaded data is mainly the channel values and diagnostic values uploaded by the input module. The mapping relation table is generated when the configuration software compiles the configuration data.
[0056] In addition, when compiling the configuration data, redundant configurations can also be enabled for the power supply and the processor, and the master-slave switching logic in the redundant configuration can be set.
[0057] In a feasible implementation manner, in order to ensure the validity of the configuration data, the configuration data can be further monitored and debugged, which may include the following steps:
[0058] First step, monitor the input / output status and analog quantity changes of the configuration data; the input / output status includes sensor values and output signals;
[0059] Second step, perform step-by-step execution debugging on the configuration data to obtain the debugging result;
[0060] Third step, use the default device logic program to send the redundant device to the controller so that the controller can call the redundant data voting algorithm to obtain the test result;
[0061] Fourth step, if there are no abnormalities in both the debugging result and the test result, confirm that the configuration data is valid.
[0062] The configuration software can view the system POU through configuration. In the online mode of the configuration software, the online values and operation results of all variables can be observed through the system POU to ensure whether it runs as expected.
[0063] Step-by-step execution debugging is a method of executing the program one by one. Users can view the execution results of each instruction one by one, which is suitable for checking program logic and variable changes.
[0064] Since some hardware devices may include redundant settings, it is necessary to perform redundant tests on the corresponding hardware devices such as the processor and the power supply to ensure the effectiveness of the redundant settings.
[0065] If there are no abnormalities in both the debugging result and the test result, the validity of the configuration data can be confirmed.
[0066] After the user configuration data is compiled and the mapping relationship table is obtained, when the input / output module transfers module data to the controller, the configuration software can send the mapping relationship table to the controller. When the controller receives the mapping relationship table and the module data, the input / output task copies the module data to the corresponding memory, and can copy the module data to the memory of the input / output task itself.
[0067] In addition, the input / output task also needs to store the module data in the private memory area corresponding to the user task according to the mapping relationship table, so that each user task performs module redundant data voting in the private memory area, and the generated voting result is used as the logical input data. In the actual application process, the module data can be distributed to the task I area to which the user task belongs according to the mapping relationship table. Each user task completes the voting of the module redundant data, and the voted data is used as the input data of the IEC module (the IEC module refers to the communication module that complies with the standards of the International Electrotechnical Commission (IEC) and is used to realize the automation of the intelligent power system). This data is only supported to be used by the user task to which the module belongs. The logical input data can be used for subsequent control logic. The task I area refers to the input buffer for user tasks in the controller system.
[0068] It can be seen that the task is the running unit of the controller. When the controller runs the input / output task, it copies the data of the input module to the memory of the task to which the input module belongs according to the mapping relationship. When the controller runs the user task, it votes on the input data in the private memory area according to the device default logic program, and stores the voting result in the memory for subsequent use as the input of the user configuration logic (also called the user POU). After the controller executes the user configuration logic (user POU) under this task, it copies the data that needs to be sent to the output module to the corresponding memory. When the controller runs the input / output task, it copies and sends the output data to the output module in the input / output module according to the mapping relationship.
[0069] In the embodiment of the present application, the user task is bound to the input / output module, so that the user task has its own exclusive memory area, and can exclusively occupy the memory resources of the user task when the user logic program runs, reducing the frequent locking and unlocking processes of the memory resources during task conflicts, thereby optimizing the performance of the multi-task processing process, avoiding the deadlock problem that may be caused by frequent locking and unlocking, and improving the multi-task processing performance.
[0070] Based on the above embodiments, if there is data interaction between user tasks, the method of inter-task reference can be adopted. Inter-task reference means that a task sends its module data to a shared memory area for other tasks to use. Specifically, the first user task to which the logical input data belongs sends the logical input data to the shared memory between tasks, so that the second user task can access the logical input data on the shared memory between tasks. The second user task described in this embodiment refers to any other user task that can access the logical input data of the first user task.
[0071] After that, the input and output data used crosswise in the configuration logic between user tasks can be obtained to generate a cross-reference table; the cross-reference table is downloaded to the controller so that the controller can send all the logical input data that has been referenced to the shared memory between tasks according to the cross-reference table.
[0072] During the compilation of the configuration software, the IEC module needs to collect the input and output data used crosswise in the user configuration logic between tasks, generate a corresponding cross-reference table, and download the cross-reference table to the controller. When the user tasks are running, the controller will send the data referenced by other user tasks to the shared memory between tasks according to the cross-reference table. The variables in the shared memory between tasks support multiple user tasks to read and access simultaneously, and only support a single task to write to the shared memory between tasks, that is, follow the access principle of one-write and multiple-reads.
[0073] Under the access principle of one-write and multiple-reads, the write operation and read operation (i.e., access operation) of the shared memory between tasks can be carried out on different resources or paths. For example, in some database systems, the write operation can be carried out in the main storage space, while multiple read operations can be carried out simultaneously in the read-only copy or cache. In this way, the read operation does not need to wait for the write operation to complete, greatly improving the concurrent processing ability of the system and enhancing the overall response speed.
[0074] At the same time, the use of locks can be reduced. Since the reads of the same variable by multiple threads do not require synchronization, the frequent use of the lock mechanism for synchronization is avoided, reducing the overhead of context switching, thereby improving the performance of the system.
[0075] More importantly, the access principle of one-write and multiple-reads can avoid data conflicts: in the case of single-write, it is not easy to have data conflict problems caused by multiple write operations being carried out simultaneously, making the update of data more controllable and accurate.
[0076] See Figure 2 , Figure 2 which is the data flow diagram of the input and output module provided by the embodiment of the present application. Figure 2The data interaction process between the IO module (i.e., input / output module) and the controller is shown. It includes IO module A, IO module B, IO module C, and IO module D. In the corresponding controller, the application task-IO mapping table is used as a mapping relationship table to record the mapping relationship between user tasks and input / output modules. Figure 2 Task 0 corresponding to module A inside the controller (module A belongs to task 0), and the following tasks 1, 2, and 3, etc. are all user tasks. Thereafter, according to the task-IO mapping table, module data is distributed, i.e., module A data, module B data, module C data, and module D data, etc. After redundant voting, the logical input data is obtained and participates in the IEC operation of the IEC module.
[0077] See Figure 3 , Figure 3 It is a schematic diagram of the structure of a mapping relationship table provided by an embodiment of the present application. The mapping relationship table includes information such as module ID, module data length, and task index.
[0078] See Figure 4 , Figure 4 It is a schematic diagram of the structure of a multi-task processing system provided by an embodiment of the present application. Next, a multi-task processing system provided by an embodiment of the present application will be introduced. The multi-task processing system described below can be correspondingly referred to the multi-task processing method described above.
[0079] This multi-task processing system is applied to a controller system. The controller system includes configuration software, input / output modules, and a controller. The configuration software runs on the upper computer and supports input / output tasks and multiple user tasks. The input / output tasks are executed by the controller and are used to manage the relationship between the input / output modules and the user logic program. The multi-task processing system includes:
[0080] A mapping relationship acquisition module, which is used to obtain the mapping relationship table between the user tasks and the input / output modules when the input / output tasks acquire the configuration data compiled by the configuration software.
[0081] A mapping relationship downloading module, which is used to download the mapping relationship table to the controller by the upper computer when the input / output modules transmit module data to the controller.
[0082] A task processing module, when the controller receives the mapping relation table and the module data, is configured to copy the module data to the corresponding memory by the input / output task, and store the module data in the private memory area corresponding to the user task according to the mapping relation table, so that each user task performs module redundant data voting in the private memory area, and uses the generated voting result as logical input data; the private memory area is used to store a copy of the module data of the input / output module to which the user task belongs.
[0083] Based on the above embodiment, as a preferred embodiment, it further includes:
[0084] A data sharing module, when detecting an access request from a second user task to the logical input data, is configured to control the first user task to which the logical input data belongs to send the logical input data to the inter-task shared memory, so that the second user task can access the logical input data on the inter-task shared memory.
[0085] Based on the above embodiment, as a preferred embodiment, it further includes:
[0086] A reference relationship recording module, configured to obtain the input / output data used crosswise in the configuration logic between user tasks to obtain a cross-reference table; download the cross-reference table to the controller, so that the controller sends all the logical input data that has been referenced to the inter-task shared memory according to the cross-reference table.
[0087] Based on the above embodiment, as a preferred embodiment, the multi-task processing system further includes:
[0088] A module data generation module, configured to obtain setting data, generated data based on the user configuration, and uploaded data; the setting data includes configuration data of hardware devices, logic programs, and communication data; the generated data includes a cross-reference table, the mapping relation table, an input / output address mapping table, and a default device logic program; the uploaded data includes channel values and diagnostic values; wherein, the mapping relation table is generated when the configuration software compiles the configuration data.
[0089] Based on the above embodiment, as a preferred embodiment, the module data generation module further includes:
[0090] A configuration data detection module, configured to monitor the input / output status and analog quantity change of the configuration data; the input / output status includes sensor values and output signals; perform single-step execution debugging on the configuration data to obtain a debugging result; use the default device logic program to send redundant devices to the controller, so that the controller calls a redundant data voting algorithm to obtain a test result; if both the debugging result and the test result are normal, confirm that the configuration data is valid.
[0091] The present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed, the steps of the method provided in the above embodiments can be implemented. The storage medium may include: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical discs.
[0092] The present application also provides an electronic device. Refer to Figure 5 , a structural diagram of an electronic device provided in an embodiment of the present application, as Figure 5 shown, may include a processor 1410 and a memory 1420.
[0093] Among them, the processor 1410 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1410 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). The processor 1410 may also include a main processor and a coprocessor. The main processor is a processor used to process data in the wake state, also known as the CPU (Central Processing Unit); the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 1410 may be integrated with a GPU (Graphics Processing Unit), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1410 may also include an AI (Artificial Intelligence) processor, and the AI processor is used to process computational operations related to machine learning.
[0094] The memory 1420 may include one or more computer-readable storage media, which may be non-transitory. The memory 1420 may also include high-speed random access memory and non-volatile memory, such as one or more magnetic disk storage devices and flash storage devices. In this embodiment, the memory 1420 is at least used to store the following computer program 1421. After the computer program is loaded and executed by the processor 1410, it can implement the relevant steps in the methods executed by the electronic device side disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 1420 may also include an operating system 1422, data 1423, etc., and the storage method may be transient storage or permanent storage. Among them, the operating system 1422 may include Windows, Linux, Android, etc.
[0095] In some embodiments, the electronic device may further include a display screen 1430, an input / output interface 1440, a communication interface 1450, a sensor 1460, a power supply 1470, and a communication bus 1480.
[0096] Of course, Figure 5 The structure of the illustrated electronic device does not constitute a limitation on the electronic device in the embodiments of the present application. In actual applications, the electronic device may include more or fewer components than Figure 5 those illustrated, or combine certain components.
[0097] The various embodiments in the specification are described in a progressive manner. The key point of each embodiment is to illustrate the differences from other embodiments. The same or similar parts among the various embodiments may be referred to each other. For the system provided by the embodiment, since it corresponds to the method provided by the embodiment, the description is relatively simple, and the relevant parts may be referred to the description of the method part.
[0098] Specific examples are used in this article to elaborate on the principles and implementation manners of the present application. The descriptions of the above embodiments are only used to help understand the method and its core idea of the present application. It should be noted that for those of ordinary skill in the art of this technology, without departing from the principle of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the protection scope of the present application.
[0099] It should also be noted that in this specification, 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 any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the said element.
Claims
1. A multitasking method, characterized in that: Applied to a controller system, the controller system includes configuration software, an input / output module and a controller, the configuration software runs on a host computer and supports input / output tasks and multiple user tasks; The input / output task is executed by the controller and is used to manage the relationship between the input / output module and the user logic program. The method includes: When the configuration software compiles the configuration data, the input-output task obtains a mapping relationship table between the user task and the input-output module; When the input / output module transmits module data to the controller, the host computer sends the mapping relationship table to the controller; When the controller receives the mapping relationship table and the module data, the input-output task copies the module data to the corresponding memory, and stores the module data to the private memory area corresponding to the user task according to the mapping relationship table, so that each user task performs module redundant data voting in the private memory area and uses the generated voting result as logical input data; the private memory area is used to store the module data copy of the input-output module to which the user task belongs.
2. The multitasking method according to claim 1, characterized in that: If a second user task's access request to the logic input data is detected, the method further includes: The first user task to which the logic input data belongs sends the logic input data to an inter-task shared memory, so that the second user task accesses the logic input data on the inter-task shared memory.
3. The multitasking method according to claim 2, characterized in that: After the first user task to which the logic input data belongs sends the logic input data to the inter-task shared memory, the method further includes: Get the input and output data cross-used by the configuration logic between user tasks and get a cross-reference table; The cross-reference table is downloaded to the controller so that the controller sends all referenced logic input data to the inter-task shared memory according to the cross-reference table.
4. The multitasking method according to claim 3, characterized in that: The inter-task shared memory supports simultaneous read access by multiple user tasks, and only supports a single task writing to the inter-task shared memory.
5. The multitasking method according to claim 3, characterized in that: The process of transmitting module data from the input / output module to the controller includes: The input / output module acquires setting data, generated data based on user configuration and uploaded data; the setting data includes configuration data, logic program and communication data of the hardware device; the generated data includes a cross-reference table, the mapping relationship table, an input / output address mapping table and a default device logic program; the uploaded data includes a channel value and a diagnostic value; wherein the mapping relationship table is generated when the configuration software compiles the configuration data; The input-output module transmits the setting data, the generated data based on the user configuration and the uploaded data to the controller.
6. The multitasking method according to claim 5, characterized in that: Also includes: Enable redundant configuration for power supplies and processors, and set the active / standby switchover logic in the redundant configuration.
7. The multitasking method according to claim 5, characterized in that: After the input and output module obtains the setting data, it also includes: Monitoring the input and output states and analog quantity changes of the configuration data; the input and output states include sensor values and output signals; Performing single-step debugging on the configuration data to obtain a debugging result; Sending redundant devices to the controller using a default device logic program so that the controller invokes a redundant data voting algorithm to obtain a test result; If there is no abnormality in the debugging result and the test result, it is confirmed that the configuration data is valid.
8. A multi-tasking system, characterized in that: Applied to a controller system, the controller system includes configuration software, an input / output module and a controller, the configuration software runs on a host computer and supports input / output tasks and multiple user tasks; The input and output tasks are executed by the controller to manage the relationship between the input and output modules and the user logic program. The multi-task processing system includes: A mapping relationship acquisition module, used for the input-output task to acquire a mapping relationship table between the user task and the input-output module when the configuration software compiles the configuration data; A mapping relationship download module, used for the host computer to send the mapping relationship table to the controller when the input and output module transmits module data to the controller; A task processing module, used for when the controller receives the mapping relationship table and the module data, the input and output task copies the module data to the corresponding memory, and stores the module data to the private memory area corresponding to the user task according to the mapping relationship table, so that each user task performs module redundant data voting in the private memory area and uses the generated voting result as logical input data; the private memory area is used to store the module data copy of the input and output module to which the user task belongs.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the multi-tasking method according to any one of claims 1 to 7 are implemented.
10. An electronic device, characterized in that: The method comprises a memory and a processor, wherein a computer program is stored in the memory, and when the processor calls the computer program in the memory, the steps of the multi-tasking method according to any one of claims 1 to 7 are implemented.