A concurrent processing method based on a named pipe FIFO and an epoll model

CN122554409APending Publication Date: 2026-08-1158TH RES INST OF CETC
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-30
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

[0006]本发明的目的在于提供一种基于命名管道FIFO及epoll模型的并发处理方法,以解决epoll模型中频繁增加或删除文件描述符的问题,减少了业务逻辑复杂性

Benefits of technology

(1)减少业务逻辑复杂度。以tcp连接为例,建立tcp连接保持跟传统方式一致,不需要考虑增加socket至epfd中;断开tcp链接时,也跟传统方式一致,不需要考虑从epfd中删除socket。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122554409A_ABST
    Figure CN122554409A_ABST
Patent Text Reader

Abstract

This invention discloses a concurrent processing method based on named pipe FIFO and epoll models, belonging to the field of aerospace technology interaction. For dynamic descriptors monitored by the epoll model that can be frequently added or deleted, a system-level named pipe FIFO is used to replace the dynamic descriptors, reducing the operations of adding or deleting from the epoll model when opening or closing dynamic descriptors. The named pipe FIFO used in this invention has the following advantages: a first-in-first-out queue, which can act as a buffer and simulate the data flow order of each connection; the system supports customizable buffer size; it supports cross-process and cross-thread operations; it is highly operable, allowing write operations to be redirected and simulated in the shell, solving the problem of frequent addition or deletion of file descriptors in the epoll model and reducing the complexity of business logic.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of aerospace technology interaction technology, and in particular to a concurrent processing method based on named pipe FIFO and epoll model. Background Technology

[0002] The main control system on a spacecraft has functions such as interaction with the ground, relay, and storage. It can control the power-on or power-off of each sub-unit according to ground commands, forward remote control commands to each sub-unit, and also forward telemetry information from each sub-unit to the ground. The physical methods for connecting the main control system and the sub-units include serial ports, gigabit Ethernet, and CAN.

[0003] The main control system needs to interact with each extension unit and the ground display and control system in real time, using the Linux system epoll model for monitoring. The epoll model needs to monitor multiple file descriptors (file descriptors correspond to various serial ports and multiple sockets, which can locate specific extension units), and then receive data and forward or process it according to the address in the source or software protocol.

[0004] The file descriptors or monitored objects described above must always be in a connected state. If a branch office loses power, the corresponding monitored file descriptor in the epoll model must be deleted. If power is restored, the file descriptor corresponding to the branch office must be added back to the epoll model. This scenario is typically seen in TCP connections.

[0005] This frequent opening and closing of file descriptors, and the addition or deletion of files from the epoll model, complicates the business process. Summary of the Invention

[0006] The purpose of this invention is to provide a concurrent processing method based on named pipe FIFO and epoll model to solve the problem of frequent addition or deletion of file descriptors in the epoll model and reduce the complexity of business logic.

[0007] To address the aforementioned technical problems, this invention provides a concurrent processing method based on named pipe FIFO and epoll models, comprising: For dynamic descriptors that are monitored by the epoll model and can be frequently added or deleted, a system-level named pipe FIFO is used instead of dynamic descriptors to reduce the number of operations that need to be added to or deleted from the epoll model when the dynamic descriptor is turned on or off.

[0008] In one embodiment, the method includes the following steps: Step 1: Create an epoll model and enable monitoring. (1) Create the epoll model file descriptor epfd; (2) Open the file descriptors in the file system and add them to the epfd model one by one so that they can be monitored by the epfd model; (3) Open the existing named pipe FIFO in a read-write mode, add it to the epfd model, and make it monitored by the epfd model; (4) Establish dynamic descriptor connections and establish a one-to-one correspondence with the FIFO in step (3); determine the number of dynamic descriptor connections based on the traffic volume, and repeat step (4); (5) Execute the monitoring process and wait for read events to arrive; read them one by one and distribute them for processing. Step 2: Create an infinite loop read module thread; (1) After the dynamic descriptor connection is established, whenever the dynamic descriptor data stream is read, the data stream is written into the corresponding named pipe FIFO. The FIFO has been monitored by the epfd model. When the epfd model detects data in the FIFO, it is equivalent to detecting that data has arrived in the dynamic descriptor, and the data stream is read, parsed, and processed. (2) When a dynamic descriptor is closed actively or passively, it is closed after exiting the read operation of this dynamic descriptor without having to remove the FIFO corresponding to this dynamic descriptor from the epfd model.

