A Multi-task Hierarchical Synchronization and Sequential Monitoring Method Based on Dual-Mode CPU

By employing a multi-task hierarchical synchronization and sequential monitoring method with dual-mode CPUs, the problems of a single synchronization mechanism and unreasonable resource allocation are solved, enabling precise synchronization and strict monitoring of high-security-level tasks, and optimizing system performance and resource utilization.

CN123114887APending Publication Date: 2026-11-17CRRC QINGDAO SIFANG ROLLING STOCK RESEARCH INSTITUTE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611262149.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-19
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

Existing dual-mode CPU systems suffer from a lack of synchronization mechanisms, insufficient monitoring granularity, and unreasonable resource allocation when handling multi-tasking environments. This leads to mutual interference between high and low security level tasks, making it impossible to meet the stringent requirements of high security level tasks.

Method used

A multi-task hierarchical synchronization and sequential monitoring method based on dual-mode CPU is adopted. Task synchronization is achieved through isolation channels and hardware clocks, an execution sequence state machine and statistical monitoring are established, and non-overlapping execution time windows and memory regions are allocated to ensure the independent operation of high-security-level tasks.

Benefits of technology

It achieves precise synchronization and strict monitoring of high-security tasks, optimizes system performance, prevents fault propagation, and improves resource utilization efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123114887A_ABST
    Figure CN123114887A_ABST
Patent Text Reader

Abstract

This invention provides a multi-task hierarchical synchronization and sequential monitoring method based on a dual-mode CPU, comprising: When the first CPU and the second CPU execute tasks, they synchronize according to security levels. The first security level task transmits GPIO signals through an isolation channel and is synchronized by a hardware clock; the second security level task is placed in a blocked state and awakened by an interrupt. After acquiring status signals, the first FPGA and the second FPGA monitor the task execution order according to the security level. The first security level task establishes an execution order state machine to verify the legality of state transitions and check execution time; the second security level task uses statistical monitoring. The secure operating system allocates non-overlapping execution time windows and independent memory regions to each security level task, achieving time and space isolation. This invention improves system security integrity and resource utilization efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of embedded computer system technology, and in particular to a multi-task hierarchical synchronization and sequential monitoring method based on a dual-mode CPU. Background Technology

[0002] Fields such as rail transit and automation control require high-safety-level controller systems, which need to handle multiple tasks with different safety levels simultaneously. Traditional security computer systems face the following technical challenges when handling multi-tasking environments: (1) Single synchronization mechanism: Existing dual-mode CPU systems usually adopt a unified synchronization strategy, which cannot adapt to the differentiated synchronization requirements of tasks with different security levels.

[0003] (2) Insufficient monitoring granularity: Traditional sequential monitoring mechanisms apply the same monitoring intensity to all tasks, which wastes system resources and may not meet the strict monitoring requirements of high-security tasks.

[0004] (3) Unreasonable resource allocation: In a multi-task environment, tasks with high and low security levels compete for system resources, which may affect the real-time performance and reliability of tasks with high security levels.

[0005] (4) Fault impact spread: Faults in low-security-level tasks may affect the execution of high-security-level tasks through resource sharing, violating the principle of security isolation.

[0006] Existing technologies lack an effective solution for a secure computer system that can support multi-task hierarchical management, synchronous execution, and differentiated monitoring. Summary of the Invention

[0007] The purpose of this application is to address the deficiencies in the existing technology by providing a method and system for multi-task hierarchical synchronization and sequential monitoring based on a dual-mode CPU, thereby solving the problems existing in the prior art.

[0008] To achieve the above objectives, this application provides a multi-task hierarchical synchronization and sequential monitoring method based on a dual-mode CPU, applied to a secure computer system. The system includes a first CPU and a second CPU that redundantly run the same program, a first FPGA and a second FPGA isolated via an isolation channel, and a secure operating system. The method includes: When the first CPU and the second CPU execute tasks, they synchronize the tasks according to the preset security level of the tasks and output status signals. The synchronization includes: for tasks of the first security level, synchronization is performed by passing through GPIO signals through an isolation channel and by time synchronization through a hardware clock; for tasks of the second security level, they are placed in a blocked state to stop polling and are woken up when an interrupt is triggered. The first FPGA and the second FPGA respectively acquire the corresponding status signals and monitor the execution order of each task according to the preset security level and the monitoring strategy. The monitoring strategy includes: for the first security level task, establishing an execution order state machine, verifying the legality of the state transition according to the status completion signal sent when each task is completed and checking whether the execution time exceeds the time limit. If the state transition is illegal or exceeds the time limit, a fault indication is generated. For the second security level task, statistical monitoring is adopted to monitor the sequence of key events. The security operating system allocates non-overlapping execution time windows and independent memory regions for the first security level task and the second security level task, thereby isolating the first security level task and the second security level task in time and space. When the fault indication is received, the security operating system isolates the faulty first security level task or second security level task from the other security level task through the time window and the memory region.

