Search

CN-115373874-B - Cross-process event processing method and device, electronic equipment, storage medium and vehicle

CN115373874BCN 115373874 BCN115373874 BCN 115373874BCN-115373874-B

Abstract

The disclosure provides a method, a device, electronic equipment, a storage medium and a vehicle for processing a cross-process event, relates to the technical field of computers, and particularly relates to the technical field of inter-process communication. The method comprises the steps of acquiring a process lock of a shared memory of a process set under the condition that event notification needs to be sent, wherein the shared memory comprises a first object, establishing an association relationship between the first object and a process subset in the shared memory under the condition that the process lock is successfully acquired, and waking up a plurality of processes in a dormant state in the process set based on a condition variable signal of the shared memory so as to notify the process subset in the plurality of processes for processing the dormant state to acquire message content of the event notification based on the first object. The event processing method improves the efficiency of event notification, overcomes the defect that a process cannot be awakened directionally by using a condition variable signal, completes the directional transmission of the event notification to a process subset, and improves the efficiency of cross-process event notification.

Inventors

  • DONG LEI
  • LIN XIAODONG
  • WANG BAISHENG

Assignees

  • 阿波罗智能技术(北京)有限公司

Dates

Publication Date
20260512
Application Date
20220824

Claims (16)

  1. 1. A method of cross-process event processing, comprising: acquiring a process lock of a shared memory of a process set under the condition that event notification needs to be sent, wherein the shared memory comprises a first object, and the first object records an identifier of a process subset of which the event notification needs to be acquired; Under the condition that the process lock is successfully acquired, establishing an association relation between the first object and a process subset in the shared memory; Waking up a plurality of processes in a dormant state in the process set based on the condition variable signals of the shared memory to inform the subset of the processes in the dormant state to acquire the message content of the event notification based on the first object; The shared memory further comprises a second object, the second object is used for recording the number of processes connected with the shared memory, and the method further comprises: And releasing the shared memory under the condition that the process number of the second object record is a designated value after the preset value is reduced.
  2. 2. The method of claim 1, further comprising creating the shared memory based on: Calling a memory creation interface to send a memory creation request under the condition that the shared memory is not created based on the memory identification of the shared memory; receiving response information returned by the memory creation interface; creating the shared memory based on the memory identification under the condition that the response information indicates that the shared memory is allowed to be created; Setting the state of the shared memory to be in initialization under the condition of starting initializing the shared memory; And under the condition that the initialization of the shared memory is completed, updating the state of the shared memory to be the initialization completion.
  3. 3. The method of claim 2, further comprising: reading the state of the shared memory every interval designated time length until the state of the shared memory is updated to be initialized when the response information indicates that the memory creation fails; and under the condition that the state of the shared memory is updated to be initialized, mapping the memory address of the shared memory to a process space.
  4. 4. A method according to claim 2 or 3, wherein the shared memory includes header identification information, and the status of the shared memory is recorded in the header identification information.
  5. 5. A method according to any one of claims 1-3, further comprising: acquiring a process lock of the shared memory under the condition that event notification needs to be received; under the condition that the process lock is successfully acquired, calling a dormancy method of the shared memory to enter a dormancy state; Under the condition that a condition variable signal is received, entering an awake state; in the awake state, the event notification is processed.
  6. 6. The method of claim 5, wherein the processing the event notification in the awake state comprises: in the wake-up state, acquiring a process lock of the shared memory; Reading a first object in the shared memory; releasing the process lock and acquiring message content based on the event notification if it is determined that the process lock is associated with the first object; And under the condition that the first object is not associated with the first object, returning to execute the operation of calling the sleep method of the shared memory to enter the sleep state, and releasing the process lock.
  7. 7. A cross-process event processing apparatus, the apparatus comprising: The system comprises a first acquisition module, a first object, a second acquisition module and a first acquisition module, wherein the first acquisition module is used for acquiring a process lock of a shared memory of a process set under the condition that event notification is required to be sent; the association module is used for establishing an association relation between the first object and the process subset in the shared memory under the condition that the process lock is successfully acquired; A notification module, configured to wake up a plurality of processes in a sleep state in the process set based on a condition variable signal of the shared memory, so as to notify the subset of processes in the sleep state to acquire a message content of the event notification based on the first object; the shared memory further includes a second object, where the second object is used to record the number of processes connected to the shared memory, and the apparatus further includes: the recording module is used for reducing the process number recorded by the second object by a preset value under the condition that the shared memory is determined to stop being used; and the release module is used for releasing the shared memory under the condition that the process number recorded by the second object is a designated value after the preset value is reduced.
  8. 8. The apparatus of claim 7, further comprising a creation module to create the shared memory based on: Calling a memory creation interface to send a memory creation request under the condition that the shared memory is not created based on the memory identification of the shared memory; receiving response information returned by the memory creation interface; creating the shared memory based on the memory identification under the condition that the response information indicates that the shared memory is allowed to be created; Setting the state of the shared memory to be in initialization under the condition of starting initializing the shared memory; And under the condition that the initialization of the shared memory is completed, updating the state of the shared memory to be the initialization completion.
  9. 9. The apparatus of claim 8, further comprising: The cyclic reading module is used for reading the state of the shared memory every interval appointed duration until the state of the shared memory is updated to be initialized when the response information indicates that the memory creation fails; and the mapping module is used for mapping the memory address of the shared memory to a process space under the condition that the state of the shared memory is updated to be initialized.
  10. 10. The apparatus according to claim 8 or 9, wherein header identification information is included in the shared memory, and a state of the shared memory is recorded in the header identification information.
  11. 11. The apparatus of any of claims 7-9, further comprising: the second acquisition module is used for acquiring the process lock of the shared memory under the condition that event notification needs to be received; The dormancy module is used for calling a dormancy device of the shared memory to enter a dormancy state under the condition that the process lock is successfully acquired; the wake-up module is used for entering a wake-up state under the condition that a condition variable signal is received; and the processing module is used for processing the event notification in the wake-up state.
  12. 12. The apparatus of claim 11, wherein the processing module comprises: The acquisition sub-module is used for acquiring the process lock of the shared memory in the wake-up state; The reading sub-module is used for reading the first object in the shared memory; The message acquisition sub-module is used for releasing the process lock and acquiring message content based on the event notification under the condition that the process lock is determined to be associated with the first object; and the dormancy sub-module is used for returning to execute the operation of calling the dormancy device of the shared memory to enter the dormancy state and releasing the process lock under the condition that the dormancy sub-module is not associated with the first object.
  13. 13. An electronic device, comprising: at least one processor, and A memory communicatively coupled to the at least one processor, wherein, The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of claims 1-6.
  14. 14. A non-transitory computer readable storage medium storing computer instructions for causing the computer to perform the method of any one of claims 1-6.
  15. 15. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any of claims 1-6.
  16. 16. A vehicle comprising the electronic device of claim 13.