[0009] The concurrent processing method based on named pipe FIFO and epoll model provided by this invention has the following beneficial effects: (1) Reduce business logic complexity. Taking TCP connection as an example, establishing TCP connection is consistent with the traditional method, and there is no need to consider adding socket to epfd; disconnecting TCP connection is also consistent with the traditional method, and there is no need to consider deleting socket from epfd.

[0010] (2) Layered modularization. Taking TCP connections as an example, in the traditional approach, the establishment and deletion of TCP connections require adding or deleting tcp_sockets from the epfd. In the new approach, the process of establishing and deleting TCP connections remains unchanged. The epfd and TCP processing modules are independent of each other and have low coupling. The connection between the two is achieved through an associated FIFO.

[0011] (3) Utilize the FIFO, a system-level supported FIFO, to replace the ordinary queue data structure. FIFO named pipes are system-level supported queue data structures. They have a name in the file system and can be opened and read / written like ordinary files. This allows FIFOs to be used for communication between different processes and threads. FIFOs can also be used as configuration channels and as a means of debugging programs. By modifying certain global variables in the program, program logic can be modified to achieve debugging purposes. Attached Figure Description

[0012] Figure 1 It is a traditional epoll model diagram.

[0013] Figure 2 This is a diagram of the improved FIFO-based epoll model.

[0014] Figure 3 This is a schematic diagram illustrating a specific practical application of the method of the present invention.

[0015] Among them, label 1 is a static descriptor, label 2 is a traditional monitoring tcp_socket module, label 3 is a configuration and debugging type FIFO module, label 4 is a FIFO module newly added in this invention patent, and label 5 is a dynamic descriptor write FIFO module. Detailed Implementation

[0016] The following detailed description, in conjunction with the accompanying drawings and specific embodiments, provides a further detailed explanation of the concurrent processing method based on named pipe FIFO and epoll models proposed in this invention. The advantages and features of this invention will become clearer from the following description. It should be noted that the accompanying drawings are all in a very simplified form and use non-precise scales, and are only used to facilitate and clarify the illustration of the embodiments of this invention.

[0017] First, let's define the two descriptions: Static descriptors: Descriptors that will not disconnect after being established, such as UDP connections, internal serial ports, CAN connections, etc.

[0018] Dynamic descriptors: These rely on physical connections or may experience disconnections, such as TCP connections or pluggable USB connections. Characteristics: The physical link may break and then reconnect.

[0019] The file descriptors mentioned below refer to readable file descriptors, or only focus on the readable characteristics of file descriptors.

[0020] This invention is aimed at such as Figure 1In the traditional epoll model, dynamically existing file descriptors, such as TCP connections and pluggable USB connections, can be replaced by a one-to-one named pipe FIFO. Figure 2 As shown, when new data arrives in a dynamic file descriptor, the monitoring thread reads the new data and forwards it to the corresponding FIFO. For static file descriptors, such as internal serial ports, UDP connections, and CAN connections, the epoll model can still monitor them. FIFOs can be used instead, or they can be left unmonitored. Figure 1 and Figure 2 In this context, the epfd module is the epoll monitoring module; the distribution module is the read parsing and processing module.

[0021] Detailed operation steps: 1. Create an epoll model and enable monitoring.

[0022] (1) Create the epoll model file descriptor epfd; (2) Open the static file descriptors and add them to epfd one by one so that they can be monitored by epfd; (3) Open the existing named pipe FIFO in a read-write mode, add it to epfd, and make it monitored by epfd; (4) Establish dynamic descriptor connections (such as TCP connections) and establish a one-to-one correspondence with the FIFO in step (3); determine the number of dynamic descriptor connections based on the traffic volume, and repeat step (4). (5) Execute the monitoring process and wait for read events to arrive; read them one by one and distribute them for processing.

[0023] 2. Create an infinite loop read module thread.

[0024] (1) After the dynamic descriptor connection is established, whenever a data stream from the dynamic descriptor is read, the data stream is written into the named pipe FIFO described above. The FIFO is monitored by epfd. When epfd detects that there is data in the FIFO, it is equivalent to detecting that data has arrived from the dynamic descriptor, and the data stream is read, parsed, and processed.

[0025] (2) When a dynamic descriptor is closed actively or passively, the read operation on this dynamic descriptor is exited before closing it. Compared with the traditional epfd monitoring process, closing a dynamic descriptor eliminates the need to delete the dynamic descriptor from the epfd. This invention also does not require deleting the named pipe FIFO corresponding to the dynamic descriptor from the epfd model.

