Partition pseudo-interrupt implementation method based on shared storage domain
By using the shared storage domain to store pseudo-interrupt events in an embedded partition operating system, the problem that partitions cannot handle continuous pseudo-interrupt events when inactive state is solved, and the real-timeness of the system and the integrity of event processing are improved.
Patent Information
- Application Number
- CN202411773370.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-03-18
AI Technical Summary
In the partitioned operating system environment, pseudo-interrupt event information is easily lost because the partition cannot immediately handle pseudo-interrupt events triggered by continuously triggered external interrupts when the partition is inactive.
By initializing the pseudo-interruption mechanism in the core operating system, the shared storage domain space is allocated to store pseudo-interruption events, and when external interrupts occur, the event is stored in the shared storage area corresponding to the partition, reducing the switching between the user state and the system state.
It effectively reduces the number of switching between user state and system state, saves system overhead, improves the real-timeness of embedded partition operating systems, and avoids the loss of pseudo-interrupt events.
Smart Images

Figure CN119645704A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a partition pseudo interruption implementation method, in particular to a partition pseudo interruption implementation method based on a shared storage domain, belonging to the technical field of embedded system development. Background Art
[0002] Generally speaking, embedded partition operating systems are divided into three layers: the bottom layer is the core operating system, which runs in the system state and is used for partition-level management and scheduling; the second layer is the partition operating system, which runs in the user state and is used for process-level management and scheduling within the partition; the top layer is the application program, which runs on the partition operating system. This system architecture effectively ensures the independent security of programs and data between each partition.
[0003] In the prior art, a method for implementing a virtual interrupt standard component of a multi-partition operating system disclosed in publication number CN109542610A is provided, wherein the method formulates a standard virtual interrupt component specification and an implementation scheme, wherein the standard virtual interrupt component specification formulates system virtual interrupt division standards, division of subsystem virtual interrupt codes, formulation of virtual interrupt initialization standard interfaces, formulation of virtual interrupt registration interface processing specifications, and the like. The formulation scheme enables the virtual interrupt implementation scheme of a multi-partition operating system to have a unified standard and specification, and uniformly manages the virtual interrupt implementation mechanism of each subsystem, reduces the coupling between subsystems, and improves the independence and maintainability of the system. However, in a partition operating system environment, the partition application cannot directly perceive the external interrupt signal, and the pseudo interrupt mechanism provides synchronization between the system kernel and the partition with a soft interrupt function. Unlike a hardware interrupt, a pseudo interrupt cannot be processed immediately when an interrupt occurs, and the pseudo interrupt service program can only be triggered and executed during the running time of the partition to which it belongs, and will only be triggered once at the moment when the partition switches to restore the running state. Therefore, when multiple external interrupts are triggered continuously at the bottom layer within a certain period of time, and each external interrupt reports a pseudo-interrupt event to a partition, but the partition is not in an activated state due to the scheduling policy, this will cause the loss of pseudo-interrupt event information. To solve this problem, the kernel usually maintains an additional pseudo-interrupt event cache for each partition, and stores the pseudo-interrupt information in the cache device of the corresponding partition each time a pseudo-interrupt is sent. When the pseudo-interrupt service program in the partition is triggered, it needs to continuously read the events in the corresponding event cache of the partition through system calls, and perform specific processing on the read pseudo-interrupt information until the cache device of the partition is empty.
[0004] However, in this processing method, the pseudo-interrupt event is stored in the kernel. After the partition triggers the pseudo-interrupt, it is necessary to continuously obtain event information through system calls, which involves switching and access between user state and system state, and has a certain impact on the real-time performance of the system. Summary of the invention
[0005] The purpose of the present invention is to provide a partition pseudo-interrupt implementation method based on a shared storage domain in order to solve at least one of the above technical problems, store pseudo-interrupt events in the system shared storage domain, avoid frequent switching of partitions from user state to system state to obtain events, reduce the number of switching times between user state and system state, save system overhead, and improve the real-time performance of the embedded partition operating system.
[0006] The present invention achieves the above-mentioned purpose through the following technical scheme: a partition pseudo-interrupt implementation method based on a shared storage domain, the partition pseudo-interrupt implementation method comprising the following steps: S1. The core operating system initializes the pseudo-interrupt mechanism and allocates a shared storage domain space for storing pseudo-interrupt events. S2. When an external interrupt is triggered, the core operating system stores the corresponding pseudo interrupt event in the shared storage area corresponding to the partition, and sends a pseudo interrupt signal to the corresponding partition; S3, the partition registers a pseudo interrupt service program. When the partition pseudo interrupt is triggered to execute, the pseudo interrupt events are read from the shared storage area corresponding to the partition in sequence for processing until all pseudo interrupt events are processed.
[0007] As a further solution of the present invention: in S1, the initialization of the pseudo interrupt mechanism includes the following steps: S11, the core operating system allocates a shared storage domain space for storing pseudo interrupt events, divides the shared storage domain space into shared storage areas corresponding to each partition according to the event queue length set by the user, and maps the shared storage areas to the corresponding partitions; S12, in the shared storage area of each partition, allocating memory space of the pseudo interrupt event queue structure according to the event queue length set by the user, and setting the initial value of the memory space to zero; S13, initialize the event queue watchdog to detect whether the partition is in a fault state; S14, setting the pseudo interrupt lock flag in each partition information data structure to 1, indicating that the partition pseudo interrupt function is locked; S15. The event queue status flag in each partition information data structure is set to 0, and the event read index and event write index in the pseudo interrupt event queue structure are set to 0, indicating that the event queue is empty.
[0008] As a further solution of the present invention: in S11, the core operating system has read and write access rights to the entire shared storage domain space, and the partition only has read and write access rights to its own corresponding shared storage area and cannot access other spaces of the shared storage domain space.
[0009] As a further solution of the present invention: in S12, the pseudo-interrupt event queue structure includes an event read index, an event write index, an event watchdog, an event queue pointer, and an event queue length, and the event queue includes an event type and event parameters; wherein the event queue length can be set by the user as needed.
[0010] As a further solution of the present invention: in S14, the pseudo interrupt lock flag is reset according to the situation of each partition when the partition is running.
[0011] As a further solution of the present invention: in S2, sending a pseudo interrupt signal to the corresponding partition includes the following steps: S21, obtaining the partition ID of the pseudo interrupt event to be sent, and confirming that the partition ID is valid; S22, obtaining a pseudo interrupt event, writing the pseudo interrupt event into the event queue corresponding to the partition, and writing the pseudo interrupt event into an index plus 1; S23, the partition starts to execute in its time window, and determines whether the pseudo interrupt lock flag in the partition information data structure is 1. If it is 1, it means that the partition does not respond to this pseudo interrupt, otherwise execute S24; S24, the partition responds to the pseudo interrupt, executes the pseudo interrupt service program, reads the pseudo interrupt event and processes it.
[0012] As a further solution of the present invention: in S23, when the pseudo interrupt lock flag in the partition information data structure is 1, the partition does not respond to the pseudo interrupt, and waits until the pseudo interrupt lock flag of the partition is 0 to perform pseudo interrupt processing.
[0013] As a further solution of the present invention: in S24, when the pseudo-interrupt lock flag in the partition information data structure is 0, the pseudo-interrupt service program is executed, that is, the register information of the partition task control block is backed up to the partition interrupt stack, the register information of the partition task control block is modified, and the pc pointer in the partition task control block points to the pseudo-interrupt event handler corresponding to the event.
[0014] As a further solution of the present invention: in S3, reading the pseudo interrupt event includes the following steps: S31, fetching a pseudo interrupt event from the shared storage area corresponding to the partition, and adding 1 to the pseudo interrupt event reading index; S32, searching for a pseudo interrupt event processing program corresponding to the event type in a first-in-first-out order, and performing pseudo interrupt event processing; S33, traverse the event queue until all pseudo interrupt events are processed.
[0015] The beneficial effects of the present invention are: 1) The present invention initializes the pseudo-interrupt mechanism of the core operating system and allocates a shared storage domain space for storing pseudo-interrupt events; when an external interrupt is triggered, the corresponding pseudo-interrupt event is stored in the shared storage area corresponding to the partition, and a pseudo-interrupt signal is sent to the corresponding partition; the partition registers a pseudo-interrupt service program, and when the partition pseudo-interrupt is triggered and executed, the events are sequentially taken out from the shared storage area corresponding to the partition for processing until all events are processed; 2) Through this method, pseudo interrupt events are stored in the system shared storage domain, which can reduce the number of switching between user state and system state, save system overhead, and improve the real-time performance of the embedded partition operating system. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 It is a schematic diagram of the process flow of the method for implementing the present invention; Figure 2 This is a schematic diagram of the pseudo interrupt initialization process of the present invention; Figure 3 This is a schematic diagram of a pseudo interruption event of the present invention; Figure 4 A schematic diagram of a pseudo interrupt event sending process of the present invention; Figure 5 This is a schematic diagram of the pseudo interrupt event reading process of the present invention. DETAILED DESCRIPTION
[0017] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0018] Embodiment 1, as Figure 1 As shown, this embodiment provides a partition pseudo interruption implementation method based on a shared storage domain, and the partition pseudo interruption implementation method includes the following steps: S1. The core operating system initializes the pseudo-interrupt mechanism and allocates a shared storage domain space for storing pseudo-interrupt events. S2. When an external interrupt is triggered, the core operating system stores the corresponding pseudo interrupt event in the shared storage area corresponding to the partition and sends a pseudo interrupt signal to the corresponding partition; S3, the partition registers a pseudo interrupt service program. When the partition pseudo interrupt is triggered to execute, the pseudo interrupt events are read from the shared storage area corresponding to the partition in sequence for processing until all pseudo interrupt events are processed.
[0019] Embodiment 2: In addition to all the technical features of Embodiment 1, this embodiment also includes: Figure 2 As shown, in S1, the initialization of the pseudo interrupt mechanism includes the following steps: S11, the core operating system allocates a shared storage domain space for storing pseudo interrupt events, divides the shared storage domain space into shared storage areas corresponding to each partition according to the event queue length set by the user, and maps the shared storage areas to the corresponding partitions; S12, in the shared storage area of each partition, allocating memory space of the pseudo interrupt event queue structure according to the event queue length set by the user, and setting the initial value of the memory space to zero; S13, initialize the event queue watchdog to detect whether the partition is in a fault state; S14, setting the pseudo interrupt lock flag in each partition information data structure to 1, indicating that the partition pseudo interrupt function is locked; S15. The event queue status flag in each partition information data structure is set to 0, and the event read index and event write index in the pseudo interrupt event queue structure are set to 0, indicating that the event queue is empty.
[0020] In S11, the operating system has read and write access permissions to the entire shared storage domain space, and the partition only has read and write access permissions to its corresponding shared storage area and cannot access other spaces in the shared storage domain space.
[0021] like Figure 3 As shown, in S12, the pseudo interrupt event queue structure includes an event read index, an event write index, an event watchdog, an event queue pointer, and an event queue length. The event queue includes an event type and event parameters; wherein the event queue length can be set by the user as needed.
[0022] In S14, the pseudo interrupt lock flag is reset according to the partition's own situation when each partition is running.
[0023] like Figure 4 As shown, in S2, sending a pseudo interrupt signal to a corresponding partition includes the following steps: S21, obtaining the partition ID of the pseudo interrupt event to be sent, and confirming that the partition ID is valid; S22, obtaining a pseudo interrupt event, writing the pseudo interrupt event into the event queue corresponding to the partition, and writing the pseudo interrupt event into an index plus 1; S23, the partition starts to execute in its time window, and determines whether the pseudo interrupt lock flag in the partition information data structure is 1. If it is 1, it means that the partition does not respond to this pseudo interrupt, otherwise execute S24; S24, the partition responds to the pseudo interrupt, executes the pseudo interrupt service program, reads the pseudo interrupt event and processes it.
[0024] In S23, when the pseudo interrupt lock flag in the partition information data structure is 1, the partition does not respond to the pseudo interrupt, and waits until the pseudo interrupt lock flag of the partition is 0 to perform pseudo interrupt processing.
[0025] In S24, when the pseudo-interrupt lock flag in the partition information data structure is 0, the pseudo-interrupt service program is executed, that is, the register information of the partition task control block is backed up to the partition interrupt stack, the register information of the partition task control block is modified, and the pc pointer in the partition task control block points to the pseudo-interrupt event handler corresponding to the event.
[0026] like Figure 5 As shown, in S3, reading the pseudo interrupt event includes the following steps: S31, fetch and read the pseudo interrupt event from the shared storage area corresponding to the partition, and increase the pseudo interrupt event reading index by 1; S32, searching for a pseudo interrupt event processing program corresponding to the event type in a first-in-first-out order, and performing pseudo interrupt event processing; S33, traverse the event queue until all events are processed.
[0027] Working principle: The core operating system initializes the pseudo-interrupt event and allocates a shared storage domain space for storing pseudo-interrupt events; when an external interrupt is triggered, the core operating system stores the corresponding pseudo-interrupt event in the shared storage area corresponding to the partition and sends a pseudo-interrupt signal to the corresponding partition; the partition registers the pseudo-interrupt service program, and when the partition pseudo-interrupt is triggered and executed, the events are taken out from the shared storage area corresponding to the partition in sequence for processing until all events are processed.
[0028] It will be apparent to those skilled in the art that the invention is not limited to the details of the exemplary embodiments described above and that the invention can be implemented in other specific forms without departing from the spirit or essential features of the invention. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description, and it is intended that all variations falling within the meaning and scope of the equivalent elements of the claims be included in the invention. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.
[0029] In addition, it should be understood that although the present specification is described according to implementation modes, not every implementation mode contains only one independent technical solution. This description of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment may also be appropriately combined to form other implementation modes that can be understood by those skilled in the art.
Claims
1. A partition pseudo interruption implementation method based on a shared storage domain, characterized in that: The partition pseudo interruption implementation method comprises the following steps: S1. The core operating system initializes the pseudo-interrupt mechanism and allocates a shared storage domain space for storing pseudo-interrupt events. S2. When an external interrupt is triggered, the core operating system stores the corresponding pseudo interrupt event in the shared storage area corresponding to the partition, and sends a pseudo interrupt signal to the corresponding partition; S3, the partition registers a pseudo interrupt service program. When the partition pseudo interrupt is triggered to execute, the pseudo interrupt events are read from the shared storage area corresponding to the partition in sequence for processing until all pseudo interrupt events are processed.
2. The partition pseudo interruption implementation method according to claim 1, characterized in that: In S1, the pseudo interrupt mechanism initialization includes the following steps: S11, the core operating system allocates a shared storage domain space for storing pseudo interrupt events, divides the shared storage domain space into shared storage areas corresponding to each partition according to the event queue length set by the user, and maps the shared storage areas to the corresponding partitions; S12, in the shared storage area of each partition, allocating memory space of the pseudo interrupt event queue structure according to the event queue length set by the user, and setting the initial value of the memory space to zero; S13, initialize the event queue watchdog to detect whether the partition is in a fault state; S14, setting the pseudo interrupt lock flag in each partition information data structure to 1, indicating that the partition pseudo interrupt function is locked; S15. The event queue status flag in each partition information data structure is set to 0, and the event read index and event write index in the pseudo interrupt event queue structure are set to 0, indicating that the event queue is empty.
3. The partition pseudo interruption implementation method according to claim 2, characterized in that: In S11, the core operating system has read and write access rights to the entire shared storage domain space, and the partition only has read and write access rights to its corresponding shared storage area and cannot access other spaces in the shared storage domain space.
4. The partition pseudo interruption implementation method according to claim 2, characterized in that: In S12, the pseudo interrupt event queue structure includes an event read index, an event write index, an event watchdog, an event queue pointer, and an event queue length. The event queue includes an event type and event parameters; wherein the event queue length is set by the user as required.
5. The partition pseudo interruption implementation method according to claim 2, characterized in that: In S14, the pseudo interrupt lock flag is reset according to the situation of each partition when the partition is running.
6. The partition pseudo interruption implementation method according to claim 1, characterized in that: In S2, sending a pseudo interrupt signal to the corresponding partition includes the following steps: S21, obtaining the partition ID of the pseudo interrupt event to be sent, and confirming that the partition ID is valid; S22, obtaining a pseudo interrupt event, writing the pseudo interrupt event into the event queue corresponding to the partition, and writing the pseudo interrupt event into an index plus 1; S23, the partition starts to execute in its time window, and determines whether the pseudo interrupt lock flag in the partition information data structure is 1. If it is 1, it means that the partition does not respond to this pseudo interrupt, otherwise execute S24; S24, the partition responds to the pseudo interrupt, executes the pseudo interrupt service program, reads the pseudo interrupt event and processes it.
7. The partition pseudo interruption implementation method according to claim 6, characterized in that: In S23, when the pseudo interrupt lock flag in the partition information data structure is 1, the partition does not respond to the pseudo interrupt, and waits until the pseudo interrupt lock flag of the partition is 0 to perform pseudo interrupt processing.
8. The partition pseudo interruption implementation method according to claim 6, characterized in that: In S24, when the pseudo-interrupt lock flag in the partition information data structure is 0, the pseudo-interrupt service program is executed, that is, the register information of the partition task control block is backed up to the partition interrupt stack, the register information of the partition task control block is modified, and the pc pointer in the partition task control block points to the pseudo-interrupt event handler corresponding to the event.
9. The partition pseudo interruption implementation method according to claim 1, characterized in that: In S3, reading the pseudo interrupt event includes the following steps: S31, fetching a pseudo interrupt event from the shared storage area corresponding to the partition, and adding 1 to the pseudo interrupt event reading index; S32, searching for a pseudo interrupt event processing program corresponding to the event type in a first-in-first-out order, and performing pseudo interrupt event processing; S33, traverse the event queue until all pseudo interrupt events are processed.
Citation Information
Patent Citations
A method for implementing a virtual interrupt standard component of a multi-partition operating system
CN109542610A
Cited By
XDMA-based random trigger type data stream transmission method and device
CN120029950A