Description

Cross-process event processing method and device, electronic equipment, storage medium and vehicle Technical Field The present disclosure relates to the field of computer technology, and in particular, to the field of interprocess communication technology. Background With the development of software and hardware, inter-process communication is more and more extensive, and a method for realizing the inter-process communication is also endless. Wherein, the cross-process communication based on the shared memory is a high-efficiency and rapid method. A cross-process communication method based on shared memory includes such steps as sharing memory by process A and process B, writing data in memory by process A, updating data identifier, periodically checking the data identifier of shared memory by process B, copying data to process space if there is data, and obtaining information. However, such a cross-process communication method still cannot meet the requirements, and how to more efficiently implement the cross-process communication still needs to be solved. Disclosure of Invention The present disclosure provides a method, apparatus, device, storage medium and vehicle for cross-process event handling. According to an aspect of the present disclosure, there is provided a cross-process event processing method, including: Under the condition that event notification needs to be sent, acquiring a process lock of a shared memory of a process set, wherein the shared memory comprises a first object; Under the condition of successfully acquiring the process lock, establishing an association relation between a first object and a process subset in a shared memory; Based on the condition variable signals of the shared memory, a plurality of processes in the dormant state in the process set are awakened to inform a subset of the processes in the dormant state to acquire message content of event notification based on the first object. According to another aspect of the present disclosure, there is provided a cross-process event processing apparatus including: The first acquisition module is used for acquiring a process lock of a shared memory of the process set under the condition that event notification needs to be sent; the association module is used for establishing an association relation between the first object and the process subset in the shared memory under the condition that the process lock is successfully acquired; And the notification module is used for waking up a plurality of processes in the dormant state in the process set based on the condition variable signals of the shared memory so as to notify a subset of the processes in the dormant state to acquire the message content of the event notification based on the first object. According to another aspect of the present disclosure, there is provided an electronic device including: at least one processor, and A memory communicatively coupled to the at least one processor, wherein, The memory stores instructions executable by the at least one processor to enable the at least one processor to perform the method of any one of the embodiments of the present disclosure. According to another aspect of the present disclosure, there is provided a non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform a method according to any one of the embodiments of the present disclosure. According to another aspect of the present disclosure, there is provided a computer program product comprising a computer program which, when executed by a processor, implements a method according to any of the embodiments of the present disclosure. According to another aspect of the present disclosure, there is provided a vehicle including the above-described electronic device. According to the event processing method provided by the disclosure, resource consumption caused by periodic access to the shared memory is reduced, the efficiency of event notification is improved, the defect that a process cannot be awakened directionally by using a condition variable signal is overcome, and the event notification is transmitted to a subset of processes in a directed manner, namely to an appointed other process, so that the efficiency of cross-process event notification is improved. It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the disclosure, nor is it intended to be used to limit the scope of the disclosure. Other features of the present disclosure will become apparent from the following specification. Drawings The drawings are for a better understanding of the present solution and are not to be construed as limiting the present disclosure. Wherein: FIG. 1 is a flow chart of a method for processing a cross-process event according to an embodiment of the present disclosure; FIG. 2 is a schematic diagram of a possible application scenario provided by an e