[0026] This invention provides a concurrent processing method based on named pipe FIFO and epoll model. For dynamic descriptors monitored by the epoll model that can be frequently added or deleted, such as tcp_socket, it proposes to use system-level named pipe FIFO to replace dynamic descriptors. This reduces the number of operations that need to be added to or deleted from the epoll model when opening or closing dynamic descriptors, thereby reducing the coupling between modules and reducing the complexity of business logic.

[0027] like Figure 3 As shown, the specific operation steps are as follows: 1. Open all static descriptors in read-write mode and save them as a global variable array STATIC_FD.

[0028] 2. Dynamic file descriptor processing, taking TCP socket as an example. Based on business functions, determine the maximum number of TCP sockets to be connected, denoted as N. Open N FIFO_fds in read-write mode, denoted as a global variable array FIFO_FD. Each FIFO_fd corresponds to a TCP socket to be connected, establishing a one-to-one correspondence between the two using a structure.

[0029] 3. Create an epoll model file descriptor (epfd) and determine the maximum number of descriptors to be monitored. The maximum number includes the number of static descriptors and the number of FIFOs. The number of FIFOs is the same as the number of dynamic descriptors; there is a one-to-one correspondence between the two. Add the global variable arrays STATIC_FD from step 1 and FIFO_FD from step 2 to the epfd for monitoring, with the events field set to EPOLLIN.

[0030] 4. Configure and debug the CFG_FIFO processing flow. Refer to the static descriptor processing method and add it to epfd.

[0031] 5. Listening Module Thread. When an incoming request to establish a connection is detected, a `tcp_socket` is created and assigned to the `tcp_socket` with which the association was established in step 2. When a `tcp_socket` is detected to be disconnected, the associated `tcp_socket` is also deleted accordingly. The exit condition for the `tcp_socket` is that the socket read interface returns an exception or a connection break is detected, at which point the `tcp_socket` is closed. However, the listening module thread does not exit and waits for the `tcp_socket` to reconnect.

[0032] 6. Dynamic descriptor infinite loop read thread. This thread reads data from the tcp_socket in a non-blocking manner and writes the data stream into the named pipe FIFO_fd corresponding to step 2.

[0033] The named pipe FIFO used in this invention has the following advantages: it is a first-in-first-out queue that can be used as a buffer to simulate the data flow order of each connection; the buffer size supported by the system can be customized; it supports cross-process and cross-thread operations; it is highly operable and can redirect and simulate write operations in the shell.

[0034] The above description is merely a description of preferred embodiments of the present invention and is not intended to limit the scope of the present invention in any way. Any changes or modifications made by those skilled in the art based on the above disclosure shall fall within the protection scope of the claims.

Claims

1. A concurrent processing method based on named pipe FIFO and epoll model, characterized in that, include: For dynamic descriptors that are monitored by the epoll model and can be frequently added or deleted, a system-level named pipe FIFO is used instead of dynamic descriptors to reduce the number of operations that need to be added to or deleted from the epoll model when the dynamic descriptor is turned on or off.

2. The concurrent processing method based on the named pipe FIFO and the epoll model according to claim 1, wherein, The method includes the following steps: Step 1: Create an epoll model and enable monitoring. (1) Create the epoll model file descriptor epfd; (2) Open the static file descriptors in the file system and add them to the epfd model one by one so that they can be monitored by the epfd model; (3) Open the existing named pipe FIFO in a read-write mode, add it to the epfd model, and make it monitored by the epfd model; (4) Establish dynamic descriptor connections and establish a one-to-one correspondence with the FIFO in step (3); determine the number of dynamic descriptor connections based on the traffic volume, and repeat step (4); (5) Execute the monitoring process and wait for the read event to arrive; Read and distribute the data one by one; Step 2: Create an infinite loop read module thread; (1) After the dynamic descriptor connection is established, whenever the dynamic descriptor data stream is read, the data stream is written into the corresponding named pipe FIFO. The FIFO has been monitored by the epfd model. When the epfd model detects data in the FIFO, it is equivalent to detecting that data has arrived in the dynamic descriptor, and the data stream is read, parsed, and processed. (2) When a dynamic descriptor is closed actively or passively, it is closed after exiting the read operation of this dynamic descriptor without having to remove the FIFO corresponding to this dynamic descriptor from the epfd model.