[0009] In one possible implementation, the first CPU is connected to the first FPGA via an EMIF, and the second CPU is connected to the second FPGA via an EMIF. An isolation channel is provided between the first FPGA and the second FPGA; The GPIO signals of the first CPU are transmitted to the second CPU via the first FPGA, the isolation channel, and the second FPGA; the GPIO signals of the second CPU are transmitted to the first CPU via the second FPGA, the isolation channel, and the first FPGA.

[0010] In one possible implementation, the first security level task includes a data receiving task, a logical calculation task, a data sending task, and a self-testing task. The data receiving task has a priority of 1 and an execution period of 10ms; it is used to receive external input data. The logical calculation task has a priority of 2 and an execution period of 10ms. It is used to perform logical operations on the input data received by the data receiving task. The data sending task has a priority of 3 and an execution period of 10ms. It is used to send the calculation results of the logical calculation task to an external device. The self-check task has a priority of 4 and an execution cycle of 100ms. It is used to perform periodic self-checks on the system's operating status. The smaller the priority value, the higher the priority. The data receiving task, the logic calculation task, the data sending task, and the self-test task are scheduled to be executed by the security operating system in descending order of priority.

[0011] In one possible implementation, the second security level task is a fault log recording task; The fault log recording task has a running priority of 10 and an execution period of 1000ms. It is used to record fault information that occurs during system operation. After the fault log recording task begins execution, the event wait function of the security operating system is called to enter a blocked state and stop polling and occupying CPU resources. The fault log records events where a task waits for a high-priority task or an interrupt service program to trigger the event, which is either a fault occurrence event or a log write request event. When the fault occurrence event or the log write request event is triggered, the security operating system wakes up the fault log recording task; After being awakened, the fault log recording task performs log recording processing and writes the fault information into the log. After the log recording process is completed, the fault log recording task calls the event waiting function again and re-enters the blocked state.

[0012] In one possible implementation, placing the second security level task into a blocked state to stop polling and waking it up when an interrupt is triggered includes: After the second security level task begins execution, the event wait function of the security operating system is called, and the system enters a blocked state. In the blocked state, the second security level task stops polling and occupying CPU resources and waits for events triggered by high-priority tasks or interrupt service routines. When the event is triggered, the security operating system wakes up the second security level task, and the second security level task performs log recording processing; After the log recording is completed, the second security level task calls the event waiting function again and enters the blocked state.

[0013] In one possible implementation, the synchronization via transparent GPIO signals through an isolation channel includes: The first CPU outputs logic 1 simultaneously with the second CPU through its GPIOB_6 pin, via the isolation channel between the first FPGA and the second FPGA; The first CPU reads the logic 1 fed back by the second CPU through its GPIOB_7 pin and the isolation channel, and the second CPU reads the logic 1 fed back by the first CPU through its GPIOB_7 pin and the isolation channel. If the read is successful, the first CPU and the second CPU will simultaneously output logic 0 through their respective GPIOB_6 pins and read the logic 0 fed back by the other CPU through their respective GPIOB_7 pins. If the feedback value read after the first CPU or the second CPU writes logic 1 is not logic 1, or the feedback value read after writing logic 0 is not logic 0, then a security process is triggered.

[0014] In one possible implementation, for the first security level task, establishing an execution sequence state machine, verifying the legality of the state transition based on the state completion signal sent when each task is completed, and checking whether the execution time has exceeded the limit include: The first FPGA and the second FPGA respectively initialize the execution sequence state machine, and preset the legal state sequence of the execution sequence state machine and the transition conditions between each state; The first FPGA and the second FPGA respectively execute the following monitoring process cyclically: Obtain the corresponding CPU output status signals and parse the current task status; verify whether the current task status is a valid status in the valid status sequence, and trigger security processing if invalid; verify whether the next task status is consistent with the next status in the preset status sequence of the current task status in the valid status sequence, and trigger security processing if inconsistent; check whether the execution time of the current task exceeds the preset period time, and trigger security processing if timeout occurs; if all three verifications pass, update the internal status and continue the loop monitoring.

[0015] In one possible implementation, the time synchronization via a hardware clock includes: The first CPU and the second CPU synchronize their time using a hardware clock. At the start time of the first security level task, the first CPU and the second CPU respectively record the current timestamp and compare whether the timestamp deviation between the two CPUs is within the preset deviation threshold range. During the execution of the first security level task, the first CPU and the second CPU periodically exchange their current timestamps at preset time intervals and compare whether the timestamp deviation is within the preset deviation threshold range. At the end of the first security level task, the first CPU and the second CPU respectively record the timestamp when the task is completed, and compare whether the difference between the timestamps of the two CPUs is within the preset deviation threshold. If the result of any timestamp comparison exceeds the preset deviation threshold range, a security process is triggered.

