Communication method and device between application programs, electronic equipment and vehicle
In the automotive electronic electronic domain control environment, using communication variables to manage buffer access between applications and stagger read and write operations, the CPU resource consumption problem caused by concurrent access is solved and communication efficiency is improved.
Patent Information
- Application Number
- CN202310682673.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-09
- Publication Date
- 2024-12-10
AI Technical Summary
In the automotive electronic electronic domain control environment, concurrent access to shared data between applications is likely to cause CPU resource consumption, especially because isolation measures caused by memory protection unit (MPU) limit direct read and write access, resulting in spin lock Waiting affects efficiency.
By obtaining the communication variables of the other party's application, determining the buffer occupancy situation, and selecting different buffers for read and write operations, ensuring that the sending and receiving applications logically stagger the read and write access, thereby avoiding concurrency to the same buffer access.
It effectively avoids the consumption of CPU resources, improves the efficiency of communication between applications, and ensures simultaneous read and write operations between different buffers without waiting for the spin lock to be released.
Smart Images

Figure CN119105878A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a method, device, electronic device and vehicle for communication between applications. Background Art
[0002] With the development of domain control of automotive electronic control, traditional professional functions such as body, chassis, and vehicle control may be integrated into a domain controller. In order to meet the requirements of functional safety, each discipline will be deployed to the application (such as OS-Application) corresponding to the AUTomotive Open System Architecture (AUTOSAR), and measures such as the Memory Protection Unit (MPU) will be used to ensure that the software of each discipline is isolated from each other and does not interfere with each other. Due to the existence of MPU, different OS-Applications belong to different security partitions and do not have direct read and write access permissions, but each discipline inevitably has the need to communicate with each other, and concurrent access to shared data is prone to occur when communicating with each other.
[0003] In existing operating system, application communication technology usually uses spinlock to solve the problem of concurrent access to shared data. Spinlock will keep spinning while waiting for the lock to be released. The spinning process will cause the central processing unit (CPU) to run empty statements, which will consume CPU resources. Summary of the invention
[0004] In view of this, the present application provides a method, device, electronic device and vehicle for communication between applications, which can effectively solve the problem of concurrent access to shared data during application communication while avoiding consumption of CPU resources.
[0005] According to a first aspect of the present application, a method for communication between applications is provided, the method being applied to a sending application, comprising:
[0006] Acquire a first communication variable of a receiving-end application, the first communication variable being used to indicate whether the receiving-end application currently occupies a buffer zone, and, if the receiving-end application currently occupies a buffer zone, indicating that the receiving-end application occupies a buffer zone for reading data;
[0007] Determine a first target buffer based on the first communication variable, where the first target buffer is other buffers other than the buffer occupied by the receiving end application for reading data;
[0008] The communication data is sent to the receiving application by performing a data write operation on the first target buffer.
[0009] According to a second aspect of the present application, a method for communication between applications is provided, the method being applied to a receiving application, comprising:
[0010] Acquire a third communication variable of the sending end application, the third communication variable being used to indicate whether the sending end application currently occupies a buffer, and, if the sending end application currently occupies a buffer, indicating that the sending end application occupies a buffer for writing data;
[0011] Determine a second target buffer based on the third communication variable, where the second target buffer is another buffer other than the buffer occupied by the sending application to write data;
[0012] The communication data sent by the sending application is received by performing a data read operation on the second target buffer.
[0013] According to a third aspect of the present application, there is provided an inter-application communication device, the device being applied to a sending end application, comprising:
[0014] A first acquisition module is used to acquire a first communication variable of a receiving-end application, wherein the first communication variable is used to indicate whether the receiving-end application currently occupies a buffer zone, and when the receiving-end application currently occupies a buffer zone, indicates that the receiving-end application occupies a buffer zone for reading data;
[0015] A first determination module is used to determine a first target buffer based on the first communication variable, where the first target buffer is other buffers other than the buffer occupied by the receiving end application for reading data;
[0016] The first sending module is used to send communication data to the receiving end application by performing a data writing operation on the first target buffer.
[0017] According to a fourth aspect of the present application, there is provided an inter-application communication device, the device being applied to a receiving-end application, comprising:
[0018] A second acquisition module is used to acquire a third communication variable of the sending end application, wherein the third communication variable is used to indicate whether the sending end application currently occupies a buffer zone, and when the sending end application currently occupies a buffer zone, indicates that the sending end application occupies a buffer zone for writing data;
[0019] A second determination module is used to determine a second target buffer based on the third communication variable, where the second target buffer is another buffer other than the buffer occupied by the sending application to write data;
[0020] The receiving module is used to receive the communication data sent by the sending application by performing a data reading operation on the second target buffer.
[0021] According to a fifth aspect of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the inter-application communication method described in the first aspect and the second aspect is implemented.
[0022] According to the sixth aspect of the present application, an electronic device is provided, comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements the inter-application communication method described in the first aspect and the second aspect when executing the computer program.
[0023] According to a seventh aspect of the present application, a vehicle is provided, comprising: the electronic device as described in the sixth aspect.
[0024] By means of the above technical solution, the present application provides an inter-application communication method, device, electronic device and vehicle, wherein the sending end application can first obtain the first communication variable of the receiving end application, the first communication variable is used to indicate whether the receiving end application currently occupies the buffer, and when the receiving end application currently occupies the buffer, indicates that the receiving end application occupies the buffer for reading data; then the first target buffer can be determined based on the first communication variable, the first target buffer is other buffers other than the buffer for reading data occupied by the receiving end application; finally, the sending end application can send communication data to the receiving end application by performing a data write operation on the first target buffer. The receiving end application can obtain the third communication variable of the sending end application, the third communication variable is used to indicate whether the sending end application currently occupies the buffer, and when the sending end application currently occupies the buffer, indicates that the sending end application occupies the buffer for writing data; then the second target buffer can be determined based on the third communication variable, the second target buffer is other buffers other than the buffer for writing data occupied by the sending end application; finally, the receiving end application can receive the communication data sent by the sending end application by performing a data read operation on the second target buffer. The technical solution disclosed in the present invention can make the sending end application and the receiving end application staggered in read and write access logically. Whenever the sending end application is to read the buffer to be written to the receiving end application, it is staggered, so there will be no concurrent access to the shared data in the same buffer. Since the sending end application and the receiving end application can perform read and write access to different buffers at the same time, there is no need to spin and wait for the release of the same buffer, so there will be no consumption of CPU resources.
[0025] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0027] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0028] Figure 1A schematic diagram of the structure of a software isolation architecture provided by an embodiment of the present disclosure;
[0029] Figure 2 A schematic diagram of an example of a multi-layer structure division provided by an embodiment of the present disclosure
[0030] Figure 3 A flowchart of an inter-application communication method provided by an embodiment of the present disclosure;
[0031] Figure 4 A schematic diagram of the principle flow of communication between applications provided by an embodiment of the present disclosure;
[0032] Figure 5 A flowchart of an inter-application communication method provided by another embodiment of the present disclosure;
[0033] Figure 6 A schematic diagram of a principle flow of communication between applications provided by another embodiment of the present disclosure;
[0034] Figure 7 A schematic diagram of the structure of an inter-application communication device provided in an embodiment of the present disclosure;
[0035] Figure 8 A schematic diagram of the structure of an inter-application communication device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0036] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0037] The following describes the inter-application communication method, device, electronic device, and vehicle according to the embodiments of the present disclosure with reference to the accompanying drawings.
[0038] The present application can be applied to application communication within different operating systems. In the following embodiment steps of the present disclosure, the operating system is an operating system (OS) of the Automotive Open System Architecture (AUTOSAR), and the application that needs to communicate within the operating system is an OS-Application, to illustrate the technical solution in the present disclosure, but it does not constitute a specific limitation.
[0039] In an operating system, in order to prevent program failures between independent applications from interfering with each other, the operating system can be deployed as an isolation architecture, such as Figure 1 As shown, the isolation architecture includes multiple independent layer structures, which can include the application layer, adaptation layer and bottom layer from top to bottom. Specifically, the application programs in the controller can be divided into layers according to the types of professional functions carried by the controller, the development team and the software security level. According to the three-layer structure of application layer, adaptation layer and bottom layer, the application programs are deployed in different layers of different cores of the controller. Among them, the functional software deployed in the application layer, adaptation layer and bottom layer are compiled independently from each other and configured with different access rights.
[0040] Specifically, the application layer can be used to deploy functional software that provides application services in the controller. When the controller is a vehicle controller, the functional software that provides application services can be software that can achieve corresponding functions through human-machine control, such as acceleration function software, creeping function software, reversing function software, gear shifting function software, etc. For example, Figure 2 As shown, the functional software that provides application services can be deployed in the application layer: Function1, Function2, Function3, Function4; the adaptation layer can be used to provide the connection between the application layer and the bottom layer, and to deploy functional software that provides auxiliary adaptation services for the application layer and the bottom layer. When the controller is a vehicle controller, the functional software that provides auxiliary adaptation services for the application layer and the bottom layer may include signal routing functional software, signal diagnosis functional software, auxiliary interface functional software, etc.; the functional software that provides auxiliary adaptation services can be deployed in the adaptation layer: Function5, Function6, Function7; the bottom layer can be used to deploy functional software that provides driving services in the controller, such as driving the sensor to collect hardware detection signals, and sending the hardware detection signals to the application layer through the adaptation layer, or providing power for the controller, etc.; the functional software that provides driving services can be deployed in the bottom layer: Function8, Function9, Function10.
[0041] In a specific application scenario, at least one management container is deployed in the application layer, the adaptation layer, and the bottom layer respectively, and each management container in the at least one management container is used to manage functional software of the same security level under the corresponding layer structure. Figure 2 For the development team TeamA, the functional software Function1 corresponding to the safety level of QM and ASILD is configured at the application layer, and the corresponding management containers can be respectively Figure 1Application_TeamA_Func1_QM and Application_TeamA_Func1_ASILD in ASW_CORE0; for the development team TeamB, the functional software Function2 with the corresponding security level of QM and ASILB is configured in the application layer, and the corresponding management containers can be respectively Figure 1 Application_TeamB_Func2_QM and Application_TeamB_Func2_ASILB in ASW_CORE1; for the development teams TeamC and TeamD, the function software Function3 and Function4 with the corresponding security level of QM are configured in the application layer. The corresponding management containers of Function3 and Function4 can be respectively Figure 1 Application_TeamC_Func3_QM and Application_TeamD_Func4_QM in ASW_CORE2; for the development team TeamQ, the functional software Function5, Function6, and Function7 with the corresponding safety level of ASILD are configured in the adaptation layer, and the management container corresponding to Function5 can be Figure 1 The management container corresponding to Application_TeamQ_Func5_ASILD and Function6 in Adaptor_CORE0 can be Figure 1 The management container corresponding to Application_TeamQ_Func6_ASILD and Function7 in Adaptor_CORE1 can be Figure 1 Application_TeamQ_Func7_ASILD in Adaptor_CORE2; for the development team TeamY, the functional software Function8, Function9, and Function10 with the corresponding safety level of ASILD are configured at the bottom layer, and the management container corresponding to Function8 can be Figure 1 The management container corresponding to BSW_TeamY_Func8_ASILD and Function9 in BSW_CORE0 can be Figure 1 The management container corresponding to BSW_TeamY_Func9_ASILD and Function10 in BSW_CORE1 can be Figure 1 BSW_TeamY_Func10_ASILD in BSW_CORE2.
[0042] In specific application scenarios, the application layer, adaptation layer, and bottom layer use each management container as a unit to independently store the function code and private data corresponding to the function software managed by each management container, and independently configure the user permissions for the function code and private data. The user permissions are used to support each function software to access the function code and private data under its own management container. Figure 1 As shown, for the application layer, adaptation layer and bottom layer, the management container Application under different security levels can independently store the corresponding function code and private data, and each Application can only access its own code and private data. For example, when Function3 developed by TeamC accesses the data code of Function4 developed by TeamD during operation, this behavior will be discovered and corresponding fault handling will be performed to avoid running out of erroneous results. In this way, precise access rights can be achieved while ensuring normal functions, illegal read and write operations outside the software design scope can be restricted, and the software performs correct read and write operations within the design scope. Without affecting the operation of other functional software, a single Application is supported for fault handling: restart or terminate operation, so as to achieve non-interference between faults of various professional software and prevent fault crosstalk.
[0043] In specific application scenarios, because there may be essential interactions between functional software, a communication channel can be configured between the application layer and the adaptation layer. The communication channel is used to support different functional software deployed by the application layer and the adaptation layer to communicate according to the preset communication access mechanism. Among them, as a possible implementation method, the preset communication access mechanism can be to directly open user permissions between interactive functional software, and one interactive functional software can directly access the data communication of another interactive functional software based on the opened user permissions; as a possible implementation method, in order to avoid illegal tampering between functional software and cause software hard failures, communication between different applications can be implemented in the application layer and the adaptation layer based on this solution.
[0044] like Figure 3 , an embodiment of the present disclosure provides an inter-application communication method, which can be applied to a sending end application, including:
[0045] Step 101: Obtain a first communication variable of a receiving application, where the first communication variable is used to indicate whether the receiving application currently occupies a buffer zone, and if the receiving application currently occupies a buffer zone, indicate that the receiving application occupies a buffer zone for reading data.
[0046] In a specific application scenario, five variables may be predefined in the shared area (Inter OS-Application Communication, IOC) of the operating system: the first buffer (Buffer_A), the second buffer (Buffer_B), the first communication variable (ReadHoldFlg), the second communication variable (LastBestFlg) and the third communication variable (WriteHoldFlg). The first communication variable is used to indicate whether the receiving end application (Receiver OS-Application) currently occupies the buffer, and if the receiving end application currently occupies the buffer, indicates the specific buffer occupied by the receiving end application for reading data. If the receiving application currently does not occupy the buffer, it can indicate that the buffer currently occupied by reading data is 0 (no buffer is occupied); if the receiving application currently occupies the buffer, it can indicate whether the buffer currently occupied by reading data is Buffer_A or Buffer_B; the second communication variable (LastBestFlg) is used to indicate the buffer where the sending application (Sender OS-Application) last wrote data, such as indicating that the buffer where the data was last written is Buffer_A or Buffer_B; the third communication variable (WriteHoldFlg) is used to indicate whether the sending application (Sender OS-Application) currently occupies the buffer, and if the sending application currently occupies the buffer, it indicates the specific buffer occupied by the sending application for writing data. If the sending application currently does not occupy the buffer, it can indicate that the buffer currently occupied by writing data is 0 (no buffer is occupied); if the sending application currently occupies the buffer, it can indicate whether the buffer currently written data is Buffer_A or Buffer_B.
[0047] In a specific application scenario, due to the need for software isolation, the MPU configured for the sender application (Sender OS-Application) does not have the authority to read and write access to the above five variables in the shared area, so access can be achieved through an OS trap (Trap). Specifically, before executing the steps of this embodiment, the Sender OS-Application can call IOC_Send(data) through the RTE function Rte_Write(data), and trigger the OS Trap exception by using the SVC instruction (i.e., sending a trap instruction to the operating system), so that the operating system switches from user mode to system mode in the case of an OS Trap exception, and implements read and write access to the variables Buffer_A, Buffer_B, LastBestFlg, ReadHoldFlg, and WriteHoldFlg in the IOC. The embodiment steps may include: sending a trap instruction to the operating system, and the trap instruction is used to instruct the operating system to switch from user mode to system mode. Accordingly, for the embodiment of the present disclosure, in response to the operating system being in system mode, the first communication variable of the receiving application can be obtained in the shared area of the operating system.
[0048] Step 102: determine a first target buffer based on the first communication variable, where the first target buffer is a buffer other than the buffer occupied by the receiving end application for reading data.
[0049] For the embodiments of the present disclosure, when the operating system is in system mode, the sender application (SenderOS-Application) can perform write access to the first buffer and the second buffer in the shared area IOC, and determine the buffer status of the first buffer and the second buffer (i.e., whether they are occupied by reading or writing) based on the first communication variable in the shared area IOC, and further determine the first target buffer based on the buffer status, so that the sender application can stagger the read and write access to the same buffer with the receiver application by writing data to the first target buffer, thereby avoiding concurrent access to shared data in the same buffer.
[0050] Accordingly, for the embodiment of the present disclosure, when determining the first target buffer based on the first communication variable:
[0051] As a possible implementation, when the first communication variable indicates that the buffer currently reading data from the receiving application is the first buffer, the first target buffer can be determined to be the second buffer, and the sending application can write communication data to the second buffer. That is, when the first communication variable (ReadHoldFlg) is equal to A, it means that the Receiver OS-Application is reading and occupying Buffer_A, and the Sender OS-Application can currently write data to Buffer_B.
[0052] As a possible implementation, when the first communication variable indicates that the buffer currently reading data from the receiving application is the second buffer, the first target buffer can be determined to be the first buffer, and the sending application can write communication data to the first buffer. That is, when the first communication variable (ReadHoldFlg) is equal to B, it means that the Receiver OS-Application is reading and occupying Buffer_B, and the Sender OS-Application can currently write data to Buffer_A.
[0053] For the disclosed embodiment, as a preferred method, when the operating system is in system mode, the sender application (Sender OS-Application) can perform write access to the first buffer and the second buffer in the shared area IOC, and determine the buffer status of the first buffer and the second buffer (i.e., whether they are occupied by reading and writing) based on the first communication variable and the second communication variable in the shared area IOC at the same time, and further determine the first target buffer based on the buffer status, so that the sender application can stagger the read and write access to the same buffer with the receiving application by writing data to the first target buffer, avoiding concurrent access to shared data in the same buffer. At the same time, when there are multiple buffers supporting the current data writing of the sender application, the buffer where the sender application writes data next time is different from the buffer where the data was written last time, avoiding the sender application from continuously writing data to the same buffer, and the receiving application cannot read data in the buffer in time, resulting in the loss of transmission data.
[0054] Accordingly, the embodiment steps may include: obtaining a second communication variable of the sending end application, the second communication variable is used to indicate the buffer where the sending end application last wrote data; determining the first target buffer based on the second communication variable and the first communication variable. Wherein, when the first target buffer is determined based on the second communication variable and the first communication variable, the embodiment steps may also include: determining the first target buffer to be the second buffer when the second communication variable indicates that the buffer where the sending end application last wrote data is the first buffer, and the first communication variable indicates that the receiving end application currently does not occupy the buffer; or determining the first target buffer to be the first buffer when the second communication variable indicates that the buffer where the sending end application last wrote data is the second buffer, and the first communication variable indicates that the receiving end application currently does not occupy the buffer. Wherein, the second communication variable is also obtained in the shared area of the operating system when the operating system is in system mode. The specific acquisition process can refer to the relevant description of the acquisition of the first communication variable in step 101 of the embodiment, which will not be repeated here.
[0055] Accordingly, for the embodiment of the present disclosure, when determining the first target buffer based on the second communication variable and the first communication variable:
[0056] As a possible implementation, when the first communication variable indicates that the buffer currently read by the receiving end application is the first buffer or no buffer is occupied, and the second communication variable indicates that the buffer previously written by the sending end application is the first buffer, the first target buffer can be determined to be the second buffer, and the sending end application can write communication data to the second buffer. That is, LastBestFlg is equal to A, and ReadHoldFlg is not equal to B, the Sender OS-Application last wrote Buffer_A, and the Receiver OS-Application did not read and occupy Buffer_B, which means that data can be written to Buffer_B at present.
[0057] As a possible implementation, when the first communication variable indicates that the buffer currently reading data from the receiving end application is the first buffer, and the second communication variable indicates that the buffer previously written data from the sending end application is the second buffer, the first target buffer can be determined to be the second buffer, and the sending end application can write communication data to the second buffer. That is, LastBestFlg is equal to B, and ReadHoldFlg is equal to A, the Sender OS-Application last wrote Buffer_B, but the Receiver OS-Application is reading and occupying Buffer_A, which means that Buffer_A cannot be written at present, and can only be written to Buffer_B again.
[0058] As a possible implementation, when the first communication variable indicates that the buffer currently read by the receiving end application is the second buffer or no buffer is occupied, and the second communication variable indicates that the buffer previously written by the sending end application is the second buffer, the first target buffer can be determined to be the first buffer, and the sending end application can write communication data to the first buffer. That is, LastBestFlg is equal to B, and ReadHoldFlg is not equal to A, the Sender OS-Application last wrote Buffer_B, and the Receiver OS-Application did not read and occupy Buffer_A, which means that data can be written to Buffer_A at present.
[0059] As a possible implementation, when the first communication variable indicates that the buffer currently reading data from the receiving end application is the second buffer, and the second communication variable indicates that the buffer previously written data from the sending end application is the first buffer, the first target buffer can be determined to be the first buffer, and the sending end application can write communication data to the first buffer. That is, LastBestFlg is equal to A, and ReadHoldFlg is equal to B, the Sender OS-Application last wrote Buffer_A, but the Receiver OS-Application is reading and occupying Buffer_B, which means that Buffer_B cannot be written at present, and Buffer_A can only be written again.
[0060] For the disclosed embodiment, due to the existence of LastBestFlg, the Sender OS-Application and the Receiver OS-Application can logically stagger the read and write accesses. Under normal circumstances, whenever the Receiver OS-Application is to read a buffer, it will be separate from the buffer that the Sender OS-Application is to write, so there will be no concurrent access to shared resources. In abnormal circumstances, such as when the Sender OS-Application takes too long to write data in a Buffer. At this time, since LastBestFlg indicates another Buffer, it has no effect on the read operation and will not affect the normal operation of the Receiver OS-Application.
[0061] Step 103: Send communication data to a receiving application by performing a data write operation on the first target buffer.
[0062] For the embodiment of the present disclosure, when sending communication data to a receiving application by performing a data write operation on a first target buffer:
[0063] As a possible implementation method, when the first target buffer is the second buffer, communication data is sent to the receiving application by performing the following first data write operation: writing communication data to the second buffer to support the receiving application to read the communication data in the second buffer; during the communication data writing process, assigning a first identifier to the third communication variable of the sending application; after the communication data writing is completed, assigning a second identifier to the third communication variable of the sending application, and assigning a first identifier to the second communication variable.
[0064] Among them, when the third communication variable is assigned the first identifier, it is used to indicate that the buffer to which the sending application currently writes data is the second buffer; when the third communication variable is assigned the second identifier, it is used to indicate that the sending application no longer occupies the second buffer; when the second communication variable is assigned the first identifier, it is used to indicate that the buffer to which the sending application previously wrote data is the second buffer. The first identifier may be an occupation identifier corresponding to the second buffer, such as "B", and the second identifier may be a release identifier corresponding to the second buffer, such as "0". When executing the first data writing operation, the sending application may first assign B to the third communication variable (WriteHoldFlg), indicating that Buffer_B is to be written and occupied, and the receiving application cannot read data from Buffer_B at this stage; then the sending application may write the communication data into Buffer_B, and after the communication data is written, WriteHoldFlg may be assigned 0, indicating that Buffer_B is no longer occupied, and the receiving application may read data from Buffer_B. In addition, after the communication data is written, the second communication variable (LastBestFlg) can be assigned a value of B, indicating that the buffer where the sending application last wrote data is Buffer_B, which helps the sending application and the receiving application determine the communication access mechanism for the next stage.
[0065] As a possible implementation method, when the first target buffer is the first buffer, communication data is sent to the receiving application by performing the following second data write operation: writing communication data to the first buffer to support the receiving application to read the communication data in the first buffer; during the communication data writing process, assigning a third identifier to the third communication variable of the sending application; after the communication data writing is completed, assigning a fourth identifier to the third communication variable of the sending application, and assigning a third identifier to the second communication variable.
[0066] Among them, when the third communication variable is assigned the third identifier, it is used to indicate that the buffer to which the sending application currently writes data is the first buffer; when the third communication variable is assigned the fourth identifier, it is used to indicate that the sending application no longer occupies the first buffer; when the second communication variable is assigned the third identifier, it is used to indicate that the buffer to which the sending application previously wrote data is the first buffer. The third identifier can be an occupation identifier corresponding to the first buffer, such as "A", and the second identifier can be a release identifier corresponding to the first buffer, such as "0". When executing the second data writing operation, the sending application can first assign A to the third communication variable (WriteHoldFlg), indicating that Buffer_A is to be written and occupied. At this time, the receiving application cannot read data from Buffer_A at this stage; then the sending application can write the communication data to Buffer_A. After the communication data is written, WriteHoldFlg can be assigned 0, indicating that Buffer_A is no longer occupied. At this time, the receiving application can read data from Buffer_A. In addition, after the communication data is written, the second communication variable (LastBestFlg) can be assigned a value of A, indicating that the buffer where the sending application last wrote data is Buffer_A, which helps the sending application and the receiving application determine the communication access mechanism for the next stage.
[0067] In order to facilitate the understanding of the disclosed technical solution, Figure 4 A complete description of the scheme in this disclosure is provided, such as Figure 4 As shown, when the sending application writes communication data to the IOC, it can determine whether LastBestFlg is equal to A (i.e., whether the buffer where the sending application last wrote data is the first buffer). When it is determined that LastBestFlg is equal to A, it can further determine whether ReadHoldFlg is not equal to B (i.e., whether the buffer where the receiving application currently reads data is not the second buffer). When it is determined that LastBestFlg is equal to A and ReadHoldFlg is not equal to B (i.e., the Sender OS-Application last wrote Buffer_A, and the Receiver OS-Application did not read and occupy Buffer_B), the data can be written to Buffer_B. The specific operations for writing data to Buffer_B can be as follows: WriteHoldFlg is assigned a value of B, indicating that Buffer_B is to be written and occupied; input data is written to Buffer_B; WriteHoldFlg is assigned a value of 0, indicating that Buffer_B is no longer occupied; LastBestFlg is assigned a value of B, indicating that Buffer_B was written last.
[0068] When it is determined that LastBestFlg is equal to A and ReadHoldFlg is equal to B (i.e. the Sender OS-Application last wrote Buffer_A, but the Receiver OS-Application is reading and occupying Buffer_B), it means that Buffer_B cannot be written at present and Buffer_A can only be written again. The specific operations for writing data to Buffer_A are as follows: WriteHoldFlg is assigned a value of A, indicating that Buffer_A is to be written and occupied; input data is written to Buffer_A; WriteHoldFlg is assigned a value of 0, indicating that Buffer_A is no longer occupied; LastBestFlg is assigned a value of A, indicating that Buffer_A was last written.
[0069] When it is determined that LastBestFlg is equal to B and WriteHoldFlg is not equal to A (i.e., the Sender OS-Application last wrote Buffer_B, and the Receiver OS-Application did not read and occupy Buffer_A), the data can be written into Buffer_A. The specific operations for writing data into Buffer_A are as follows: WriteHoldFlg is assigned a value of A, indicating that Buffer_A is to be written and occupied; input data is written into Buffer_A; WriteHoldFlg is assigned a value of 0, indicating that Buffer_A is no longer occupied; LastBestFlg is assigned a value of A, indicating that Buffer_A was last written.
[0070] When it is determined that LastBestFlg is equal to B and WriteHoldFlg is equal to A (i.e., the Sender OS-Application last wrote Buffer_B, but the Receiver OS-Application is reading and occupying Buffer_A), it means that Buffer_A cannot be written at present and Buffer_B can only be written again. The specific operations for writing data to Buffer_B are as follows: WriteHoldFlg is assigned a value of B, indicating that Buffer_B is to be written and occupied; input data is written to Buffer_B; WriteHoldFlg is assigned a value of 0, indicating that Buffer_B is no longer occupied; LastBestFlg is assigned a value of B, indicating that Buffer_B was last written.
[0071] In summary, according to the inter-application communication method provided by the present application, the sending application may first obtain the first communication variable, the first communication variable is used to indicate whether the receiving application currently occupies the buffer, and when the receiving application currently occupies the buffer, indicates that the receiving application occupies the buffer for reading data; then the first target buffer may be determined based on the first communication variable, and the communication data may be sent to the receiving application by performing a data write operation on the first target buffer. The first target buffer is a buffer other than the buffer occupied by the receiving application for reading data. The technical solution disclosed in the present invention can make the sending application and the receiving application logically staggered in read and write access. Whenever the buffer to be read by the sending application is staggered with the buffer to be written by the receiving application, there will be no concurrent access to the shared data in the same buffer. Since the sending application and the receiving application can perform read and write access in different buffers at the same time, there is no need to spin and wait for the release of the same buffer, so there will be no consumption of CPU resources. In addition, the reading and writing processes of the sending application and the receiving application can be performed simultaneously without waiting, which can improve the communication efficiency between applications.
[0072] like Figure 5 , an embodiment of the present disclosure provides an inter-application communication method, which can be applied to a receiving-end application, including:
[0073] Step 201: Obtain a third communication variable of the sending application, where the third communication variable is used to indicate whether the sending application currently occupies a buffer, and if the sending application currently occupies a buffer, indicate that the sending application occupies a buffer for writing data.
[0074] In a specific application scenario, five variables may be predefined in the shared area (Inter OS-Application Communication, IOC) of the operating system: the first buffer (Buffer_A), the second buffer (Buffer_B), the first communication variable (ReadHoldFlg), the second communication variable (LastBestFlg) and the third communication variable (WriteHoldFlg). The first communication variable is used to indicate whether the receiving end application (Receiver OS-Application) currently occupies the buffer, and if the receiving end application currently occupies the buffer, indicates the specific buffer occupied by the receiving end application for reading data. If the receiving application currently does not occupy the buffer, it can indicate that the buffer currently occupied by reading data is 0 (no buffer is occupied); if the receiving application currently occupies the buffer, it can indicate whether the buffer currently occupied by reading data is Buffer_A or Buffer_B, or no buffer is occupied; the second communication variable (LastBestFlg) is used to indicate the buffer where the sending application (Sender OS-Application) last wrote data, such as indicating that the buffer where the last data was written is Buffer_A or Buffer_B; the third communication variable (WriteHoldFlg) is used to indicate whether the sending application (Sender OS-Application) currently occupies the buffer, and if the sending application currently occupies the buffer, it indicates the specific buffer occupied by the sending application for writing data. If the sending application currently does not occupy the buffer, it can indicate that the buffer currently occupied by writing data is 0 (no buffer is occupied); if the sending application currently occupies the buffer, it can indicate whether the buffer currently written data is Buffer_A or Buffer_B.
[0075] In a specific application scenario, due to the need for software isolation, the MPU configured for the receiving end application (Receiver OS-Application) has no permission to read and write access to the above five variables in the shared area, so access can be achieved through an OS trap (Trap). Specifically, before executing the steps of this embodiment, the Receiver OS-Application can call IOC_Receiver (data) through the RTE function Rte_Read (data), and trigger the OS Trap exception by using the SVC instruction (i.e., sending a trap instruction to the operating system), so that the operating system switches from user mode to system mode in the case of an OS Trap exception, and realizes read and write access to the variables Buffer_A, Buffer_B, LastBestFlg, ReadHoldFlg, and WriteHoldFlg in the IOC. The embodiment steps may include: sending a trap instruction to the operating system, and the trap instruction is used to instruct the operating system to switch from user mode to system mode. Accordingly, for the embodiment of the present disclosure, in response to the operating system being in system mode, the third communication variable of the sending end application can be obtained in the shared area of the operating system.
[0076] Step 202: Determine a second target buffer based on the third communication variable, where the second target buffer is a buffer other than the buffer occupied by the sending application for writing data.
[0077] For the embodiments of the present disclosure, when the operating system is in system mode, the receiving application (Receiver OS-Application) can read the first buffer and the second buffer in the shared area IOC, and determine the buffer status of the first buffer and the second buffer (i.e., whether they are occupied by reading and writing) based on the third communication variable in the shared area IOC, and further determine the second target buffer based on the buffer status, so that the receiving application can read data in the second target buffer and stagger the read and write access to the same buffer with the sending application, thereby avoiding concurrent access to shared data in the same buffer.
[0078] Accordingly, for the embodiment of the present disclosure, when determining the second target buffer based on the third communication variable, the embodiment steps may include:
[0079] As a possible implementation, when the third communication variable indicates that the buffer to which the sender application currently writes data is the first buffer, the second target buffer can be determined to be the second buffer. That is, when the third communication variable (WriteHoldFlg) is equal to A, it means that the Sender OS-Application is writing and occupying Buffer_A, and the Receiver OS-Application can currently read data from Buffer_B.
[0080] As a possible implementation, when the third communication variable indicates that the buffer to which the sender application currently writes data is the second buffer, the second target buffer can be determined to be the first buffer. That is, when the third communication variable (WriteHoldFlg) is equal to B, it means that the Sender OS-Application is writing and occupying Buffer_B, and the Receiver OS-Application can currently read data from Buffer_A.
[0081] For the embodiments of the present disclosure, as a preferred method, when the operating system is in system mode, the receiving application (Receiver OS-Application) can read the first buffer and the second buffer in the shared area IOC, and determine the buffer status of the first buffer and the second buffer (i.e., whether they are occupied by reading and writing) based on the second communication variable and the third communication variable in the shared area IOC, and further determine the second target buffer based on the buffer status, so that the receiving application can read data in the second target buffer, and stagger the read and write access to the same buffer with the sending application, avoiding concurrent access to shared data in the same buffer. At the same time, when there are multiple buffers supporting the current reading of data by the receiving application, the buffer where the receiving application reads data is the same as the buffer where the sending application last wrote data, which can realize timely reading of data and avoid the sending application continuously occupying the same buffer to write data, and the receiving application cannot read data in the buffer, resulting in loss of transmission data.
[0082] Accordingly, the embodiment steps may include: obtaining a second communication variable of the sending end application, the second communication variable is used to indicate the buffer where the sending end application last wrote data; determining the second target buffer based on the second communication variable and the third communication variable. Wherein, when determining the second target buffer based on the second communication variable and the third communication variable, the embodiment steps may include: determining the second target buffer as the first buffer when the second communication variable indicates that the buffer where the sending end application last wrote data is the first buffer, and the third communication variable indicates that the sending end application currently does not occupy the buffer; or determining the second target buffer as the second buffer when the second communication variable indicates that the buffer where the sending end application last wrote data is the second buffer, and the third communication variable indicates that the sending end application currently does not occupy the buffer. Wherein, the second communication variable is also obtained in the shared area of the operating system when the operating system is in system mode. The specific acquisition process can refer to the relevant description of the acquisition of the third communication variable in step 201 of the embodiment, which will not be repeated here.
[0083] Accordingly, for the embodiment of the present disclosure, when determining the second target buffer based on the second communication variable and the third communication variable:
[0084] As a possible implementation, when the third communication variable indicates that the buffer into which the sender application currently writes data is the first buffer, and the second communication variable indicates that the buffer into which the sender application previously wrote data is the first buffer, the second target buffer is determined to be the second buffer, and the receiver application can read the communication data in the second buffer. That is, LastBestFlg is equal to A, and WriteHoldFlg is equal to A, that is, the sender OS-Application last wrote Buffer_A, but the sender OS-Application is writing and occupying Buffer_A, which means that Buffer_A cannot be read currently, and data can only be read from Buffer_B.
[0085] As a possible implementation, when the third communication variable indicates that the buffer to which the sender application currently writes data is the first buffer or the buffer is not occupied, and the second communication variable indicates that the buffer to which the sender application previously wrote data is the second buffer, the second target buffer is determined to be the second buffer, and the receiver application can read the communication data in the second buffer. That is, LastBestFlg is equal to B, and WriteHoldFlg is not equal to B, that is, the sender OS-Application last wrote Buffer_B, and the sender OS-Application did not write and occupy Buffer_B, which means that data can be read from Buffer_B currently.
[0086] As a possible implementation, when the third communication variable indicates that the buffer to which the sender application currently writes data is the second buffer, and the second communication variable indicates that the buffer to which the sender application previously wrote data is the second buffer, the second target buffer is determined to be the first buffer, and the receiver application can read the communication data in the first buffer. That is, LastBestFlg is equal to B, and WriteHoldFlg is equal to B, that is, the sender OS-Application last wrote Buffer_B, but the sender OS-Application is writing and occupying Buffer_B, which means that Buffer_B cannot be read currently, and data can only be read from Buffer_A.
[0087] As a possible implementation, when the third communication variable indicates that the buffer to which the sender application currently writes data is the second buffer or the buffer is not occupied, and the second communication variable indicates that the buffer to which the sender application previously wrote data is the first buffer, the second target buffer is determined to be the first buffer, and the receiver application can read the communication data in the first buffer. That is, LastBestFlg is equal to A, and WriteHoldFlg is not equal to A, that is, the sender OS-Application last wrote Buffer_A, and the sender OS-Application did not write and occupy Buffer_A, which means that data can be read from Buffer_A currently.
[0088] For the disclosed embodiment, due to the existence of LastBestFlg, the Sender OS-Application and the Receiver OS-Application can logically stagger the read and write accesses. Under normal circumstances, whenever the Receiver OS-Application is to read a buffer, it will be separate from the buffer that the Sender OS-Application is to write, so there will be no concurrent access to shared resources. In abnormal circumstances, such as when the Sender OS-Application takes too long to read data from a Buffer. At this time, since LastBestFlg indicates another Buffer, it has no effect on the write operation and will not affect the normal operation of the Sender OS-Application.
[0089] Step 203: Receive the communication data sent by the sending application by performing a data read operation on the second target buffer.
[0090] For the embodiment of the present disclosure, when receiving communication data sent by the sending application by performing a data read operation on the second target buffer:
[0091] As a possible implementation method, when the second target buffer is the second buffer, the communication data sent by the sending application is received by performing the following first data reading operation: reading the communication data sent by the sending application in the second buffer; during the communication data reading process, assigning a first identifier to the first communication variable of the receiving application; after the communication data reading is completed, assigning a second identifier to the first communication variable of the receiving application.
[0092] Among them, when the first communication variable is assigned the first identifier, it is used to indicate that the buffer currently reading data by the receiving application is the second buffer; when the first communication variable is assigned the second identifier, it is used to indicate that the receiving application no longer occupies the second buffer. The first identifier can be an occupation identifier corresponding to the second buffer, such as "B", and the second identifier can be a release identifier corresponding to the second buffer, such as "0". When executing the first data reading operation, the receiving application can first assign B to the first communication variable (ReadHoldFlg), indicating that Buffer_B is to be read and occupied. At this time, the sending application cannot write data to Buffer_B at this stage; then the receiving application can read data from Buffer_B; after the communication data is read, ReadHoldFlg can be assigned 0, indicating that Buffer_B is no longer occupied, and the sending application can write data to Buffer_B.
[0093] As a possible implementation method, when the second target buffer is the first buffer, the communication data sent by the sending application is received by performing the following second data reading operation: reading the communication data sent by the sending application in the first buffer; during the communication data reading process, assigning a third identifier to the first communication variable of the receiving application; after the communication data reading is completed, assigning a fourth identifier to the first communication variable of the receiving application.
[0094] Among them, when the first communication variable is assigned the third identifier, it is used to indicate that the buffer currently reading data by the receiving application is the first buffer; when the first communication variable is assigned the fourth identifier, it is used to indicate that the receiving application no longer occupies the first buffer. The third identifier can be the occupation identifier corresponding to the first buffer, such as "A", and the second identifier can be the release identifier corresponding to the first buffer, such as "0". When executing the second data reading operation, the receiving application can first assign A to the first communication variable (ReadHoldFlg), indicating that Buffer_A is to be read and occupied. At this time, the sending application cannot write data to Buffer_A at this stage; then the receiving application can read data from Buffer_A; after the communication data is read, ReadHoldFlg can be assigned 0, indicating that Buffer_A is no longer occupied, and the sending application can write data to Buffer_B.
[0095] In order to facilitate the understanding of the disclosed technical solution, Figure 6 A complete description of the scheme in this disclosure is provided, such as Figure 6 As shown, when the receiving application reads the communication data at the IOC, it can determine whether LastBestFlg is equal to A (i.e., whether the buffer where the sending application last wrote data is the first buffer). When it is determined that LastBestFlg is equal to A, it can further determine whether WriteHoldFlg is not equal to A (i.e., whether the buffer where the sending application currently writes data is not the first buffer). When it is determined that LastBestFlg is equal to A and WriteHoldFlg is not equal to A (i.e., the Sender OS-Application last wrote Buffer_A, and the Sender OS-Application did not write to occupy Buffer_A), it means that data can be read from Buffer_A at present. The specific operations for reading data in Buffer_A can be as follows: ReadHoldFlg is assigned a value of A, indicating that Buffer_A is to be read and occupied; data is read from Buffer_A; ReadHoldFlg is assigned a value of 0, indicating that Buffer_A is no longer occupied.
[0096] When it is determined that LastBestFlg is equal to A and WriteHoldFlg is equal to A (i.e., the Sender OS-Application last wrote Buffer_A, but the Sender OS-Application is writing and occupying Buffer_A), it means that Buffer_A cannot be read at present and data can only be read from Buffer_B. The specific operations for reading data from Buffer_B are as follows: ReadHoldFlg is assigned a value of B, indicating that Buffer_B is to be read and occupied; data is read from Buffer_B; ReadHoldFlg is assigned a value of 0, indicating that Buffer_B is no longer occupied.
[0097] When it is determined that LastBestFlg is equal to B and WriteHoldFlg is not equal to B (i.e., the Sender OS-Application last wrote Buffer_B and the Sender OS-Application did not write and occupy Buffer_B), it means that data can be read from Buffer_B. The specific operations for reading data from Buffer_B are as follows: ReadHoldFlg is assigned a value of B, indicating that Buffer_B is to be read and occupied; data is read from Buffer_B; ReadHoldFlg is assigned a value of 0, indicating that Buffer_B is no longer occupied.
[0098] When it is determined that LastBestFlg is equal to B and WriteHoldFlg is equal to B (i.e., the Sender OS-Application last wrote Buffer_B, but the Sender OS-Application is writing and occupying Buffer_B), it means that Buffer_B cannot be read at present and data can only be read from Buffer_A. The specific operations for reading data from Buffer_A are as follows: ReadHoldFlg is assigned a value of A, indicating that Buffer_A is to be read and occupied; data is read from Buffer_A; ReadHoldFlg is assigned a value of 0, indicating that Buffer_A is no longer occupied.
[0099] In summary, according to the inter-application communication method provided by the present application, the receiving application can first obtain the third communication variable of the sending application, and the third communication variable is used to indicate whether the sending application currently occupies the buffer, and when the sending application currently occupies the buffer, it indicates that the sending application occupies the buffer for writing data; then the second target buffer can be determined based on the third communication variable, and the communication data sent by the sending application is received by performing a data read operation on the second target buffer, wherein the second target buffer is other buffers other than the buffer occupied by the sending application for writing data. The technical solution in the present disclosure can make the sending application and the receiving application logically staggered in read and write access, and whenever the buffer to be read by the sending application is staggered with the buffer to be written by the receiving application, there will be no concurrent access to the shared data in the same buffer. Since the sending application and the receiving application can perform read and write access in different buffers at the same time, there is no need to spin and wait for the release of the same buffer, so it will not cause consumption of CPU resources. In addition, the reading and writing processes of the sending application and the receiving application can be carried out simultaneously without waiting, which can improve the communication efficiency between applications.
[0100] Based on the above Figure 3 , Figure 4 The specific implementation of the method shown in the embodiment provides an inter-application communication device, which is applied to a sending end application, such as Figure 7 , the device comprises:
[0101] A first acquisition module 31, which can be used to acquire a first communication variable of a receiving-end application, where the first communication variable is used to indicate whether the receiving-end application currently occupies a buffer zone, and if the receiving-end application currently occupies a buffer zone, indicates that the receiving-end application occupies a buffer zone for reading data;
[0102] A first determination module 32, which can be used to determine a first target buffer based on the first communication variable, where the first target buffer is a buffer other than the buffer occupied by the receiving end application for reading data;
[0103] The first sending module 33 may be used to send communication data to a receiving end application by performing a data writing operation on a first target buffer.
[0104] In a specific application scenario, the shared area of the operating system where the sending application and the receiving application are located includes a first buffer and a second buffer. The first determination module 32 can be used to determine that the first target buffer is the second buffer when the first communication variable indicates that the buffer currently reading data by the receiving application is the first buffer; or determine that the first target buffer is the first buffer when the first communication variable indicates that the buffer currently reading data by the receiving application is the second buffer.
[0105] In a specific application scenario, the first acquisition module 31 can also be used to acquire the second communication variable of the sending application, the second communication variable is used to indicate the buffer where the sending application last wrote data; the first determination module 32 can also be used to determine the first target buffer based on the second communication variable and the first communication variable; the first determination module 32 can be specifically used to determine that the first target buffer is the second buffer when the second communication variable indicates that the buffer where the sending application last wrote data is the first buffer, and the first communication variable indicates that the receiving application currently does not occupy the buffer; or determine that the first target buffer is the first buffer when the second communication variable indicates that the buffer where the sending application last wrote data is the second buffer, and the first communication variable indicates that the receiving application currently does not occupy the buffer.
[0106] In a specific application scenario, the first sending module 33 can be used to send communication data to the receiving application by performing the following first data writing operation when the first target buffer is the second buffer: writing communication data to the second buffer to support the receiving application to read communication data in the second buffer; during the communication data writing process, assigning a first identifier to the third communication variable of the sending application; after the communication data is written, assigning a second identifier to the third communication variable of the sending application, and assigning the first identifier to the second communication variable; or when the first target buffer is the first buffer, sending communication data to the receiving application by performing the following second data writing operation: writing communication data to the first buffer to support the receiving application to read communication data in the first buffer; during the communication data writing process, assigning a second identifier to the third communication variable of the sending application. a third identifier; after the communication data is written, a fourth identifier is assigned to the third communication variable of the sending application, and a third identifier is assigned to the second communication variable; wherein, when the first identifier is assigned to the third communication variable, it is used to indicate that the buffer into which the sending application currently writes data is the second buffer; when the second identifier is assigned to the third communication variable, it is used to indicate that the sending application no longer occupies the second buffer; when the third identifier is assigned to the third communication variable, it is used to indicate that the buffer into which the sending application currently writes data is the first buffer; when the fourth identifier is assigned to the third communication variable, it is used to indicate that the sending application no longer occupies the first buffer; when the first identifier is assigned to the second communication variable, it is used to indicate that the buffer into which the sending application previously wrote data was the second buffer; when the third communication variable is assigned to the third identifier, it is used to indicate that the buffer into which the sending application previously wrote data was the first buffer.
[0107] In a specific application scenario, the first sending module 33 can also be used to send a trap instruction to the operating system, and the trap instruction is used to instruct the operating system to switch from user mode to system mode; accordingly, the first acquisition module 31 can be used to obtain the second communication variable of the sending application in the shared area of the operating system in response to the operating system being in system mode, and to obtain the first communication variable of the receiving application.
[0108] Based on the above Figure 5 , Figure 6 The specific implementation of the method shown in the embodiment provides an inter-application communication device, which is applied to a receiving end application, such as Figure 8 , the device comprises:
[0109] A second acquisition module 41 may be used to acquire a third communication variable of the sending end application, the third communication variable being used to indicate whether the sending end application currently occupies a buffer, and if the sending end application currently occupies the buffer, indicating that the sending end application occupies a buffer for writing data;
[0110] A second determination module 42, which can be used to determine a second target buffer based on the third communication variable, where the second target buffer is another buffer other than the buffer occupied by the sending end application to write data;
[0111] The receiving module 43 may be used to receive the communication data sent by the sending application by performing a data reading operation on the second target buffer.
[0112] In a specific application scenario, the shared area of the operating system where the sending application and the receiving application are located includes a first buffer and a second buffer. The second determination module 42 can be used to determine that the second target buffer is the second buffer when the third communication variable indicates that the buffer currently writing data by the sending application is the first buffer; or to determine that the second target buffer is the first buffer when the third communication variable indicates that the buffer currently writing data by the sending application is the second buffer.
[0113] In a specific application scenario, the second acquisition module 41 can also be used to acquire a second communication variable of the sending application, where the second communication variable is used to indicate the buffer where the sending application last wrote data; the second determination module 42 can also be used to determine a second target buffer based on the second communication variable and the third communication variable; the second determination module 42 can specifically be used to determine that the second target buffer is the first buffer when the second communication variable indicates that the buffer where the sending application last wrote data is the first buffer, and the third communication variable indicates that the sending application currently does not occupy the buffer; or determine that the second target buffer is the second buffer when the second communication variable indicates that the buffer where the sending application last wrote data is the second buffer, and the third communication variable indicates that the sending application currently does not occupy the buffer.
[0114] In a specific application scenario, the receiving module 43 can be used to receive the communication data sent by the sending application by performing the following first data reading operation when the second target buffer is the second buffer: reading the communication data sent by the sending application in the second buffer; assigning a first identifier to the first communication variable of the receiving application during the communication data reading process; after the communication data reading is completed, assigning a second identifier to the first communication variable of the receiving application; or when the second target buffer is the first buffer, receiving the communication data sent by the sending application by performing the following second data reading operation: reading the communication data sent by the sending application in the first buffer communication data; during the communication data reading process, assigning a third identifier to the first communication variable of the receiving application; after the communication data reading is completed, assigning a fourth identifier to the first communication variable of the receiving application; wherein, when the first communication variable is assigned the first identifier, it is used to indicate that the buffer currently reading data by the receiving application is the second buffer; when the first communication variable is assigned the second identifier, it is used to indicate that the receiving application no longer occupies the second buffer; when the first communication variable is assigned the third identifier, it is used to indicate that the buffer currently reading data by the receiving application is the first buffer; when the first communication variable is assigned the fourth identifier, it is used to indicate that the receiving application no longer occupies the first buffer.
[0115] In specific application scenarios, such as Figure 8 As shown, the device also includes: a second sending module 44;
[0116] The second sending module 44 can be used to send a trap instruction to the operating system, and the trap instruction is used to instruct the operating system to switch from user mode to system mode; accordingly, the second acquisition module 41 can be used to obtain the second communication variable and the third communication variable of the sending application in the shared area of the operating system in response to the operating system being in system mode.
[0117] It should be noted that for other corresponding descriptions of the functional units involved in the inter-application communication device provided in this embodiment, reference can be made to Figure 3 and Figure 5 The corresponding description in will not be repeated here.
[0118] Based on the above Figure 3 and Figure 5 The method shown in the embodiment also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned Figure 3 and Figure 5 The method shown.
[0119] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of the present application.
[0120] Based on the above Figure 3 and Figure 5 The method shown, and Figure 7 and Figure 8 In order to achieve the above-mentioned purpose, the embodiment of the present application also provides an electronic device that can be configured on the vehicle (such as an electric vehicle) side, and the device includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figure 3 and Figure 5 The method shown.
[0121] Optionally, the above-mentioned physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.
[0122] Those skilled in the art will appreciate that the above-mentioned physical device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different arrangements of components.
[0123] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the above-mentioned physical device, and supports the operation of the information processing program and other software and / or programs. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.
[0124] Based on the above electronic device, the embodiment of the present application further provides a vehicle, which may specifically include: the above electronic device. The vehicle may specifically be an electric car, etc.
[0125] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform, or by hardware. The technical solution in the present disclosure can make the sending-end application and the receiving-end application logically staggered in read and write access. Whenever the sending-end application is to read a buffer, it is staggered with the receiving-end application to write a buffer, so there will be no concurrent access to shared data in the same buffer. Since the sending-end application and the receiving-end application can perform read and write access to different buffers at the same time, there is no need to spin and wait for the release of the same buffer, so there will be no consumption of CPU resources.
[0126] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprising a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0127] The above is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to these embodiments herein, but will conform to the widest scope consistent with the principles and novel features applied for herein.
Claims
1. A method for communication between applications, It is characterized in that include: Acquire a first communication variable of a receiving-end application, the first communication variable being used to indicate whether the receiving-end application currently occupies a buffer zone, and, if the receiving-end application currently occupies a buffer zone, indicating that the receiving-end application occupies a buffer zone for reading data; Determine a first target buffer based on the first communication variable, where the first target buffer is other buffers other than the buffer occupied by the receiving end application for reading data; The communication data is sent to the receiving application by performing a data write operation on the first target buffer.
2. The method according to claim 1, It is characterized in that The shared area of the operating system where the sending end application and the receiving end application are located includes a first buffer and a second buffer, and the determining of the first target buffer based on the first communication variable includes: In the case where the first communication variable indicates that the buffer currently reading data by the receiving application is the first buffer, determining the first target buffer to be the second buffer; or When the first communication variable indicates that the buffer currently reading data from the receiving-end application is the second buffer, the first target buffer is determined to be the first buffer.
3. The method according to claim 2, It is characterized in that The method further comprises: Acquire a second communication variable of the sending application, where the second communication variable is used to indicate a buffer where the sending application previously wrote data; determining a first target buffer based on the second communication variable and the first communication variable; The determining of the first target buffer based on the second communication variable and the first communication variable comprises: When the second communication variable indicates that the buffer into which the sending application previously wrote data is the first buffer, and the first communication variable indicates that the receiving application currently does not occupy a buffer, determining that the first target buffer is the second buffer; or When the second communication variable indicates that the buffer into which the sending application previously wrote data is the second buffer, and the first communication variable indicates that the receiving application currently does not occupy a buffer, the first target buffer is determined to be the first buffer.
4. The method according to claim 2 or 3, It is characterized in that The sending of communication data to the receiving end application by performing a data write operation on the first target buffer comprises: In the case where the first target buffer is the second buffer, the communication data is sent to the receiving application by performing the following first data writing operation: writing the communication data to the second buffer to support the receiving application to read the communication data in the second buffer; during the communication data writing process, assigning a first identifier to a third communication variable of the sending application; after the communication data is written, assigning a second identifier to the third communication variable of the sending application, and assigning the first identifier to the second communication variable; or In the case where the first target buffer is the first buffer, the communication data is sent to the receiving application by performing the following second data writing operation: writing the communication data to the first buffer to support the receiving application to read the communication data in the first buffer; assigning a third identifier to a third communication variable of the sending application during the communication data writing process; after the communication data is written, assigning a fourth identifier to the third communication variable of the sending application, and assigning the third identifier to the second communication variable; Among them, when the third communication variable is assigned the first identifier, it is used to indicate that the buffer where the sending application currently writes data is the second buffer; when the third communication variable is assigned the second identifier, it is used to indicate that the sending application no longer occupies the second buffer; when the third communication variable is assigned the third identifier, it is used to indicate that the buffer where the sending application currently writes data is the first buffer; when the third communication variable is assigned the fourth identifier, it is used to indicate that the sending application no longer occupies the first buffer; when the second communication variable is assigned the first identifier, it is used to indicate that the buffer where the sending application previously wrote data was the second buffer; when the second communication variable is assigned the third identifier, it is used to indicate that the buffer where the sending application previously wrote data was the first buffer.
5. The method according to any one of claims 1 to 3, It is characterized in that Before obtaining the first communication variable of the receiving-end application, the method further includes: Sending a trap instruction to the operating system, wherein the trap instruction is used to instruct the operating system to switch from the user mode to the system mode; The obtaining of the first communication variable of the receiving-end application comprises: In response to the operating system being in system mode, acquiring a first communication variable of a receiving-end application in a shared area of the operating system; The obtaining of the second communication variable of the sending end application comprises: In response to the operating system being in the system mode, a second communication variable of the sending-end application is acquired in a shared area of the operating system.
6. A method for communication between applications, It is characterized in that include: Acquire a third communication variable of the sending end application, the third communication variable being used to indicate whether the sending end application currently occupies a buffer, and, if the sending end application currently occupies a buffer, indicating that the sending end application occupies a buffer for writing data; Determine a second target buffer based on the third communication variable, where the second target buffer is another buffer other than the buffer occupied by the sending application to write data; The communication data sent by the sending application is received by performing a data read operation on the second target buffer.
7. The method according to claim 6, It is characterized in that The shared area of the operating system where the sending end application and the receiving end application are located includes a first buffer and a second buffer, and the determining of the second target buffer based on the third communication variable includes: In a case where the third communication variable indicates that the buffer currently writing data by the sending application is the first buffer, determining that the second target buffer is the second buffer; or When the third communication variable indicates that the buffer into which the sending application currently writes data is the second buffer, the second target buffer is determined to be the first buffer.
8. The method according to claim 7, It is characterized in that The method further comprises: Acquire a second communication variable of the sending application, where the second communication variable is used to indicate a buffer where the sending application previously wrote data; determining a second target buffer based on the second communication variable and the third communication variable; The determining of the second target buffer based on the second communication variable and the third communication variable comprises: When the second communication variable indicates that the buffer into which the sending application previously wrote data is the first buffer, and the third communication variable indicates that the sending application currently does not occupy a buffer, determining that the second target buffer is the first buffer; or When the second communication variable indicates that the buffer into which the sending application previously wrote data is the second buffer, and the third communication variable indicates that the sending application currently does not occupy a buffer, the second target buffer is determined to be the second buffer.
9. The method according to claim 7 or 8, It is characterized in that The receiving the communication data sent by the sending application by performing a data read operation on the second target buffer comprises: In the case where the second target buffer is the second buffer, receiving the communication data sent by the sending application by performing the following first data reading operation: reading the communication data sent by the sending application in the second buffer; assigning a first identifier to a first communication variable of the receiving application during the communication data reading process; and assigning a second identifier to the first communication variable of the receiving application after the communication data reading is completed; or In the case where the second target buffer is the first buffer, the communication data sent by the sending application is received by performing the following second data reading operation: reading the communication data sent by the sending application in the first buffer; assigning a third identifier to a first communication variable of the receiving application during the communication data reading process; and assigning a fourth identifier to the first communication variable of the receiving application after the communication data reading is completed. Among them, when the first communication variable is assigned the first identifier, it is used to indicate that the buffer currently reading data by the receiving application is the second buffer; when the first communication variable is assigned the second identifier, it is used to indicate that the receiving application no longer occupies the second buffer; when the first communication variable is assigned the third identifier, it is used to indicate that the buffer currently reading data by the receiving application is the first buffer; when the first communication variable is assigned the fourth identifier, it is used to indicate that the receiving application no longer occupies the first buffer.
10. The method according to any one of claims 6 to 8, It is characterized in that Before obtaining the third communication variable of the sending-end application, the method further includes: Sending a trap instruction to the operating system, wherein the trap instruction is used to instruct the operating system to switch from the user mode to the system mode; The obtaining of the third communication variable of the sending end application comprises: In response to the operating system being in system mode, acquiring a third communication variable of the sending-end application in a shared area of the operating system; The obtaining of the second communication variable of the sending end application comprises: In response to the operating system being in the system mode, a second communication variable of the sending-end application is acquired in a shared area of the operating system.
11. An inter-application communication device, It is characterized in that include: A first acquisition module is used to acquire a first communication variable of a receiving-end application, wherein the first communication variable is used to indicate whether the receiving-end application currently occupies a buffer zone, and when the receiving-end application currently occupies a buffer zone, indicates that the receiving-end application occupies a buffer zone for reading data; A first determination module is used to determine a first target buffer based on the first communication variable, where the first target buffer is other buffers other than the buffer occupied by the receiving end application for reading data; The first sending module is used to send communication data to the receiving end application by performing a data writing operation on the first target buffer.
12. An inter-application communication device, It is characterized in that include: A second acquisition module is used to acquire a third communication variable of the sending end application, wherein the third communication variable is used to indicate whether the sending end application currently occupies a buffer zone, and when the sending end application currently occupies a buffer zone, indicates that the sending end application occupies a buffer zone for writing data; A second determination module is used to determine a second target buffer based on the third communication variable, where the second target buffer is another buffer other than the buffer occupied by the sending application to write data; The receiving module is used to receive the communication data sent by the sending application by performing a data reading operation on the second target buffer.
13. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 10 is implemented.
14. An electronic device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, It is characterized in that When the processor executes the computer program, the method according to any one of claims 1 to 10 is implemented.
15. A vehicle, It is characterized in that include: The electronic device as claimed in claim 14.
