Data processing method based on epoll mechanism, vehicle machine, medium and product
By creating epoll objects and target threads in the microkernel system and obtaining event status through inter-process communication, the problem of implementing the epoll mechanism in the microkernel system is solved, and the system's ability to handle concurrent connections and I/O events is improved.
Patent Information
- Application Number
- CN202411980807.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-05-13
AI Technical Summary
In microkernel systems, how to effectively implement the epoll mechanism to improve I/O multiplexing performance and scalability.
Create function by calling epoll in the first program running in the microkernel system, create epoll objects and target threads, and add listening events to the epoll object through the epoll event registration function. The first program requests the second program to obtain the event status of the listening event through inter-process communication and decides whether to add the event to the ready queue of the epoll object. Finally, the epoll event wait function is used to determine whether there is a ready event in the ready queue and the target thread is processed.
Event processing under the epoll mechanism is implemented in the microkernel system, which significantly improves the ability to handle a large number of concurrent connections and I/O events.
Smart Images

Figure CN119988056A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a data processing method, a vehicle computer, a medium and a product based on an epoll mechanism. Background Art
[0002] The microkernel system minimizes the kernel functions and provides other service modules as external services. This design makes the microkernel more flexible, scalable and secure. In the operating system, I / O multiplexing is a basic and important function. I / O multiplexing can monitor multiple I / O events at the same time through a thread. Once an I / O event occurs, the thread will be awakened and process the corresponding I / O operation, which can avoid thread blocking and improve the concurrency and efficiency of the system.
[0003] In the related art, the epoll mechanism is an important I / O multiplexing mechanism in Linux. Compared with the traditional select mechanism and poll mechanism, epoll has better performance and scalability. Therefore, how to implement epoll in a microkernel system is a technical problem that needs to be solved urgently. Summary of the invention
[0004] The embodiment of the present invention provides a data processing method, a vehicle computer, a medium and a product based on the epoll mechanism.
[0005] In a first aspect, an embodiment of the present invention provides a data processing method based on an epoll mechanism, which is applied to a microkernel system, wherein the microkernel system includes a first program and a second program running in a user space, and the method includes:
[0006] The first program calls an epoll creation function to create an epoll object and a target thread for event monitoring in a process of the first program;
[0007] The first program adds N listening events to the epoll object through the epoll event registration function, where N is a positive integer;
[0008] The first program sends an inter-process communication request to the second program based on the file descriptor of each listening event, so as to request the event status of each listening event from the second program;
[0009] The first program determines whether to add each listening event to the ready queue in the epoll object based on the target event state of each listening event fed back by the second program;
[0010] The first program determines whether there is a ready event in the ready queue through an epoll event waiting function, and processes the target thread based on the determination result.
[0011] In some implementations, after the first program calls the epoll creation function and creates an epoll object in the process of the first program, the method further includes:
[0012] The first program associates a target address of a data structure of the epoll object with a file descriptor assigned to the epoll object.
[0013] In some implementations, the data structure of the epoll object includes a red-black tree, and the first program adds N listening events to the epoll object through an epoll event registration function, including:
[0014] The first program allocates a corresponding red-black tree node object to each listening event through an epoll event registration function, wherein, for each red-black tree node object, the red-black tree node object includes red-black tree node information associated with the red-black tree, a file descriptor of the listening event corresponding to the red-black tree node object, a pointer to the epoll object, and a listening event attribute, wherein the listening event attribute includes a listening event state set;
[0015] Insert each red-black tree node object into the red-black tree.
[0016] In some implementations, the first program sends an inter-process communication request to the second program based on the file descriptor of each listening event, including:
[0017] The first program generates the inter-process communication request based on the file descriptor of each monitored event, the monitored event status set, and the thread identifier of the target thread, and sends the inter-process communication request to the second program.
[0018] In some embodiments, the method further comprises:
[0019] After receiving the inter-process communication request, the second program creates a notification event object based on the inter-process communication request, wherein the notification event object includes a thread identifier of the target thread, a file descriptor of each listening event, and a set of listening event states;
[0020] The second program obtains the target event status of each listening event and feeds it back to the first program.
[0021] In some implementations, the first program determines whether to add each listening event to a ready queue in the epoll object based on the target event state of each listening event fed back by the second program, including:
[0022] The first program determines whether each target event state is a subset of the monitored event state set, and adds the red-black tree node objects corresponding to the monitored events belonging to the monitored event state set subset to the ready queue.
[0023] In some implementations, the first program determines whether there is a ready event in the ready queue through an epoll event waiting function, and processes the target thread based on the determination result, including:
[0024] When the first program determines through the epoll event waiting function that there is a red-black tree node object in the ready queue, the target thread is awakened;
[0025] When the first program determines through the epoll event waiting function that there is no data in the ready queue, the target thread enters an interrupt waiting state.
[0026] In some embodiments, the method further comprises:
[0027] When the second program monitors a target monitoring event among the N monitoring events, the second program matches the current event state of the monitored target monitoring event with the monitored event state set in the notification event object;
[0028] If the current event state is a subset of the monitored event state set, the second program notifies the first program of event information of the target monitored event;
[0029] After receiving the event information of the target listening event, the first program determines the target red-black tree node object of the target listening event from the red-black tree based on the file descriptor of the target listening event, and adds the target red-black tree node object to the ready queue.
[0030] In a second aspect, an embodiment of the present invention provides a vehicle computer, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the above-mentioned data processing method based on the epoll mechanism when executing the program.
[0031] In a third aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the above-mentioned data processing method based on the epoll mechanism.
[0032] In a fourth aspect, an embodiment of the present invention provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it is used to load and execute the steps in the above-mentioned data processing method based on the epoll mechanism.
[0033] The above one or at least one technical solution in the embodiments of the present application has at least the following technical effects:
[0034] The data processing method based on the epoll mechanism provided by the embodiment of this specification is applied to a microkernel system, wherein the microkernel system at least includes a first program and a second program running in a user space, wherein the first program is an application program or a driver program, and the second program is a driver program, wherein the first program calls an epoll creation function, creates an epoll object and a target thread for event monitoring in the process of the first program; the first program adds N monitoring events to the epoll object through an epoll event registration function, where N is a positive integer; the first program sends an inter-process communication request to the second program based on the file descriptor of each monitoring event, and requests the event status of each monitoring event from the second program; the first program determines whether to add each monitoring event to the ready queue in the epoll object based on the target event status of each monitoring event fed back by the second program; the first program determines whether to add each monitoring event to the ready queue in the epoll object through an epoll event waiting function, and processes the target thread based on the judgment result. The above scheme implements event processing under the epoll mechanism in the microkernel system, greatly improving the ability of the microkernel system to handle a large number of concurrent connections and I / O event processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 A flowchart of a data processing method based on the epoll mechanism provided in an embodiment of this specification;
[0036] Figure 2 A schematic diagram of the association relationship between various data structures after calling the epoll creation function provided in an embodiment of this specification;
[0037] Figure 3 A schematic diagram of the association between various objects involved in the process of calling an epoll event registration function provided in an embodiment of this specification;
[0038] Figure 4 A schematic diagram of a vehicle computer provided in an embodiment of this specification. DETAILED DESCRIPTION
[0039] The overall idea of the technical solution of the embodiment of the present application is as follows: the microkernel system includes at least a first program and a second program running in the user space, the first program is an application or a driver, the second program is a driver, the first program calls the epoll create function, creates an epoll object and a target thread for event monitoring in the process of the first program; the first program adds N listening events to the epoll object through the epoll event registration function, where N is a positive integer; the first program sends an inter-process communication request to the second program based on the file descriptor of each listening event to request the event status of each listening event from the second program; the first program determines whether to add each listening event to the ready queue in the epoll object based on the target event status of each listening event fed back by the second program; the first program determines whether there is a ready event in the ready queue through the epoll event wait function, and processes the target thread based on the judgment result.
[0040] The solution of the embodiments of this specification implements event processing under the epoll mechanism in the microkernel system, greatly improving the ability of the microkernel system to handle a large number of concurrent connections and I / O event processing.
[0041] In order to better understand the above technical scheme, the technical scheme of the embodiments of this specification is described in detail below through the accompanying drawings and specific embodiments. It should be understood that the embodiments of this specification and the specific features in the embodiments are detailed descriptions of the technical scheme of the embodiments of this specification, rather than limitations on the technical scheme of this specification. In the absence of conflict, the embodiments of this specification and the technical features in the embodiments can be combined with each other.
[0042] First of all, the term "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0043] The data processing method based on the epoll mechanism provided in the embodiments of this specification can be applied to devices of a microkernel system, such as a car computer, a server, etc. of a microkernel system. A microkernel system may include a user space and a kernel space. In the embodiments of this specification, at least a first program and a second program may be run in the user space of the microkernel system, wherein the first program is an application or a driver, and the second program is a driver. The first program can communicate with the second program between processes, and the second program can transmit data with the underlying hardware and / or peripherals. Figure 1As shown, it is a flow chart of a data processing method based on the epoll mechanism provided in an embodiment of this specification, and the method comprises the following steps:
[0044] Step S101: the first program calls the epoll creation function to create an epoll object and a target thread for event monitoring in the process of the first program;
[0045] Step S102: the first program adds N listening events to the epoll object through the epoll event registration function, where N is a positive integer;
[0046] Step S103: the first program sends an inter-process communication request to the second program based on the file descriptor of each listening event, so as to request the event status of each listening event from the second program;
[0047] Step S104: the first program determines whether to add each listening event to the ready queue in the epoll object based on the target event state of each listening event fed back by the second program;
[0048] Step S105: The first program determines whether there is a ready event in the ready queue through the epoll event waiting function, and processes the target thread based on the determination result.
[0049] It should be noted that the epoll mechanism can include the following three functions: epoll create function, epoll event registration function and epoll event wait function. Among them, the epoll create function can be expressed as epoll_create, which is used to create an epoll object. The epoll event registration function can be expressed as epoll_ctl, which is used to operate the epoll object, such as adding, modifying or deleting the file descriptors and their events to be monitored to the epoll object. The epoll event wait function can be expressed as epoll_wait, which is used to wait for the event in the epoll object to occur.
[0050] In step S101, the first program can be any program running in the user space, and the first program can be an application program or a driver program. In some embodiments, when the first program monitors the status of certain drivers, processes or file systems through a multiplexing interface, the first program will call the epoll creation function. The epoll creation function is responsible for creating an epoll object, that is, a "pool" for monitoring and managing file descriptor handles. In a macro-kernel Linux system, the pool is created in the kernel, and in a micro-kernel system, such as a real-time system based on a micro-kernel, it is created in the process of the first program itself. At the same time, a target thread is also created in the process of the first program to monitor the registered file descriptor events, wherein the events can be transmitted through a signal mechanism.
[0051] In the embodiments of the present specification, after the epoll object is created, the target address of the data structure applying the epoll object may be associated with the file descriptor assigned to the epoll object.
[0052] In some embodiments, the target address of the data structure of the epoll object can be associated with the data structure of the IO data. At the same time, a file descriptor (filedescriptor, fd) is allocated to the epoll object in the file descriptor table of the IO data, and the above IO data structure is bound to the file descriptor, so that the epoll object can be found through the file descriptor.
[0053] For a better description of the steps performed by the epoll creation function, please refer to Figure 2 , which is a schematic diagram of the relationship between various data structures after calling the epoll creation function. Figure 2 In the example, struct eventpoll is the data structure of the epoll object, which may include struct rbt_root rb_tree (red-black tree), ulist_tready_list (ready queue), pthread_t_thread (target thread), and int thread_pid (thread ID of the target thread).
[0054] like Figure 2As shown, the data structure address of eventpoll can be assigned to node_priv (node attribute) in struct io_data (IO data data structure), and io_fdtable (IO data file descriptor table) includes io datat*io data list[] (io data table) for recording the fd array. In io_fdtable, an fd is allocated for eventpoll, and io_data is bound to the fd, and then eventpoll can be found through the fd. It should be noted that in addition to node_priv, struct io_data can also include other members, such as char path[] (path) and intchannel (channel), which are not listed here one by one.
[0055] In step S102, the first program adds N listening events to the epoll object through the epoll event registration function, where N is a positive integer. It should be noted that after adding the listening events to the epoll object, the listening events can also be modified and / or deleted by calling the epoll event registration function.
[0056] In an embodiment of the present specification, adding a listening event can be achieved in the following manner: the first program allocates a corresponding red-black tree node object to each listening event through an epoll event registration function, wherein, for each red-black tree node object, the red-black tree node object includes red-black tree node information associated with the red-black tree, a file descriptor of the listening event corresponding to the red-black tree node object, a pointer to the epoll object, and a listening event attribute, wherein the listening event attribute includes a listening event state set; each red-black tree node object is inserted into the red-black tree.
[0057] Specifically, for each listening event, a red-black tree node object epitem is assigned, such as Figure 3 The following is a diagram showing the relationship between the various objects involved in calling the epoll event registration function. Figure 3 , taking a red-black tree node object as an example, the node object can include the following elements:
[0058] A.struct rbt_node tree_node, i.e., red-black tree node information, is used to associate the red-black tree of the epitem with eventpoll;
[0059] B.int fd, the file descriptor of the epitem monitoring event;
[0060] C.epoll_dev_t*epoll, used for pointer to eventpoll;
[0061] D.struct epoll_event event, this data structure is used to record the listening event attributes, where the listening event attributes may include the event status of the listening event, user-defined data, etc.
[0062] After allocating the above red-black tree node object for the listening event, insert the red-black tree node object into the red-black tree of eventpoll.
[0063] In step S103, after obtaining the file descriptor of the listening event, the first program can send an inter-process communication request to the second program based on the file descriptor of each listening event. In some embodiments, the first program can determine the driver corresponding to the file descriptor, i.e., the second program, based on the file descriptor of the listening event, and then send an IPC (Inter-Process Communication) request to the second program to request the event status of the listening event.
[0064] In an embodiment of the present specification, step S103 can be implemented in the following manner: the first program generates the inter-process communication request based on the file descriptor of each monitored event, the monitored event status set and the thread identifier of the target thread, and sends the inter-process communication request to the second program.
[0065] like Figure 3 As shown, the IPC request may include the following data: a.flags, i.e., the set of event states that need to be monitored, which includes but is not limited to EPOLL_IN, EPOLL_OUT, etc.; b.sival_int, i.e., the file descriptor of the monitored event; c.thread_pid, i.e., the thread ID of the target thread. Since the event wake-up mechanism in this solution is implemented by signals, it is necessary to know the thread ID of the wake-up thread.
[0066] Furthermore, after receiving the inter-process communication request, the second program can perform the following steps: the second program creates a notification event object based on the inter-process communication request, and the notification event object includes the thread identifier of the target thread, the file descriptor of each listening event, and the listening event status set; the second program obtains the target event status of each listening event and feeds it back to the first program.
[0067] In some embodiments, after receiving the inter-process communication request, the second program end may call the operation function pre-registered by the corresponding driver process, such as the poll operation function, to create a notification event object, and the notification event object notify_event may record the relevant information of the first program end. In some embodiments, notify_event may include the following information: a.tid, i.e., the thread identifier of the target thread created by epoll_create sent by the first program; b.pend_flags, i.e., the event state set to be monitored; c.sival_int, i.e., the file descriptor of the monitored event.
[0068] In the embodiment of the present specification, after receiving an inter-process communication request, the second program can find the private data structure corresponding to the fd through the fd in the inter-process communication request. The private data structure contains notify_info. Notify_info can be a structure of information related to event notification. The notify_event object created above is hung in notify_info.
[0069] For each listening event, the second program obtains the target event state of each listening event. In some embodiments, the second program may obtain the event state mask of the listening event as the target event state and feed it back to the first program.
[0070] In step S104, the first program determines whether to add the listening event to the ready queue based on the target event state fed back by the second program, which can be achieved through the following steps: the first program determines whether each target event state is a subset of the monitored event state set, and adds the red-black tree node objects corresponding to the listening events belonging to the subset of the monitored event state set to the ready queue.
[0071] Specifically, after the first program receives the target event state fed back by the second program, it compares it with the monitored event state set. For example, the monitored event state set includes EPOLL_IN, EPOLL_OUT, EPOLL_ERR, etc. The target event state fed back by the second program is EPOLL_IN, that is, the target event state is a subset of the monitored event state set. Then, the epitem of the monitored event corresponding to the target event state can be put into the ready queue of eventpoll. If the target event state is not a subset of the monitored event state set, no processing is performed.
[0072] In step S105, after running the epoll event waiting function, the first program detects the ready queue of eventpoll to determine whether there is a ready event in the ready queue. In some embodiments, it can be determined whether there is a red-black tree node object in the ready queue. If there is a red-black tree node object, that is, epitem, in the ready queue, it indicates that there is a ready event in the ready queue. If there is no epitem in the ready queue, it indicates that there is no ready event in the ready queue.
[0073] In some embodiments, when the first program determines through the epoll event waiting function that there is a red-black tree node object in the ready queue, the target thread is awakened; when the first program determines through the epoll event waiting function that there is no data in the ready queue, the target thread enters an interrupt waiting state.
[0074] Specifically, if there is no data in the ready queue, it means that there is no file descriptor ready for I / O operation, and the target thread can be suspended at this time, without occupying the CPU. In some embodiments, when there is no data in the ready queue, the CPU can be released by the pthread_cond_timedwait function, and the pthred_cond_signal function is waited for to wake it up.
[0075] It should be noted that in the above process, the first program sends an IPC request to the second program, the second program feeds back the target event status based on the IPC request, the first program determines whether to add the epitem of the corresponding file descriptor to the ready queue based on the target event status, and performs corresponding operations on the target thread through the epoll event waiting function, and this process can be used as a synchronous processing process of the listening event. In some embodiments, the listening event can also be processed asynchronously, and the asynchronous processing process can be implemented in the following way: when the second program listens to the target listening event among the N listening events, the current event state of the listening target listening event is matched with the listening event state set in the notification event object; if the current event state is a subset of the listening event state set, the second program notifies the first program of the event information of the target listening event; after receiving the event information of the target listening event, the first program determines the target red-black tree node object of the target listening event from the red-black tree based on the file descriptor of the target listening event, and adds the target red-black tree node object to the ready queue.
[0076] Specifically, after the second program listens to the target listening event, the second program can traverse the notify_event in notify_info. If the current event state of the received target listening event is a subset of the pend_flags state in notify_event, the following steps can be performed based on the signal processing mechanism: the second program calls the signal sending interface to send the current event state to the tid specified by notify_event. At this time, the sigwaitinfo in the epoll thread in the first program will be awakened and get the sig_info sent by the second program. Among them, sigwaitinfo is used to synchronize the signal in the waiting queue. This function can suspend the execution of the calling thread until a signal in the specified signal set arrives. sig_info can be the data returned after sigwaitinfo is called. sig_info contains fd information. According to the fd in sig_info, the corresponding epitem is found from the red-black tree node, and the epitem is hung in the ready queue of eventpoll. At the same time, the thread that may be blocked by epoll wait is awakened through pthread_cond_signao.
[0077] In summary, the method provided in the embodiment of this specification implements event processing based on the epoll mechanism in the microkernel system, greatly improving the ability of the microkernel system to handle a large number of concurrent connections and I / O event processing. In addition, the scheme of the present application can also implement epoll edge triggering and epoll level triggering by operating the ready queue, which has better flexibility.
[0078] Based on the same inventive concept, the embodiment of the present invention further provides a vehicle computer, such as Figure 4 The device includes a memory 404, a processor 402, and a computer program stored in the memory 404 and executable on the processor 402. When the processor 402 executes the program, any implementation of the data processing method based on the epoll mechanism is implemented.
[0079] Among them, Figure 4In the embodiment of the present invention, a bus architecture (represented by bus 400) is shown, which may include any number of interconnected buses and bridges, and bus 400 links various circuits including one or more processors represented by processor 402 and memory represented by memory 404. Bus 400 may also link various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. Bus interface 405 provides an interface between bus 400 and receiver 401 and transmitter 403. Receiver 401 and transmitter 403 may be the same element, namely a transceiver, providing a unit for communicating with various other devices over a transmission medium. Processor 402 is responsible for managing bus 400 and general processing, while memory 404 may be used to store data used by processor 402 when performing operations.
[0080] Based on the same inventive concept, an embodiment of this specification provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the above-mentioned data processing method based on the epoll mechanism are implemented.
[0081] Based on the same inventive concept, an embodiment of this specification provides a computer program product, which includes a computer program. When the computer program is executed by a processor, it is used to load and execute the steps of the above-mentioned data processing method based on the epoll mechanism.
[0082] The functions described herein may be implemented in hardware, software executed by a processor, firmware, or any combination thereof. If implemented in software executed by a processor, the functions may be stored as one or more instructions or codes on a computer-readable medium or transmitted via a computer-readable medium. Other examples and implementations are within the scope and spirit of the present invention and the appended claims. For example, due to the nature of software, the functions described above may be implemented using software executed by a processor, hardware, firmware, hard wiring, or a combination of any of these. In addition, each functional unit may be integrated into a processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit.
[0083] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0084] The units described as separate components may or may not be physically separated, and the components of the control device may or may not be physical units, that is, they may be located in one place or distributed in multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0085] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0086] The above description is only an embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent substitution, improvement, etc. made within the spirit and principle of the present invention shall be included in the scope of the claims of the present invention.
Claims
1. A data processing method based on the epoll mechanism, characterized in that: Applied in a microkernel system, the microkernel system includes at least a first program and a second program running in a user space, the first program is an application program or a driver, and the second program is a driver, the method includes: The first program calls an epoll creation function to create an epoll object and a target thread for event monitoring in a process of the first program; The first program adds N listening events to the epoll object through the epoll event registration function, where N is a positive integer; The first program sends an inter-process communication request to the second program based on the file descriptor of each listening event, so as to request the event status of each listening event from the second program; The first program determines whether to add each listening event to the ready queue in the epoll object based on the target event state of each listening event fed back by the second program; The first program determines whether there is a ready event in the ready queue through an epoll event waiting function, and processes the target thread based on the determination result.
2. The method according to claim 1, characterized in that After the first program calls the epoll creation function and creates an epoll object in the process of the first program, the method further includes: The first program associates a target address of a data structure of the epoll object with a file descriptor assigned to the epoll object.
3. The method according to claim 1, characterized in that The data structure of the epoll object includes a red-black tree, and the first program adds N listening events to the epoll object through an epoll event registration function, including: The first program allocates a corresponding red-black tree node object to each listening event through an epoll event registration function, wherein, for each red-black tree node object, the red-black tree node object includes red-black tree node information associated with the red-black tree, a file descriptor of the listening event corresponding to the red-black tree node object, a pointer to the epoll object, and a listening event attribute, wherein the listening event attribute includes a listening event state set; Insert each red-black tree node object into the red-black tree.
4. The method according to claim 1 or 2, characterized in that: The first program sends an inter-process communication request to the second program based on the file descriptor of each listening event, including: The first program generates the inter-process communication request based on the file descriptor of each monitored event, the monitored event status set, and the thread identifier of the target thread, and sends the inter-process communication request to the second program.
5. The method according to claim 3, characterized in that The method further comprises: After receiving the inter-process communication request, the second program creates a notification event object based on the inter-process communication request, wherein the notification event object includes a thread identifier of the target thread, a file descriptor of each listening event, and a set of listening event states; The second program obtains the target event status of each listening event and feeds it back to the first program.
6. The method according to claim 3, characterized in that The first program determines whether to add each listening event to the ready queue in the epoll object based on the target event state of each listening event fed back by the second program, including: The first program determines whether each target event state is a subset of the monitored event state set, and adds the red-black tree node objects corresponding to the monitored events belonging to the monitored event state set subset to the ready queue.
7. The method according to claim 6, characterized in that The first program determines whether there is a ready event in the ready queue through an epoll event waiting function, and processes the target thread based on the determination result, including: When the first program determines through the epoll event waiting function that there is a red-black tree node object in the ready queue, the target thread is awakened; When the first program determines through the epoll event waiting function that there is no data in the ready queue, the target thread enters an interrupt waiting state.
8. The method according to claim 5, characterized in that The method further comprises: When the second program monitors a target monitoring event among the N monitoring events, the second program matches the current event state of the monitored target monitoring event with the monitored event state set in the notification event object; If the current event state is a subset of the monitored event state set, the second program notifies the first program of event information of the target monitored event; After receiving the event information of the target listening event, the first program determines the target red-black tree node object of the target listening event from the red-black tree based on the file descriptor of the target listening event, and adds the target red-black tree node object to the ready queue.
9. A vehicle computer, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 8 when executing the program.
10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.
11. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the computer program is used to load and execute the method according to any one of claims 1 to 8.