[0016] In one possible implementation, statistical monitoring is employed, and the monitoring of key event sequences includes: The first FPGA and the second FPGA respectively establish event-based monitoring models; In the event-based monitoring model, the key event sequence and abnormal event types for the second security level task are defined; The first FPGA and the second FPGA respectively monitor in real time whether the abnormal event type occurs during the execution of the second security level task on their respective CPUs; Within a preset statistical period, the number or proportion of events of the aforementioned abnormal event type is counted. If the number or proportion does not exceed the preset anomaly tolerance threshold, the second security level task is allowed to continue execution; If the number or proportion exceeds the preset anomaly tolerance threshold, a fault indication is generated.

[0017] In one possible implementation, the secure operating system also monitors the execution status of each task and implements fault isolation; The security operating system acquires the fault indications generated by the first FPGA and the second FPGA, and determines the security level of the task that has failed based on the fault indications; If the fault indication is triggered by the first security level task, the security operating system isolates the first security level task from the second security level task through the time window and the memory region, and prevents the fault of the first security level task from spreading to the second security level task. If the fault indication is triggered by the second security level task, the security operating system isolates the second security level task from the first security level task through the time window and the memory area, and prevents the fault of the second security level task from spreading to the first security level task. The secure operating system also records the fault information corresponding to the fault indication and generates a fault log.

[0018] The multi-task hierarchical synchronization and sequential monitoring method based on dual-mode CPU provided in this application has the following technical effects: (1) Differentiated synchronization optimizes system performance while ensuring security. This invention employs different synchronization strategies for tasks at the first and second security levels. Tasks at the first security level transmit GPIO signals through an isolated channel and synchronize their time via a hardware clock, achieving precise synchronization between the dual-mode CPUs and meeting the stringent synchronization accuracy requirements of high-security-level tasks. Tasks at the second security level are placed in a blocked state and stop polling, only being woken up to execute when an interrupt is triggered, thus avoiding the ineffective occupation of CPU resources by low-security-level tasks. Through the above differentiated synchronization mechanism, the real-time performance and reliability of high-security-level tasks are guaranteed, while low-security-level tasks do not consume excessive system resources, thereby optimizing the overall system performance.

[0019] (2) Refined monitoring to achieve optimal allocation of monitoring resources. For tasks of the first security level, this invention establishes an execution sequence state machine, verifies the legality of state transitions based on the state completion signals sent when each task is completed, and checks whether the execution time exceeds the limit, thus achieving strict monitoring of the execution sequence and execution time of high-security-level tasks. For tasks of the second security level, statistical monitoring is adopted to monitor the sequence of key events, allowing a certain degree of sequence anomalies. The above differentiated monitoring strategies enable high-security-level tasks to obtain strict execution sequence and timing guarantees, while low-security-level tasks only need to monitor key events, allowing for reasonable allocation of monitoring resources and achieving a balance between monitoring accuracy and system resource overhead.

[0020] (3) Efficient resource utilization to ensure that high-security-level tasks receive priority resource guarantees. This invention allocates non-overlapping execution time windows and independent memory regions to first-security-level tasks and second-security-level tasks through a secure operating system. Time partitioning and space partitioning ensure that high-security-level tasks have independent execution time and memory space during runtime and are not affected by resource contention from low-security-level tasks. At the same time, low-security-level tasks can utilize the idle time windows and memory resources of high-security-level tasks, thereby achieving efficient utilization of system resources.

[0021] (4) Fault isolation to prevent failures of low-security-level tasks from affecting high-security-level tasks. When the FPGA generates a fault indication, the security operating system isolates the first or second security-level task that has failed from another security-level task through a time window and memory area. This restricts the faulty task to its own security-level partition and prevents it from affecting the execution of other security-level tasks through shared resources. This prevents the fault from spreading across security levels and ensures the high-reliability operation of high-security-level tasks. Attached Figure Description

[0022] Figure 1This is a schematic diagram of the architecture of the multi-task hierarchical synchronization and sequential monitoring method based on dual-mode CPU provided in an embodiment of the present invention; Figure 2 A flowchart of a multi-task hierarchical synchronization and sequential monitoring method based on a dual-mode CPU provided in an embodiment of the present invention; Figure 3 A diagram illustrating a high-priority task synchronization mechanism provided in an embodiment of the present invention; Figure 4 This is a diagram illustrating a low-priority task synchronization mechanism provided in an embodiment of the present invention. Figure 5 A diagram illustrating the high-priority task sequence monitoring mechanism provided in this embodiment of the invention. Detailed Implementation

[0023] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0024] The technical solution of this application will be further described in detail below with reference to the accompanying drawings and embodiments.

[0025] Figure 1 This is a schematic diagram of the architecture of a multi-task hierarchical synchronization and sequence monitoring method based on a dual-mode CPU provided in an embodiment of the present invention. Figure 1 As shown, the system adopts a single-board dual-mode CPU architecture, mainly including a first CPU (CPU Module A), a second CPU (CPU Module B), a first FPGA (FPGA Module A), a second FPGA (FPGA Module B), and a security operating system. The security operating system is located in... Figure 1 Not shown in the diagram, it runs on the first CPU and the second CPU.

[0026] The first CPU and the first FPGA are connected via an EMIF bus, and the second CPU and the second FPGA are connected via an EMIF bus. An isolation channel is provided between the first FPGA and the second FPGA to achieve electrical isolation between the two CPU channels, ensuring that a failure in one channel will not propagate to the other channel.

[0027] The first CPU and the second CPU are redundant and run the same program. The program contains multiple tasks with preset security levels, including first-level security tasks such as data reception, logical calculation, data transmission, and self-test, and second-level security tasks such as fault log recording.

[0028] The first and second FPGAs in this invention serve dual functions. On the one hand, they act as signal pass-through channels to realize transparent transmission of GPIO signals between the two CPUs for task-level synchronization of the dual-mode CPUs. On the other hand, they act as independent hardware monitoring circuits to monitor the execution order of each task on the CPU in real time.

[0029] The system's signal flow is as follows: During task execution, the first and second CPUs interact via their respective GPIO pins through the FPGA and isolation channels to achieve task-level synchronization and output status signals. The first and second FPGAs respectively acquire the status signals output by their respective CPUs and monitor the execution sequence using differentiated monitoring strategies based on the task's preset security level. When an anomaly is detected, the FPGA generates a fault indication, and the security operating system implements fault isolation through time and space partitioning based on the fault indication. The isolation channel can be implemented using any of the following methods: optical isolation, magnetic isolation, or capacitive isolation, to prevent electrical faults in one channel from propagating to another channel through the connections between FPGAs.

[0030] The voltage and current monitoring circuit and the temperature monitoring circuit are used to monitor the power supply status and chip temperature during system operation, respectively. When the voltage, current, or temperature exceeds the preset threshold, an abnormal state is reported to the CPU, triggering system safety processing. The power supply circuit provides operating voltage to the first CPU, the second CPU, the first FPGA, the second FPGA, and various peripheral circuits.

[0031] In addition, the system also includes various peripheral circuits connected to the CPU, such as Figure 1 As shown, the system includes a driver circuit, GPIO interface, Flash memory, SPI interface, I2C interface, temperature monitoring circuit, voltage and current monitoring circuit, power supply circuit, CANFD interface, debug interface (i.e., UART interface), and Ethernet conversion chip. The driver circuit provides sufficient driving capability for external loads; the GPIO interface connects to external switching signals; the Flash memory stores program code and system configuration parameters; the SPI and I2C interfaces connect to external sensors or expansion devices; the CANFD interface communicates with the train control network; the Ethernet conversion chip converts Ethernet communication protocols; and the debug interface is used for program downloading and online debugging during system development.

[0032] Figure 2 The flowchart of the multi-task hierarchical synchronization and sequence monitoring method based on dual-mode CPU provided in the embodiments of the present invention is as follows: Figure 2 As shown, the method includes the following steps: Step 210: When executing tasks, the first CPU and the second CPU synchronize the tasks according to the preset security level of the tasks and output status signals. Specifically, for tasks of the first security level, synchronization is achieved by passing GPIO signals through an isolation channel and by time synchronization through a hardware clock; for tasks of the second security level, they are placed in a blocked state to stop polling and are woken up when an interrupt is triggered.

[0033] The first security level tasks include data receiving, logical calculation, data sending, and self-testing. The data receiving task has a priority of 1 and an execution cycle of 10ms; it receives external input data. The logical calculation task has a priority of 2 and an execution cycle of 10ms; it performs logical operations on the input data received by the data receiving task. The data sending task has a priority of 3 and an execution cycle of 10ms; it sends the calculation results of the logical calculation task to external devices. The self-testing task has a priority of 4 and an execution cycle of 100ms; it performs periodic self-tests on the system's operating status. Lower priority values ​​indicate higher priority. The secure operating system schedules the data receiving, logical calculation, data sending, and self-testing tasks in descending order of priority.

[0034] The second security level task is the fault logging task. This task has a priority of 10 and an execution cycle of 1000ms. It records fault information that occurs during system operation. After starting execution, the fault logging task calls the event wait function of the secure operating system, enters a blocked state, and stops polling CPU resources. The fault logging task waits for events triggered by high-priority tasks or interrupt service routines; these events are either fault occurrence events or log write request events. When a fault occurrence event or log write request event is triggered, the secure operating system wakes up the fault logging task. After being woken up, the fault logging task performs log recording processing, writing the fault information to the log. After log recording processing is complete, the fault logging task calls the event wait function again and re-enters the blocked state.

[0035] Step 220: The first FPGA and the second FPGA respectively acquire the corresponding status signals and monitor the execution order of each task according to the preset security level and the monitoring strategy. The monitoring strategy includes: for tasks of the first security level, establishing an execution order state machine, verifying the legality of the state transition based on the status completion signal sent when each task is completed, and checking whether the execution time exceeds the limit. If the state transition is illegal or exceeds the time limit, a fault indication is generated; for tasks of the second security level, statistical monitoring is adopted to monitor the sequence of key events.

[0036] The specific process of synchronizing via GPIO signals through an isolation channel is as follows: The first CPU outputs logic 1 simultaneously with the second CPU through its GPIOB_6 pin via the isolation channel between the first and second FPGAs; the first CPU reads the logic 1 fed back by the second CPU through its GPIOB_7 pin via the isolation channel, and the second CPU reads the logic 1 fed back by the first CPU through its GPIOB_7 pin via the isolation channel; if the reading is successful, the first CPU and the second CPU simultaneously output logic 0 through their respective GPIOB_6 pins and read the logic 0 fed back by the other CPU through their respective GPIOB_7 pins; if the feedback value read after the first CPU or the second CPU writes logic 1 is not logic 1, or the feedback value read after writing logic 0 is not logic 0, then a safety process is triggered.

[0037] For tasks at the first security level, an execution sequence state machine is established. The specific process for verifying the legality of state transitions and checking whether the execution time has exceeded the limit, based on the status completion signals sent when each task is completed, is as follows: The first FPGA and the second FPGA initialize the execution sequence state machine respectively, and preset the legal state sequence of the execution sequence state machine and the transition conditions between each state; The first FPGA and the second FPGA respectively execute the following monitoring process in a loop: Obtain the status signal output by their respective CPUs and parse the current task status; Verify whether the current task status is a legal state in the legal state sequence. If it is illegal, trigger security processing; Verify whether the next task status is consistent with the next state in the preset state sequence of the current task status in the legal state sequence. If they are inconsistent, trigger security processing; Check whether the execution time of the current task exceeds the preset period time. If it exceeds the time limit, trigger security processing; If all three verifications pass, update the internal state and continue the loop monitoring.

[0038] The specific process of time synchronization using a hardware clock is as follows: The first CPU and the second CPU synchronize their times using a hardware clock; at the start of the first security level task, the first CPU and the second CPU record their current timestamps respectively, and compare whether the timestamp deviation between the two CPUs is within a preset deviation threshold range; during the execution of the first security level task, the first CPU and the second CPU periodically exchange their current timestamps at preset time intervals, and compare whether the timestamp deviation is within a preset deviation threshold range; at the end of the first security level task, the first CPU and the second CPU record the timestamp when the task is completed respectively, and compare whether the timestamp deviation between the two CPUs is within a preset deviation threshold range; if the result of any timestamp comparison exceeds the preset deviation threshold range, security processing is triggered.

[0039] The specific process of using statistical monitoring to monitor the key event sequence is as follows: The first and second FPGAs respectively establish event-based monitoring models; in the event-based monitoring models, the key event sequence and abnormal event types of the second security level task are defined; the first and second FPGAs respectively monitor in real time whether abnormal event types occur during the execution of the second security level task on their respective CPUs; within a preset statistical period, the number or proportion of abnormal event types is counted; if the number or proportion does not exceed a preset anomaly tolerance threshold, the second security level task is allowed to continue execution; if the number or proportion exceeds the preset anomaly tolerance threshold, security processing is triggered.

[0040] The event-based monitoring model is event-driven, statistically monitoring the execution process of tasks at the second security level by defining key event sequences and abnormal event types. Abnormal event types include task execution timeouts, abnormal task output data, and repeated task execution. The preset statistical period can be set to 1000ms, and the anomaly tolerance threshold can be set to 3 times or 5%, meaning that security processing is triggered when more than 3 abnormal events occur within 1000ms or the anomaly rate exceeds 5%.

[0041] Figure 3 This is a diagram illustrating a high-priority task synchronization mechanism provided in an embodiment of the present invention. (See diagram for example.) Figure 3 As shown, the synchronization of the first security level task is achieved through a pair of GPIO pins between the two CPUs, with the first FPGA and the second FPGA serving as a transparent transmission channel. The specific synchronization process is as follows: The first CPU and the second CPU simultaneously output logic 1 through their respective GPIOB_6 pins. The GPIOB_6 signal of the first CPU is transmitted to the GPIOB_6 pin of the second CPU via the first FPGA, the isolation channel, and the second FPGA; the GPIOB_6 signal of the second CPU is transmitted to the GPIOB_6 pin of the first CPU via the second FPGA, the isolation channel, and the first FPGA. Simultaneously, the first CPU reads the logic 1 fed back by the second CPU through its GPIOB_7 pin via the isolation channel, and the second CPU reads the logic 1 fed back by the first CPU through its GPIOB_7 pin via the isolation channel.

[0042] If both CPUs successfully read a logic 1, then both CPUs simultaneously output a logic 0 through their respective GPIOB_6 pins and read the logic 0 fed back by the other CPU through their respective GPIOB_7 pins. If the read feedback values ​​are both logic 0, then synchronization is confirmed to be successful.

[0043] If the feedback value read by the first CPU or the second CPU after writing logic 1 is not logic 1, or the feedback value read after writing logic 0 is not logic 0, then synchronization is determined to have failed, the system triggers safety processing, and is directed to a fault-safe state.

[0044] The first level of security also achieves microsecond-level time synchronization through a hardware clock. At the start, during, and end of the task, the two CPUs perform status checks and data comparisons to ensure that the task execution progress on both CPUs remains consistent.

[0045] Figure 4 This is a diagram illustrating a low-priority task synchronization mechanism provided in an embodiment of the present invention. (See diagram for example.) Figure 4 As shown, the second security level task, i.e., the low security level task, such as the fault log recording task, adopts an event-triggered passive synchronization mechanism. The specific process is as follows: After the second-priority task begins execution, it calls the event wait function of the secure operating system, such as the osEventFlagsWait function, and enters a blocked state. In the blocked state, the second-priority task stops polling and occupying CPU resources, does not consume CPU processing time, and thus yields CPU resources to higher-priority tasks.

[0046] The second-level security task waits in a blocked state for events triggered by higher-priority tasks or interrupt service routines. When an event requiring logging occurs during the execution of a higher-priority task, such as a fault occurrence or a log write request event, the higher-priority task or interrupt service routine triggers the corresponding event flag.

[0047] When an event is triggered, the security operating system wakes up the second security level task, which exits the blocked state, performs log recording processing, and writes the fault information into the log.

[0048] After the log recording process is complete, the second security level task calls the event waiting function again, re-enters the blocked state, and waits for the next event to be triggered. Through this mechanism, the second security level task is only awakened and executed when an event occurs, avoiding invalid polling operations and improving the overall resource utilization efficiency of the system.

[0049] Figure 5 A diagram illustrating a high-priority task sequence monitoring mechanism provided in an embodiment of the present invention. (See diagram for example.) Figure 5 As shown, the first FPGA and the second FPGA respectively perform cyclic monitoring of the execution order of the first security level tasks on their respective CPUs. The specific monitoring process is as follows: First, during system initialization, the first and second FPGAs initialize and execute sequential state machines, respectively, pre-setting a valid state sequence and transition conditions between each state. In this embodiment, the pre-set state sequence is: Idle (idle state), Data_Recv (data receiving task), Logic_Calc (logic calculation task), Data_Send (data sending task), and Self_Check (self-check task), then returns to the Idle state.

[0050] The monitoring module enters a cyclic monitoring process: the FPGA acquires the status signals output by its corresponding CPU and parses the current task status. The FPGA first verifies whether the current task status is a valid state in the valid state sequence. If the current task status is invalid, it immediately triggers safety processing and guides the system to a fault-safe state.

[0051] If the current task state is valid, the FPGA further verifies whether the next task state is consistent with the successor state of the current task state in the valid state sequence. If they are inconsistent, for example, jumping directly from Data_Recv to Data_Send and skipping Logic_Calc, it indicates that the task execution order is abnormal and triggers security processing.

[0052] The FPGA also checks timing constraints to confirm whether the execution time of each task exceeds a preset period, such as whether the execution time of the data reception task exceeds a 10ms period. If the execution time of any task exceeds its preset period, a safety procedure is triggered.

[0053] If the current task status is valid, the next task status is consistent with the successor status, and the execution time does not exceed the limit, all three verifications pass. The FPGA then updates its internal state and continues the next round of cyclic monitoring. Through this cyclic monitoring process, the FPGA can detect abnormal execution order and execution timeouts of the first-level security tasks in real time, ensuring that the first-level security tasks are executed reliably according to the preset order and timing constraints.

[0054] Step 230: The security operating system allocates non-overlapping execution time windows and independent memory regions to the first security level task and the second security level task, thus isolating the first security level task and the second security level task in time and space. When a fault indication is received, the security operating system isolates the faulty first security level task or second security level task from the other security level task through the aforementioned time windows and memory regions.

[0055] Furthermore, the secure operating system monitors the execution status of each task and implements fault isolation. The secure operating system acquires fault indications generated by the first and second FPGAs and determines the security level of the faulty task based on these indications. If the fault indication is triggered by a first-security-level task, the secure operating system isolates the first-security-level task from the second-security-level task using a time window and memory region, preventing the fault in the first-security-level task from propagating to the second-security-level task. If the fault indication is triggered by a second-security-level task, the secure operating system isolates the second-security-level task from the first-security-level task using a time window and memory region, preventing the fault in the second-security-level task from propagating to the first-security-level task. The secure operating system also records the fault information corresponding to the fault indications and generates a fault log.

[0056] Furthermore, the secure operating system also controls data exchange between tasks of different security levels through a communication management module, preventing low-security-level tasks from sending illegal or excessive data to high-security-level tasks.

[0057] The secure operating system also monitors the execution status of each task through a health management module, including whether the task executes according to the expected cycle, and whether there are any abnormal exits or prolonged blockages. When the health management module detects an abnormal execution status for any task, it implements fault isolation based on the fault indication, isolating the security level of the abnormal task from another security level to prevent the fault from spreading.

[0058] The multi-task hierarchical synchronization and sequential monitoring method based on dual-mode CPU provided in this application has the following technical effects: (1) Differentiated synchronization optimizes system performance while ensuring security. This invention employs different synchronization strategies for tasks at the first and second security levels. Tasks at the first security level transmit GPIO signals through an isolated channel and synchronize their time via a hardware clock, achieving precise synchronization between the dual-mode CPUs and meeting the stringent synchronization accuracy requirements of high-security-level tasks. Tasks at the second security level are placed in a blocked state and stop polling, only being woken up to execute when an interrupt is triggered, thus avoiding the ineffective occupation of CPU resources by low-security-level tasks. Through the above differentiated synchronization mechanism, the real-time performance and reliability of high-security-level tasks are guaranteed, while low-security-level tasks do not consume excessive system resources, thereby optimizing the overall system performance.

[0059] (2) Refined monitoring to achieve optimal allocation of monitoring resources. For tasks of the first security level, this invention establishes an execution sequence state machine, verifies the legality of state transitions based on the state completion signals sent when each task is completed, and checks whether the execution time exceeds the limit, thus achieving strict monitoring of the execution sequence and execution time of high-security-level tasks. For tasks of the second security level, statistical monitoring is adopted to monitor the sequence of key events, allowing a certain degree of sequence anomalies. The above differentiated monitoring strategies enable high-security-level tasks to obtain strict execution sequence and timing guarantees, while low-security-level tasks only need to monitor key events, allowing for reasonable allocation of monitoring resources and achieving a balance between monitoring accuracy and system resource overhead.

[0060] (3) Efficient resource utilization to ensure that high-security-level tasks receive priority resource guarantees. This invention allocates non-overlapping execution time windows and independent memory regions to first-security-level tasks and second-security-level tasks through a secure operating system. Time partitioning and space partitioning ensure that high-security-level tasks have independent execution time and memory space during runtime and are not affected by resource contention from low-security-level tasks. At the same time, low-security-level tasks can utilize the idle time windows and memory resources of high-security-level tasks, thereby achieving efficient utilization of system resources.

[0061] (4) Fault isolation to prevent failures of low-security-level tasks from affecting high-security-level tasks. When the FPGA generates a fault indication, the security operating system isolates the first or second security-level task that has failed from another security-level task through a time window and memory area. This restricts the faulty task to its own security-level partition and prevents it from affecting the execution of other security-level tasks through shared resources. This prevents the fault from spreading across security levels and ensures the high-reliability operation of high-security-level tasks.

[0062] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0063] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented in hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.

[0064] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of this application. It should be understood that the above description is only a specific embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.

Claims

1. A multi-task hierarchical synchronization and sequential monitoring method based on a dual-mode CPU, applied to a secure computer system, comprising a first CPU and a second CPU that redundantly run the same program, a first FPGA and a second FPGA isolated by an isolation channel, and a secure operating system, characterized in that, The method includes: When the first CPU and the second CPU execute tasks, they synchronize the tasks according to the preset security level of the tasks and output status signals. The synchronization includes: for tasks of the first security level, synchronization is performed by passing through GPIO signals through an isolation channel and by time synchronization through a hardware clock; for tasks of the second security level, they are placed in a blocked state to stop polling and are woken up when an interrupt is triggered. The first FPGA and the second FPGA respectively acquire the corresponding status signals and monitor the execution order of each task according to the preset security level and the monitoring strategy. The monitoring strategy includes: for the first security level task, establishing an execution order state machine, verifying the legality of the state transition according to the status completion signal sent when each task is completed and checking whether the execution time exceeds the time limit. If the state transition is illegal or exceeds the time limit, a fault indication is generated. For the second security level task, statistical monitoring is adopted to monitor the sequence of key events. The security operating system allocates non-overlapping execution time windows and independent memory regions for the first security level task and the second security level task, thereby isolating the first security level task and the second security level task in time and space. When the fault indication is received, the security operating system isolates the faulty first security level task or second security level task from the other security level task through the time window and the memory region.

2. The method according to claim 1, characterized in that, The first CPU is connected to the first FPGA via an EMIF, and the second CPU is connected to the second FPGA via an EMIF. An isolation channel is provided between the first FPGA and the second FPGA; The GPIO signals of the first CPU are transmitted to the second CPU via the first FPGA, the isolation channel, and the second FPGA; the GPIO signals of the second CPU are transmitted to the first CPU via the second FPGA, the isolation channel, and the first FPGA.

3. The method according to claim 1, characterized in that, The first security level task includes a data receiving task, a logical calculation task, a data sending task, and a self-test task; The data receiving task has a priority of 1 and an execution period of 10ms; it is used to receive external input data. The logical calculation task has a priority of 2 and an execution period of 10ms. It is used to perform logical operations on the input data received by the data receiving task. The data sending task has a priority of 3 and an execution period of 10ms. It is used to send the calculation results of the logical calculation task to an external device. The self-check task has a priority of 4 and an execution cycle of 100ms. It is used to perform periodic self-checks on the system's operating status. The smaller the priority value, the higher the priority. The data receiving task, the logic calculation task, the data sending task, and the self-test task are scheduled to be executed by the security operating system in descending order of priority.

4. The method according to claim 1, characterized in that, The second security level task is the fault log recording task; The fault log recording task has a running priority of 10 and an execution period of 1000ms. It is used to record fault information that occurs during system operation. After the fault log recording task begins execution, the event wait function of the security operating system is called to enter a blocked state and stop polling and occupying CPU resources. The fault log records events where a task waits for a high-priority task or an interrupt service program to trigger the event, which is either a fault occurrence event or a log write request event. When the fault occurrence event or the log write request event is triggered, the security operating system wakes up the fault log recording task; After being awakened, the fault log recording task performs log recording processing and writes the fault information into the log. After the log recording process is completed, the fault log recording task calls the event waiting function again and re-enters the blocked state.

5. The method according to claim 1, characterized in that, The step of placing the second security level task into a blocked state to stop polling and waking it up when an interrupt is triggered includes: After the second security level task begins execution, the event wait function of the security operating system is called, and the system enters a blocked state. In the blocked state, the second security level task stops polling and occupying CPU resources and waits for events triggered by high-priority tasks or interrupt service routines. When the event is triggered, the security operating system wakes up the second security level task, and the second security level task performs log recording processing; After the log recording is completed, the second security level task calls the event waiting function again and enters the blocked state.

6. The method according to claim 1, characterized in that, The synchronization via transparent GPIO signals through an isolation channel includes: The first CPU outputs logic 1 simultaneously with the second CPU through its GPIOB_6 pin, via the isolation channel between the first FPGA and the second FPGA; The first CPU reads the logic 1 fed back by the second CPU through its GPIOB_7 pin and the isolation channel, and the second CPU reads the logic 1 fed back by the first CPU through its GPIOB_7 pin and the isolation channel. If the read is successful, the first CPU and the second CPU will simultaneously output logic 0 through their respective GPIOB_6 pins and read the logic 0 fed back by the other CPU through their respective GPIOB_7 pins. If the feedback value read after the first CPU or the second CPU writes logic 1 is not logic 1, or the feedback value read after writing logic 0 is not logic 0, then a security process is triggered.

7. The method according to claim 1, characterized in that, For tasks at the first security level, establishing an execution sequence state machine, verifying the legality of state transitions based on the state completion signals sent upon completion of each task, and checking whether the execution time has exceeded the limit include: The first FPGA and the second FPGA respectively initialize the execution sequence state machine, and preset the legal state sequence of the execution sequence state machine and the transition conditions between each state; The first FPGA and the second FPGA respectively execute the following monitoring process cyclically: Obtain the corresponding CPU output status signals and parse the current task status; verify whether the current task status is a valid status in the valid status sequence, and trigger security processing if invalid; verify whether the next task status is consistent with the next status in the preset status sequence of the current task status in the valid status sequence, and trigger security processing if inconsistent; check whether the execution time of the current task exceeds the preset period time, and trigger security processing if timeout occurs; if all three verifications pass, update the internal status and continue the loop monitoring.

8. The method according to claim 1, characterized in that, The time synchronization via hardware clock includes: The first CPU and the second CPU synchronize their time using a hardware clock. At the start time of the first security level task, the first CPU and the second CPU respectively record the current timestamp and compare whether the timestamp deviation between the two CPUs is within the preset deviation threshold range. During the execution of the first security level task, the first CPU and the second CPU periodically exchange their current timestamps at preset time intervals and compare whether the timestamp deviation is within the preset deviation threshold range. At the end of the first security level task, the first CPU and the second CPU respectively record the timestamp when the task is completed, and compare whether the difference between the timestamps of the two CPUs is within the preset deviation threshold. If the result of any timestamp comparison exceeds the preset deviation threshold range, a security process is triggered.

9. The method according to claim 1, characterized in that, The statistical monitoring employed monitors key event sequences, including: The first FPGA and the second FPGA respectively establish event-based monitoring models; In the event-based monitoring model, the key event sequence and abnormal event types for the second security level task are defined; The first FPGA and the second FPGA respectively monitor in real time whether the abnormal event type occurs during the execution of the second security level task on their respective CPUs; Within a preset statistical period, the number or proportion of events of the aforementioned abnormal event type is counted. If the number or proportion does not exceed the preset anomaly tolerance threshold, the second security level task is allowed to continue execution; If the number or proportion exceeds the preset anomaly tolerance threshold, a fault indication is generated.

10. The method according to claim 1, characterized in that, The secure operating system also monitors the execution status of each task and implements fault isolation; The security operating system acquires the fault indications generated by the first FPGA and the second FPGA, and determines the security level of the task that has failed based on the fault indications; If the fault indication is triggered by the first security level task, the security operating system isolates the first security level task from the second security level task through the time window and the memory region to prevent the fault of the first security level task from spreading to the second security level task. If the fault indication is triggered by the second security level task, the security operating system isolates the second security level task from the first security level task through the time window and the memory area to prevent the fault of the second security level task from spreading to the first security level task. The secure operating system also records the fault information corresponding to the fault indication and generates a fault log.