WO2020133197A1 - 多进程间的通信方法和系统 - Google Patents

多进程间的通信方法和系统 Download PDF

Info

Publication number
WO2020133197A1
WO2020133197A1 PCT/CN2018/124805 CN2018124805W WO2020133197A1 WO 2020133197 A1 WO2020133197 A1 WO 2020133197A1 CN 2018124805 W CN2018124805 W CN 2018124805W WO 2020133197 A1 WO2020133197 A1 WO 2020133197A1
Authority
WO
WIPO (PCT)
Prior art keywords
memory
memory block
block
data
blocks
Prior art date
Application number
PCT/CN2018/124805
Other languages
English (en)
French (fr)
Inventor
王斌
周青松
晋文科
Original Assignee
深圳市大疆创新科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市大疆创新科技有限公司 filed Critical 深圳市大疆创新科技有限公司
Priority to CN201880069530.8A priority Critical patent/CN111316244A/zh
Priority to PCT/CN2018/124805 priority patent/WO2020133197A1/zh
Publication of WO2020133197A1 publication Critical patent/WO2020133197A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/08Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
    • G06F12/10Address translation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5018Thread allocation

Definitions

  • the embodiments of the present invention relate to the field of communication technologies, and in particular, to a communication method and system between multiple processes.
  • unmanned driving systems such as unmanned driving systems, robot systems, etc.
  • multiple processes are required to cooperate with each other.
  • data transmission between multiple processes is involved.
  • the unmanned driving system takes the unmanned driving system as an example.
  • the unmanned driving system runs on the drone.
  • the drone is equipped with multiple cameras, radar and other sensors.
  • the image data collected by the camera or the sensor data collected by the radar require the unmanned driving system. Transfer between different processes so that different processes can be processed.
  • process A applies for a shared memory, and notifies process B of the shared memory, so that process A and process B can share and store in the same block Data in shared memory.
  • process B applies for shared memory when the process is running, which will affect the process running efficiency.
  • Embodiments of the present invention provide a multi-process communication method and system, which are used to improve process running efficiency.
  • an embodiment of the present invention provides a multi-process communication method, including:
  • the same virtual address space is reserved for multiple processes of the mobile platform, and the same virtual address space is mapped to the same physical memory;
  • the data that the first process needs to share with the at least one second process is stored in the first memory block, and the second process is Any one of the multiple processes except the first process;
  • an embodiment of the present invention provides a multi-process communication system, including: physical memory, memory, and a processor;
  • the memory is used to store program codes
  • the processor is used to execute when the program code is called:
  • the same virtual address space is reserved for multiple processes of the mobile platform, and the same virtual address space is mapped to the same physical memory in the physical memory;
  • the data that the first process needs to share with the at least one second process is stored in the first memory block, and the second process is Any one of the multiple processes except the first process;
  • an embodiment of the present invention provides a computer-readable storage medium that stores a computer program, where the computer program includes at least one piece of code that can be executed by a computer to control The computer executes the multi-process communication method described in the first aspect of the present invention.
  • an embodiment of the present invention provides a computer program.
  • the computer program When the computer program is executed by a computer, the computer program is used to implement the multi-process communication method described in the embodiment of the present invention according to the first aspect.
  • the communication method and system between multiple processes provided by the embodiments of the present invention reserve the same virtual address space for multiple processes during the linking stage of the process, and the same virtual address space maps to the same physical memory, and from the At least one first memory block is allocated for the first process in physical memory, and the first process is any process of the plurality of processes; when the first process and at least one second process need to share data, the The data that the first process needs to share with the at least one second process is stored in the first memory block, and the second process is any process of the plurality of processes except the first process;
  • the at least one second process respectively sends a notification message, and the notification message is used to indicate an address where the data is stored in the first memory block, so that each second process uses the address from the first memory block To obtain the data.
  • this embodiment allocates memory blocks for each process during the linking phase of the process, resources that affect the process during operation are avoided, and process operating efficiency is improved. Moreover, all the allocated memory blocks belong to the same physical memory and the same virtual address space. Processes that need to share the same data can obtain the shared data through the address stored in the memory block, so as to realize the data in multiple processes (for example, 3 Zero copy transmission between the above processes) improves the communication efficiency between processes.
  • FIG. 1 is a schematic architectural diagram of an unmanned aerial system according to an embodiment of the present invention
  • FIG. 2 is a flowchart of a multi-process communication method according to an embodiment of the present invention.
  • FIG. 3 is a schematic structural diagram of a multi-process communication system according to an embodiment of the present invention.
  • a component when a component is said to be “fixed” to another component, it can be directly on another component or there can also be a centered component. When a component is considered to be “connected” to another component, it can be directly connected to another component or there may be a centered component at the same time.
  • the embodiments of the present invention provide a communication method and system between multiple processes.
  • the communication system between multiple processes can be applied to a mobile platform.
  • the movable platform may be, for example, a drone, an unmanned boat, an unmanned vehicle, a robot, or the like.
  • FIG. 1 is a schematic architecture diagram of an unmanned vehicle 100 according to an embodiment of the present invention.
  • the unmanned vehicle 100 may include a perception system 110, a control system 120, and a mechanical system 130.
  • the perception system 110 is used to measure the state information of the unmanned vehicle, that is, the perception data of the unmanned vehicle 100.
  • the perception data may represent the position information and/or state information of the unmanned vehicle 100, for example, position, angle, Speed, acceleration, angular velocity, etc.
  • the perception system 110 may include, for example, visual sensors (for example, including multiple monocular or binocular vision devices), lidar, millimeter wave radar, inertial measurement unit (Inertial Measurement Unit, IMU), global navigation satellite system, gyroscope, ultrasonic sensor , Electronic compass, barometer and other sensors.
  • the global navigation satellite system may be a global positioning system (Global Positioning System, GPS).
  • the control system 120 is used to make a decision to control how the unmanned vehicle 100 travels based on the perception data, for example: how much speed to drive, or how much brake acceleration to brake, or whether to change lanes, or , Turn left/right, etc.
  • the control system 120 may include, for example, a computing platform, such as a vehicle-mounted supercomputing platform, or at least one of processing devices such as a central processor and a distributed processing unit.
  • the control system 120 may also include communication links for various data transmissions on the vehicle.
  • the control system 120 may output one or more control instructions to the mechanical system 130 according to the determined decision.
  • the mechanical system 130 is used to control the unmanned vehicle 100 in response to one or more control commands from the control system 120 to complete the above decision, for example: the mechanical system 130 can drive the wheels of the unmanned vehicle 100 to rotate, thereby Power is provided for the driving of the unmanned vehicle 100, wherein the rotation speed of the wheels can affect the speed of the unmanned vehicle.
  • the mechanical system 130 may include, for example, at least one of a body motor/motor of a machine, a control-by-wire system, and the like.
  • the perception system on the unmanned vehicle 100 will generate a large amount of perception data that needs to be transmitted and processed, and the transmission of these data between different processes can be implemented using the solutions of the following embodiments of the present invention.
  • FIG. 2 is a flowchart of a multi-process communication method according to an embodiment of the present invention. As shown in FIG. 2, the method in this embodiment may include:
  • the same block of virtual address space is reserved for multiple processes of the mobile platform.
  • the same block of virtual address space may refer to, for example, virtual addresses being consecutive address spaces.
  • the same reserved virtual address space is mapped to the same physical memory, and the same physical memory may be, for example, a piece of physical memory, or a piece of physical memory in a piece of physical memory.
  • S202 Allocate at least one first memory block for the first process from the physical memory, and the first process is any process of the plurality of processes.
  • At least one memory block is allocated for each of the multiple processes from the same physical memory.
  • any one of the multiple processes is used as an example for description.
  • the other processes are similar, and any one process is called a first process.
  • at least one first process can be allocated to the first process from the physical memory.
  • the at least one first memory block may be used for the first process to share data with other processes.
  • the other processes may be referred to as second processes, and the second process is the plurality of processes except the first
  • the number of the second process may be at least one.
  • the data may include any one of the following: data collected by the imaging device in the movable platform, and data collected by the radar in the movable platform; but this embodiment is not limited thereto.
  • the data that the first process needs to share with the at least one second process is stored in the first memory block.
  • the shared another data is stored in another first memory block.
  • the first process can share data with some second processes at the same time, or it can share other data with other second processes; some second processes and other second processes may have the same second process, or may not exist the same The second process.
  • the first process shares a piece of data as an example for description. Sharing other data is similar and will not be repeated here.
  • a notification message is sent to the at least one second process respectively, and the notification message is used to indicate the shared The address where the data is stored in the first memory block.
  • each second process in the at least one second process obtains the share according to the address where the shared data is stored in the first memory block The data is then processed accordingly.
  • the address where the data is stored in the first memory block is a virtual address where the data is stored in the first memory block, and the virtual address belongs to the same virtual address space.
  • the same virtual address space is reserved for multiple processes, and the same virtual address space is mapped to the same physical memory and from the physical memory Allocate at least one first memory block for the first process, the first process is any process of the plurality of processes; when the first process and at least one second process need to share data, the first process The data to be shared with the at least one second process is stored in the first memory block, and the second process is any process of the plurality of processes except the first process;
  • a second process sends a notification message respectively, the notification message is used to indicate the address where the data is stored in the first memory block, so that each second process obtains the address from the first memory block according to the address ⁇ The data.
  • this embodiment allocates memory blocks for each process during the linking phase of the process, resources that affect the process during operation are avoided, and process operating efficiency is improved. Moreover, all the allocated memory blocks belong to the same physical memory and the same virtual address space. Processes that need to share the same data can obtain the shared data through the address stored in the memory block, so as to realize the data in multiple processes (for example, 3 Zero copy transmission between the above processes) improves the communication efficiency between processes.
  • the data is also deleted from the first memory block.
  • this embodiment also deletes the data from the first memory block, so that the first memory block is changed from the occupied state to Idle state to ensure that the first memory block allocated to the first process has as many free memory blocks as possible to ensure that when the first process needs to share data with other processes, the data can be stored to the first in time Memory block.
  • the number of second processes in the at least one second process may also be determined, for example, the number of second processes is N, and N is An integer greater than or equal to 1.
  • each second process accumulates the number of data acquisitions when acquiring data from the first memory block. It should be noted that when there is no second process from the first memory block When acquiring data in, the initialization of the data acquisition times is 0, and each second process acquires data from the first memory block, and the data acquisition times are increased by 1.
  • the accumulated count of data acquisition times is equal to the foregoing N, it is determined that the N second processes all acquire data from the first memory block. Then, according to the N second processes all obtain data from the first memory block, and delete the data from the first memory block.
  • a plurality of types of memory blocks are further divided from the physical memory, the number of each type of memory block is at least one, and the memory spaces of different types of memory blocks are different.
  • various types of memory blocks can be divided from the physical memory first, for example, three types of memory blocks can be divided from the physical memory, one type of memory block is a 2KB memory block, and one type of memory block is 4KB Memory block, a kind of memory block is 8KB memory block.
  • various types of memory blocks are divided from the physical memory.
  • the management process is also started.
  • a possible implementation manner of the foregoing S202 is: determining the memory space and the memory required by the first process from the plurality of types of memory blocks according to the memory space of the memory block required by the first process Memory blocks of the same type with the same memory space; according to the determined type of memory block, at least one first memory block is allocated for the first process.
  • the 4KB type of memory can be determined from the divided types of memory blocks (such as 2KB, 4KB, and 8KB three types of memory blocks) Block, and then allocate at least one 4KB type memory block to the first process according to the 4KB type memory block.
  • one possible implementation manner of dividing various types of memory blocks from the physical memory described above is: determining the memory to be divided according to the memory space of the memory blocks required by each process in multiple processes Types of blocks; according to the types of memory blocks to be divided, various types of memory blocks are divided from the physical memory. For example, there are 10 processes, the memory space of each memory block required by processes 1-3 is 2KB, the memory space of each memory block required by processes 4-6 is 4KB, and the memory space of each block required by processes 7-10 If the memory space of the block is 8KB, in this embodiment, three types of memory blocks can be divided from the physical memory, and then at least one 2KB memory block, at least one 4KB memory block, and at least one 8KB memory can be divided from the physical memory Piece.
  • the number of each type of memory block is related to the number of matching processes, and the memory space of each type of memory block is the same as the memory space required by the matching process.
  • the processes matching the 2KB memory block are processes 1-3, that is, the number of processes is 3.
  • the process matching the 4KB memory block is process 1-3, that is, the number of processes is 3, then a total of 600 4KB memory blocks can be divided from the physical memory, and even more than 600 numbers of 4KB can be allocated Memory block.
  • the process that matches the 8KB memory block is process 7-10, that is, the number of processes is 4, then a total of 800 8KB memory blocks can be divided from the physical memory, and even more than 800 8KB can be allocated.
  • Memory block is a total of 800 8KB memory blocks can be divided from the physical memory, and even more than 800 8KB can be allocated.
  • the physical memory may include: primary selected physical memory and alternate physical memory; accordingly, one possible implementation manner of dividing multiple types of memory blocks from the physical memory described above is: The multiple types of memory blocks are marked out in the primary selected physical memory.
  • the alternative physical memory is used to allocate memory blocks for the process when the main selected physical memory is insufficient.
  • the plurality of types of memory blocks include memory blocks of the same type as the memory space required by the first process ;
  • various types of memory blocks include: 2KB memory blocks, 4KB memory blocks, 8KB memory blocks, if the memory space of the memory block required by the first process is 1M, it is determined that the various types of memory blocks do not include memory
  • a memory block of the same type as the memory space of the memory required by the first process is allocated at least one first memory block for the first process from the candidate physical memory. If the memory space of the memory block required by the first process is 4KB, it is determined that the various types of memory blocks include memory blocks of the same type as the memory space required by the first process. For memory blocks of the same type that require the same memory space, at least one first memory block is allocated to the first process.
  • the above-mentioned allocation of at least one first memory block from the candidate physical memory to the first process may be performed by the above-mentioned management process.
  • a possible implementation manner of allocating at least one first memory block to the first process according to the determined type of memory block is:
  • the first memory block in the determined type of memory block that is not allocated to a process is the first The process allocates at least one first memory block; or,
  • the number of memory blocks not allocated to a process in the determined type of memory block is less than or equal to the first preset number, but the number of unoccupied memory blocks in the determined type of memory block to which other processes have been allocated is greater than
  • For a second preset number at least one first memory block is allocated for the first process from unoccupied memory blocks that have been allocated other processes in the determined type of memory blocks.
  • the determined type of memory block is a type of memory block having the same memory space as the memory space required by the first process. In this embodiment, it is determined whether the number of memory blocks not allocated to the process among the determined types of memory blocks is less than the first preset number. If the number of memory blocks not allocated to the process in the determined type of memory block is greater than or equal to the first preset number, the first process is allocated from the memory blocks not allocated to the process in the determined type of memory block At least one first memory block.
  • the first preset number is 200, assuming that the memory space required by the first process is 4KB, and 1000 4KB memory blocks were previously divided from the main physical memory, of which 600 4KB memory blocks have been allocated to other In the process, the remaining 400 4KB memory blocks have not yet been allocated to the process.
  • the 4KB memory blocks not allocated to the process are 400, which is greater than the first preset number of 200. Therefore, in this embodiment, the remaining unallocated memory blocks can be allocated to Among the 400 4KB memory blocks of the process, at least one memory block is allocated for the first process.
  • the number of memory blocks not allocated to a process in the determined type of memory block is less than the first preset number, in a possible implementation manner, at least one first A memory block; in another possible implementation manner, it is also determined whether the number of unoccupied memory blocks allocated to other processes in the determined type of memory block is less than the second preset number, if the determined type The number of unoccupied memory blocks allocated to other processes in the memory block is greater than or equal to the second preset number, for example: the second preset number is 200, assuming that the memory space required by the first process is 4KB, and the 4KB The number of unoccupied memory blocks allocated to other processes in the memory block is 300.
  • at least one first memory can be allocated for the first process from the 300 unoccupied memory blocks allocated to other processes Piece.
  • At least one first memory block is allocated for the first process from the candidate physical memory.
  • the above allocation of at least one first memory block to the first process is performed by the above management process.
  • the number of unoccupied first memory blocks of the first process is also monitored; When the number of occupied first memory blocks is less than the third preset number, at least one first memory block is allocated again for the first process from the physical memory, so that the unoccupied first memory block of the first process The number of memory blocks is greater than or equal to the third preset number.
  • the number of unoccupied first memory blocks of the first process is monitored, wherein the unoccupied first memory block A memory block refers to the first memory block where no data is stored. And determine whether the number of unoccupied first memory blocks is less than the third preset number.
  • At least one first memory block is allocated again for the first process in the physical memory, so that the number of unoccupied first memory blocks of the first process is greater than or equal to 50, wherein in this embodiment, physical memory can be selected from the main physical memory At least one first memory block is allocated for the first process again, or at least one first memory block may be allocated for the first process again from the alternative physical memory of the physical memory.
  • the monitoring of the number of unoccupied first memory blocks is performed by the management process.
  • this embodiment divides various types of memory blocks from the main selected physical memory of the physical memory, and allocates at least one memory block to the process according to the various types of memory blocks. If multiple types of memory blocks are divided into matching types of memory blocks that are not allocated to other processes, the memory blocks that are not allocated to other processes are sufficient to be allocated to the process, then the matching types of memory blocks are not allocated to other processes.
  • Allocate memory blocks for the process if the memory blocks that match the process among the various types of memory blocks are not allocated to other processes, the memory blocks are not enough to be allocated to the process, but the memory blocks that match the process If the number of unoccupied memory blocks that have been allocated to other processes is sufficient for allocation to the process, the process is allocated from the unoccupied memory blocks that have been allocated to other processes from the types of memory blocks that match the process Memory block; otherwise allocate memory block for the process from the alternative physical memory of the physical memory. At the same time, the number of unoccupied memory blocks of the process is also monitored. When the number is less than a certain number, the memory block is allocated again for the process from the main selected physical memory or the alternative physical memory of the physical memory. Therefore, it can be guaranteed that the unoccupied memory block in each process is greater than a certain number, and that when the process needs to share data with other processes, the number can be saved in the memory block of the process in time, which improves the communication efficiency between processes.
  • a computer storage medium is also provided in an embodiment of the present invention.
  • the computer storage medium stores program instructions, and when the program is executed, it may include a part of the multi-process communication method as shown in FIG. 2 and its corresponding embodiments or All steps.
  • FIG. 3 is a schematic structural diagram of a multi-process communication system according to an embodiment of the present invention.
  • the multi-process communication system 300 of this embodiment may include: a physical memory 301, a memory 302, and a processor 303 .
  • the physical memory 301, the memory 302, and the processor 303 can be communicatively connected.
  • the memory 302 is used to store program codes.
  • the processor 303 is configured to execute: when the program code is called:
  • the same virtual address space is reserved for multiple processes of the mobile platform, and the same virtual address space is mapped to the same physical memory 3011 in the physical memory 301;
  • the data that the first process needs to share with the at least one second process is stored in the first memory block, and the second process is Any one of the multiple processes except the first process;
  • the processor 303 is further configured to:
  • the data is deleted from the first memory block.
  • the processor 303 is further configured to:
  • the processor 303 is further configured to divide various types of memory blocks from the physical memory 3011 before allocating at least one first memory block for the first process from the physical memory 3011, The number of each type of memory block is at least one, and the memory space of different types of memory blocks is different;
  • the processor 303 when allocating at least one first memory block for the first process from the physical memory 3011, is specifically used for: according to the memory space of the memory block required by the first process, from the multiple A type of memory block with the same memory space as the memory space required for the first process is determined from the type of memory block; at least one first memory block is allocated to the first process according to the determined type of memory block.
  • processor 303 when the processor 303 divides multiple types of memory blocks from the physical memory 3011, it is specifically used to:
  • the processor 303 is further configured to: start the management process when the process is initialized.
  • the processor 303 is specifically used to divide multiple types of memory blocks from the physical memory 3011:
  • various types of memory blocks are divided from the physical memory 3011.
  • the number of each type of memory block is related to the number of matching processes, and the memory space of each type of memory block is the same as the memory space required by the matching process.
  • the physical memory 3011 includes: a primary selected physical memory 3011a and an alternative physical memory 3011b;
  • the processor 303 divides multiple types of memory blocks from the physical memory 3011, it is specifically used to: divide the multiple types of memory blocks from the primary selected physical memory 3011a.
  • the processor 303 is further configured to:
  • the first process is allocated at least at least one of the candidate physical memory 3011b A first memory block.
  • processor 303 when the processor 303 allocates at least one first memory block to the first process according to the determined type of memory block, it is specifically used to:
  • the memory block not allocated to the process in the determined type of memory block is the first A process allocates at least one first memory block; or,
  • the number of memory blocks not allocated to a process in the determined type of memory block is less than the first preset number, but the number of unoccupied memory blocks in the determined type of memory block to which other processes have been allocated is greater than or equal to the first Two preset numbers, then at least one first memory block is allocated for the first process from the unoccupied memory blocks of the determined type of memory blocks that have been allocated by other processes.
  • the processor 303 is further configured to:
  • At least one first memory block is allocated for the first process from the candidate physical memory 3011b.
  • the at least one first memory block is allocated by the management process to the first process.
  • the processor 303 is further used to:
  • At least one first memory block is allocated again for the first process from the physical memory 3011 mapped to the same virtual address space So that the number of unoccupied first memory blocks of the first process is greater than the third preset number.
  • the number of the unoccupied first memory blocks is monitored by the management process.
  • the data includes any one of the following: data collected by an imaging device in the movable platform, and data collected by a radar in the movable platform.
  • the address where the data is stored in the first memory block is a virtual address where the data is stored in the first memory block.
  • the multi-process communication system of this embodiment may be used to execute the technical solution of the multi-process communication method in the above method embodiments of the present invention, and its implementation principles and technical effects are similar and will not be repeated here.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Memory System (AREA)

Abstract

本发明实施例提供一种多进程间的通信方法和系统,此方法包括:在进程的链接阶段,为多个进程预留同一块虚拟地址空间,同一虚拟地址空间映射到相同的物理内存,并从物理内存中为第一进程分配至少一个第一内存块,第一进程为多个进程中的任一进程;然后将第一进程需要与至少一个第二进程共享的数据存储在第一内存块中,第一进程和至少一个第二进程为多个进程中的进程;向至少一个第二进程分别发送通知消息,以指示数据存储在第一内存块中的地址,以便各第二进程根据该地址获取数据。避免影响到进程运行时的资源,提高了进程运行效率,还实现数据在多进程间的零拷贝传输,提高了进程间的通信效率。

Description

多进程间的通信方法和系统 技术领域
本发明实施例涉及通信技术领域,尤其涉及一种多进程间的通信方法和系统。
背景技术
软件系统(例如:无人驾驶系统、机器人系统等)在工作时,是需要多个进程相互协作运行。多个进程在相互协作运行的过程中,会涉及数据在多进程间传输的情况。以无人驾驶系统为例,无人驾驶系统运行在无人机上,无人机上安装有多个摄像头、雷达等传感器,摄像头采集的图像数据或者雷达采集的传感数据需要无人驾驶系统中的不同进程间进行传输,以便各个不同的进程进行处理。
现有技术中,数据在不同进程间传输的过程为:在进程运行过程中,进程A申请一块共享内存,并将该共享内存通知给进程B,这样进程A与进程B可以共享存储在同一块共享内存中的数据。但是,现有技术中的上述方案是在进程运行时申请共享内存,会影响进程运行效率。
发明内容
本发明实施例提供一种多进程间的通信方法和系统,用于提高进程运行效率。
第一方面,本发明实施例提供一种多进程间的通信方法,包括:
在进程的链接阶段,为可移动平台的多个进程预留同一块虚拟地址空间,所述同一虚拟地址空间映射到相同的物理内存;
从所述物理内存中为第一进程分配至少一个第一内存块,所述第一进程为所述多个进程中的任一进程;
当第一进程与至少一个第二进程需要共享数据时,将所述第一进程需要与所述至少一个第二进程共享的数据存储在所述第一内存块中,所述第二进程为所述多个进程中除所述第一进程外的任一进程;
向所述至少一个第二进程分别发送通知消息,所述通知消息用于指示所述数据存储在第一内存块中的地址,以便各所述第二进程根据所述地址从所述第一内存块中获取所述数据。
第二方面,本发明实施例提供一种多进程间的通信系统,包括:物理内存、存储器和处理器;
所述存储器,用于存储程序代码;
所述处理器,用于当所述程序代码被调用时,以执行:
在进程的链接阶段,为可移动平台的多个进程预留同一块虚拟地址空间,所述同一虚拟地址空间映射到所述物理内存中相同的物理内存;
从所述同一虚拟地址空间映射到的物理内存中为第一进程分配至少一个第一内存块,所述第一进程为所述多个进程中的任一进程;
当第一进程与至少一个第二进程需要共享数据时,将所述第一进程需要与所述至少一个第二进程共享的数据存储在所述第一内存块中,所述第二进程为所述多个进程中除所述第一进程外的任一进程;
向所述至少一个第二进程分别发送通知消息,所述通知消息用于指示所述数据存储在第一内存块中的地址,以便各所述第二进程根据所述地址从所述第一内存块中获取所述数据。
第三方面,本发明实施例提供一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序包含至少一段代码,所述至少一段代码可由计算机执行,以控制所述计算机执行第一方面本发明实施例所述的多进程间的通信方法。
第四方面,本发明实施例提供一种计算机程序,当所述计算机程序被计算机执行时,用于实现第一方面本发明实施例所述的多进程间的通信方法。
本发明实施例提供的多进程间的通信方法和系统,在进程的链接阶段,为多个进程预留同一块虚拟地址空间,所述同一虚拟地址空间映射到相同的物理内存,并从所述物理内存中为第一进程分配至少一个第一内存块,所述第一进程为所述多个进程中的任一进程;当第一进程与至少一个第二进程需要共享数据时,将所述第一进程需要与所述至少一个第二进程共享的数据存储在所述第一内存块中,所述第二进程为所述多个进程中除所述第一进程外的任一进程;向所述至少一个第二进程分别发送通知消息,所述通知消息用 于指示所述数据存储在第一内存块中的地址,以便各所述第二进程根据所述地址从所述第一内存块中获取所述数据。由于本实施例在进程的链接阶段为各进程分配内存块,避免了影响到进程运行时的资源,提高了进程运行效率。而且分配的所有内存块属于相同的物理内存并且同一块虚拟地址空间,需要共享同一数据的进程可以通过数据存储在内存块中的地址获取共享的数据,从而实现数据在多进程(例如是3个以上的进程)间的零拷贝传输,提高了进程间的通信效率。
附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1是根据本发明的实施例的无人飞行系统的示意性架构图;
图2为本发明一实施例提供的多进程间的通信方法的流程图;
图3为本发明一实施例提供的多进程间的通信系统的结构示意图。
具体实施方式
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
需要说明的是,当组件被称为“固定于”另一个组件,它可以直接在另一个组件上或者也可以存在居中的组件。当一个组件被认为是“连接”另一个组件,它可以是直接连接到另一个组件或者可能同时存在居中组件。
除非另有定义,本文所使用的所有的技术和科学术语与属于本发明的技术领域的技术人员通常理解的含义相同。本文中在本发明的说明书中所使用的术语只是为了描述具体的实施例的目的,不是旨在于限制本发明。本文所使用的术语“及/或”包括一个或多个相关的所列项目的任意的和所有的组 合。
下面结合附图,对本发明的一些实施方式作详细说明。在不冲突的情况下,下述的实施例及实施例中的特征可以相互组合。
本发明的实施例提供了多进程间的通信方法和系统。其中多进程间的通信系统可以应用于可移动平台。该可移动平台例如可以是无人机、无人船、无人驾驶车辆、机器人等。
下面以可移动平台平是无人驾驶车辆为例进行说明。图1是根据本发明的实施例的无人驾驶车辆100的示意性架构图。
无人驾驶车辆100可以包括感知系统110、控制系统120和机械系统130。
其中,感知系统110用于测量无人驾驶车辆的状态信息,即无人驾驶车辆100的感知数据,感知数据可以表示无人驾驶车辆100的位置信息和/或状态信息,例如,位置、角度、速度、加速度和角速度等。感知系统110例如可以包括视觉传感器(例如包括多个单目或双目视觉装置)、激光雷达、毫米波雷达、惯性测量单元(Inertial Measurement Unit,IMU)、全球导航卫星系统、陀螺仪、超声传感器、电子罗盘、和气压计等传感器中的至少一种。例如,全球导航卫星系统可以是全球定位系统(Global Positioning System,GPS)。
感知系统110获取到感知数据后,可以将感知数据传输给控制系统120。其中,控制系统120用于根据感知数据做出用于控制无人驾驶车辆100如何行驶的决策,例如:以多少的速度行驶,或者,以多少的刹车加速度刹车,或者,是否变道行驶,或者,左/右转行驶等。控制系统120例如可以包括:计算平台,例如车载超算平台,或者中央处理器、分布式处理单元等具有处理功能器件的至少一种。控制系统120还可以包括车辆上各种数据传输的通信链路。
控制系统120可以根据确定的决策向机械系统130输出一个或多个控制指令。其中,机械系统130用于响应来自控制系统120的一个或多个控制指令对无人驾驶车辆100进行控制,以完成上述决策,例如:机械系统130可以驱动无人驾驶车辆100的车轮转动,从而为无人驾驶车辆100的行驶提供动力,其中,车轮的转动速度可以影响到无人驾驶车辆的速度。其中,机械系统130例如可以包括:机械的车身发动机/电动机、控制的线控系统等等中 的至少一种。
应理解,上述对于无人驾驶车辆各组成部分的命名仅是出于标识的目的,并不应理解为对本发明的实施例的限制。
在无人驾驶车辆100上的感知系统,会产生大量的感知数据需要传输处理,而这些数据在不同进程间进行传输可以采用本发明下述各实施例的方案来实现。
图2为本发明一实施例提供的多进程间的通信方法的流程图,如图2所示,本实施例的方法可以包括:
S201、在进程的链接阶段,为可移动平台的多个进程预留同一块虚拟地址空间,所述同一虚拟地址空间映射到相同的物理内存。
本实施例中,在进程的链接阶段,为可移动平台的多个进程预留同一块虚拟地址空间,同一块虚拟地址空间例如可以是指虚拟地址是连续的地址空间。并且预留的同一块虚拟地址空间映射到相同的物理内存,该相同的物理内存例如可以是一块物理内存,或者,一块物理内存中的一段物理内存。
S202、从所述物理内存中为第一进程分配至少一个第一内存块,所述第一进程为所述多个进程中的任一进程。
本实施例中,从上述相同的物理内存中为上述多个进程中的每一个进程分配至少一个内存块。本实施例以多个进程中的任意一个进程为例进行说明,其它各进程类似,该任意一个进程称为第一进程,本实施例可以从该物理内存中为该第一进程分配至少一个第一内存块。
S203、当第一进程与至少一个第二进程需要共享数据时,将所述第一进程需要与所述至少一个第二进程共享的数据存储在所述第一内存块中,所述第二进程为所述多个进程中除所述第一进程外的任一进程。
本实施例中,该至少一个第一内存块可以用于第一进程与其它进程进行共享数据,其它进程可以称为第二进程,所述第二进程为所述多个进程中除所述第一进程外的任一进程,该第二进程的数量可以为至少一个。
可选地,该数据可以包括以下任一项:所述可移动平台中成像装置采集的数据、所述可移动平台中雷达采集的数据;但本实施例并不限于此。
当第一进程与至少一个第二进程需要共享数据时,将第一进程需要与该至少一个第二进程共享的数据存储在第一内存块中。当第一进程与其它的一 个或多个第二进程需要共享另一数据时,将共享的另一数据存储的另一第一内存块中。第一进程可以同时与一些第二进程共享数据,也可以与另一些第二进程共享另一些数据;一些第二进程与另一些第二进程中可以存在相同的第二进程,也可以不存在相同的第二进程。
此处将第一进程共享一数据为例进行说明,共享其它数据类似,此处不再赘述。
S204、向所述至少一个第二进程分别发送通知消息,所述通知消息用于指示所述数据存储在第一内存块中的地址,以便各所述第二进程根据所述地址从所述第一内存块中获取所述数据。
本实施例中,将第一进程需要与该至少一个第二进程共享的数据存储在第一内存块中之后,向该至少一个第二进程分别发送通知消息,该通知消息用于指示该共享的数据存储在第一内存块中的地址,相应地,该至少一个第二进程中的各第二进程接收到通知消息后,根据该共享的数据存储在第一内存块中的地址获取到该共享的数据,然后对数据执行相应的处理。
可选地,数据存储在第一内存块中的地址为数据存储在第一内存块中的虚拟地址,该虚拟地址属于上述同一块虚拟地址空间。
本实施例提供的多进程间的通信方法,在进程的链接阶段,为多个进程预留同一块虚拟地址空间,所述同一虚拟地址空间映射到相同的物理内存,并从所述物理内存中为第一进程分配至少一个第一内存块,所述第一进程为所述多个进程中的任一进程;当第一进程与至少一个第二进程需要共享数据时,将所述第一进程需要与所述至少一个第二进程共享的数据存储在所述第一内存块中,所述第二进程为所述多个进程中除所述第一进程外的任一进程;向所述至少一个第二进程分别发送通知消息,所述通知消息用于指示所述数据存储在第一内存块中的地址,以便各所述第二进程根据所述地址从所述第一内存块中获取所述数据。由于本实施例在进程的链接阶段为各进程分配内存块,避免了影响到进程运行时的资源,提高了进程运行效率。而且分配的所有内存块属于相同的物理内存并且同一块虚拟地址空间,需要共享同一数据的进程可以通过数据存储在内存块中的地址获取共享的数据,从而实现数据在多进程(例如是3个以上的进程)间的零拷贝传输,提高了进程间的通信效率。
在一些实施例中,在所述至少一个第二进程都从所述第一内存块中获取数据之后,还将所述数据从所述第一内存块中删除。在上述需要与第一进程共享该数据的所有第二进程均从第一内存块中获取数据之后,本实施例还将数据从第一内存块中删除,使得第一内存块从占用状态变更为空闲状态,以尽可能地保证为第一进程分配的第一内存块中具有足够的处于空闲状态的第一内存块,保证第一进程需要与其它进程共享数据时,数据可以及时存储至第一内存块中。
在一些实施例中,在第一进程与至少一个第二进程需要共享数据时,还可以确定该至少一个第二进程中第二进程的个数,例如第二进程的个数为N,N为大于等于1的整数。在向该N个第二进程发送通知消息后,每个第二进程从该第一内存块中获取数据时,累计计数数据获取次数,需要说明的是,在没有第二进程从第一内存块中获取数据时,该数据获取次数的初始化为0,每个第二进程从第一内存块中获取数据,将数据获取次数加1。当累计计数的数据获取次数等于上述N时,确定该N个第二进程都从所述第一内存块中获取数据。然后根据该N个第二进程都从所述第一内存块中获取数据,将所述数据从所述第一内存块中删除。
在一些实施例中,在执行上述S202之前,还从所述物理内存中划分出多种种类内存块,每种种类内存块的数量为至少一个,不同种的种类内存块的内存空间不同。本实施例中可以先从物理内存中划分出多种种类内存块,例如可以从物理内存中划分出3种种类内存块,一种种类内存块为2KB的内存块,一种种类内存块为4KB的内存块,一种种类内存块为8KB的内存块。可选地,本实施例是在进程初始化时,从所述物理内存中划分出多种种类内存块。可选地,在进程初始化时,还启动管理进程。
相应地,上述S202的一种可能的实现方式为:根据所述第一进程所需内存块的内存空间,从所述多种种类内存块中确定出内存空间与所述第一进程所需内存的内存空间相同的种类内存块;根据确定的种类内存块,为所述第一进程分配至少一个第一内存块。本实施例中,例如第一进程所需内存块的内存空间为4KB,则可以从划分出的多种种类内存块(例如2KB、4KB、8KB三种种类内存块)中确定出4KB的种类内存块,然后根据4KB的种类内存块,为该第一进程分配至少一个4KB的种类内存块。
在一些实施例中,上述从所述物理内存中划分出多种种类内存块的一种可能的实现方式为:根据多个进程中每个进程所需内存块的内存空间,确定需要划分的内存块的种类;根据需要划分的内存块的种类,从所述物理内存中划分出多种种类内存块。例如存在10个进程,进程1-3所需的每块内存块的内存空间为2KB,进程4-6所需的每块内存块的内存空间为4KB,进程7-10所需的每块内存块的内存空间为8KB,则本实施例可以从物理内存中划分出3种种类内存块,然后从物理内存中划分出至少一个2KB的内存块、至少一个4KB的内存块,至少一个8KB的内存块。
可选地,每种种类内存块的数量与相匹配的进程的个数有关,每种种类内存块的内存空间与所述相匹配的进程所需内存的内存空间相同。例如:需要为每个进程分配200个内存块,其中,与2KB的内存块相匹配的进程为进程1-3,即进程的个数为3个,则可以从物理内存中划分出2KB的内存块共600个,甚至可以分配大于600个数量的2KB的内存块。与4KB的内存块相匹配的进程为进程1-3,即进程的个数为3个,则可以从物理内存中划分出4KB的内存块共600个,甚至可以分配大于600个数量的4KB的内存块。与8KB的内存块相匹配的进程为进程7-10,即进程的个数为4个,则可以从物理内存中划分出8KB的内存块共800个,甚至可以分配大于800个数量的8KB的内存块。
在一些实施例中,所述物理内存可以包括:主选物理内存和备选物理内存;相应地,上述从所述物理内存中划分出多种种类内存块的一种可能的实现方式为:从所述主选物理内存中划出所述多种种类内存块。其中,备选物理内存用于在主选物理内存不够时为进程分配内存块,具体方案可以参见下述实施例所述。
在一些实施例中,根据所述第一进程所需内存块的内存空间,确定所述多种种类内存块中是否包括内存空间与所述第一进程所需内存的内存空间相同的种类内存块;例如:多种种类内存块包括:2KB的内存块、4KB的内存块、8KB的内存块,若第一进程所需内存块的内存空间为1M,则确定该多种种类内存块不包括内存空间与第一进程所需内存的内存空间相同的种类内存块,则从备选物理内存中为第一进程分配至少一个第一内存块。若第一进程所需内存块的内存空间为4KB,则确定该多种种类内存块包括内存空间与 第一进程所需内存的内存空间相同的种类内存块,则根据内存空间与第一进程所需内存的内存空间相同的种类内存块,为所述第一进程分配至少一个第一内存块,具体实现过程可以参见上述实施例中的相关描述,此处不再赘述。
可选地,上述从备选物理内存中为第一进程分配至少一个第一内存块可以由上述的管理进程为执行。
在一些实施例中,上述根据确定的种类内存块,为所述第一进程分配至少一个第一内存块的一种可能的实现方式为:
若所述确定的种类内存块中未分配给进程的内存块的数量大于第一预设数量,则从所述确定的种类内存块中所述未分配给进程的内存块中为所述第一进程分配至少一个第一内存块;或者,
在所述确定的种类内存块中未分配给进程的内存块的数量小于或等于第一预设数量,但所述确定的种类内存块中已分配其它进程的未被占用的内存块的数量大于第二预设数量,则从所述确定的种类内存块中已分配其它进程的未被占用的内存块中为所述第一进程分配至少一个第一内存块。
其中,该确定的种类内存块为内存空间与第一进程所需内存的内存空间相同的种类内存块。本实施例判断确定的种类内存块中未分配给进程的内存块的数量是否小于第一预设数量。如果确定的种类内存块中未分配给进程的内存块的数量大于等于第一预设数量,从所述确定的种类内存块中所述未分配给进程的内存块中为所述第一进程分配至少一个第一内存块。例如:第一预设数量为200,假设第一进程所需内存的内存空间为4KB,之前从主选物理内存中划分出1000个4KB的内存块,其中600个4KB的内存块已分配给其它进程,剩下400个4KB的内存块还未分配给进程,未分配给进程式的4KB的内存块为400个,大于第一预设数量200,因此本实施例可以从剩下的未分配给进程的400个4KB的内存块中为第一进程分配至少一个内存块。
如果确定的种类内存块中未分配给进程的内存块的数量小于第一预设数量,在一种可能的实现方式中,可以从上述的备选内存块中为该第一进程分配至少一个第一内存块;在另一种可能的实现方式中,还判断所述确定的种类内存块中已分配其它进程的未被占用的内存块的数量是否小于第二预设数量,如果该确定的种类内存块中已分配其它进程的未被占用的内存块的数量大于等于第二预设数量,例如:第二预设数量为200,假设第一进程所需内 存的内存空间为4KB,该4KB的内存块中已分配其它进程的未被占用的内存块的数量为300个,则本实施例可以从这300个分配其它进程的未被占用的内存块中为第一进程分配至少一个第一内存块。
如果该确定的种类内存块中已分配其它进程的未被占用的内存块的数量小于第二预设数量,则从备选物理内存中为第一进程分配至少一个第一内存块。
可选地,上述为所述第一进程分配至少一个第一内存块是由上述的管理进程执行。
在一些实施例中,在从所述物理内存中为第一进程分配至少一个第一内存块之后,还监测所述第一进程的未被占用的第一内存块的数量;在所述未被占用的第一内存块的数量小于第三预设数量时,从所述物理内存中为所述第一进程再次分配至少一个第一内存块,使得所述第一进程的未被占用的第一内存块的数量大于等于所述第三预设数量。
本实施例中,在通过上述各实施例中的方案为第一进程分配至少一个第一内存块之后,监测第一进程的未被占用的第一内存块的数量,其中,未被占用的第一内存块是指未存储有数据的第一内存块。并判断未被占用的第一内存块的数量是否小于第三预设数量,如果该未被占用的第一内存块的数量小于第三预设数量,例如第三预设数量为50,则从物理内存中为该第一进程再次分配至少一个第一内存块,使得第一进程的未被占用的第一内存块的数量大于等于50,其中,本实施例可以从物理内存的主选物理内存中为第一进程再次分配至少一个第一内存块,也可以从物理内存的备选物理内存中为第一进程再次分配至少一个第一内存块,具体实现方案可以参见上述各实施例的相关描述,此处不再赘述。
可选地,上述监测所述未被占用的第一内存块的数量由上述管理进程执行。
综上所述,本实施例从物理内存的主选物理内存中划分多种种类内存块,并根据多种种类内存块为进程分配至少一个内存块。如果划分多种种类内存块中与进程相匹配的种类内存块未分配给其它进程的内存块足够用于分配给该进程,则从该相匹配的种类内存块未分配给其它进程的内存块中为该进程分配内存块;如果划分多种种类内存块中与进程相匹配的种类内存块未分配 给其它进程的内存块不足够用于分配给该进程,但与进程相匹配的种类内存块中已分配给其它进程的未被占用的内存块的数量足够用于分配给该进程,则从与进程相匹配的种类内存块中已分配给其它进程的未被占用的内存块中为该进程分配内存块;否则从物理内存的备选物理内存中为该进程分配内存块。同时还监测该进程的未被占用的内存块的数量,当该数量小于一定数量时,则再次从物理内存的主选物理内存或备选物理内存中为该进程再次分配内存块。因此,可以保证每个进程中未被占用的内存块大于一定数量,保证在进程需要与其它进程共享数据时,数量可以及时保存至该进程的内存块中,提高了进程间的通信效率。
本发明实施例中还提供了一种计算机存储介质,该计算机存储介质中存储有程序指令,所述程序执行时可包括如图2及其对应实施例中的多进程间的通信方法的部分或全部步骤。
图3为本发明一实施例提供的多进程间的通信系统的结构示意图,如图3所示,本实施例的多进程间的通信系统300可以包括:物理内存301、存储器302和处理器303。其中,物理内存301、存储器302、处理器303可以通信连接。
所述存储器302,用于存储程序代码。
所述处理器303,用于当所述程序代码被调用时,以执行:
在进程的链接阶段,为可移动平台的多个进程预留同一块虚拟地址空间,所述同一虚拟地址空间映射到所述物理内存301中相同的物理内存3011;
从所述同一虚拟地址空间映射到的物理内存3011中为第一进程分配至少一个第一内存块,所述第一进程为所述多个进程中的任一进程;
当第一进程与至少一个第二进程需要共享数据时,将所述第一进程需要与所述至少一个第二进程共享的数据存储在所述第一内存块中,所述第二进程为所述多个进程中除所述第一进程外的任一进程;
向所述至少一个第二进程分别发送通知消息,所述通知消息用于指示所述数据存储在第一内存块中的地址,以便各所述第二进程根据所述地址从所述第一内存块中获取所述数据。
在一些实施例中,所述处理器303,还用于:
在所述至少一个第二进程都从所述第一内存块中获取数据之后,将所述 数据从所述第一内存块中删除。
在一些实施例中,所述处理器303,还用于:
确定所述至少一个第二进程的个数;
在每个第二进程从所述第一内存块中获取数据时,累计计数数据获取次数;
在所述数据获取次数等于所述个数时,确定所述至少一个第二进程都从所述第一内存块中获取数据。
在一些实施例中,所述处理器303,还用于从所述物理内存3011中为第一进程分配至少一个第一内存块之前,从所述物理内存3011中划分出多种种类内存块,每种种类内存块的数量为至少一个,不同种的种类内存块的内存空间不同;
所述处理器303,在从所述物理内存3011中为第一进程分配至少一个第一内存块时,具体用于:根据所述第一进程所需内存块的内存空间,从所述多种种类内存块中确定出内存空间与所述第一进程所需内存的内存空间相同的种类内存块;根据确定的种类内存块,为所述第一进程分配至少一个第一内存块。
在一些实施例中,所述处理器303在从所述物理内存3011中划分出多种种类内存块时,具体用于:
在进程初始化时,从所述物理内存3011中划分出多种种类内存块。
在一些实施例中,所述处理器303,还用于:在进程初始化时,启动管理进程。
在一些实施例中,所述处理器303,在从所述物理内存3011中划分出多种种类内存块时,具体用于:
根据多个进程中每个进程所需内存块的内存空间,确定需要划分的内存块的种类;
根据需要划分的内存块的种类,从所述物理内存3011中划分出多种种类内存块。
在一些实施例中,每种种类内存块的数量与相匹配的进程的个数有关,每种种类内存块的内存空间与所述相匹配的进程所需内存的内存空间相同。
在一些实施例中,所述物理内存3011包括:主选物理内存3011a和备选 物理内存3011b;
所述处理器303在从所述物理内存3011中划分出多种种类内存块时,具体用于:从所述主选物理内存3011a中划出所述多种种类内存块。
在一些实施例中,所述处理器303,还用于:
若从所述多种种类内存块中不包括内存空间与所述第一进程所需内存的内存空间相同的种类内存块,则从所述备选物理内存3011b中为所述第一进程分配至少一个第一内存块。
在一些实施例中,所述处理器303在根据确定的种类内存块,为所述第一进程分配至少一个第一内存块时,具体用于:
若所述确定的种类内存块中未分配给进程的内存块的数量大于等于第一预设数量,则从所述确定的种类内存块中所述未分配给进程的内存块中为所述第一进程分配至少一个第一内存块;或者,
在所述确定的种类内存块中未分配给进程的内存块的数量小于第一预设数量,但所述确定的种类内存块中已分配其它进程的未被占用的内存块的数量大于等于第二预设数量,则从所述确定的种类内存块中已分配其它进程的未被占用的内存块中为所述第一进程分配至少一个第一内存块。
在一些实施例中,所述处理器303,还用于:
若所述确定的种类内存块中未分配给进程的内存块的数量小于第一预设数量,或者,所述确定的种类内存块中已分配其它进程的未被占用的内存块的数量小于或等于第二预设数量,则从所述备选物理内存3011b中为所述第一进程分配至少一个第一内存块。
在一些实施例中,所述至少一个第一内存块由所述管理进程为所述第一进程分配。
在一些实施例中,所述处理器303在从所述物理内存3011中为第一进程分配至少一个第一内存块之后,还用于:
监测所述第一进程的未被占用的第一内存块的数量;
在所述未被占用的第一内存块的数量小于等于第三预设数量时,从所述同一虚拟地址空间映射到的物理内存3011中为所述第一进程再次分配至少一个第一内存块,使得所述第一进程的未被占用的第一内存块的数量大于所述第三预设数量。
在一些实施例中,所述未被占用的第一内存块的数量由所述管理进程监测。
在一些实施例中,所述数据包括以下任一项:所述可移动平台中成像装置采集的数据、所述可移动平台中雷达采集的数据。
在一些实施例中,所述数据存储在第一内存块中的地址为所述数据存储在所述第一内存块中的虚拟地址。
本实施例的多进程间的通信系统,可以用于执行本发明上述各方法实施例中多进程间的通信方法的技术方案,其实现原理和技术效果类似,此处不再赘述。
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储于一计算机可读取存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:只读内存(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
最后应说明的是:以上各实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述各实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分或者全部技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的范围。

Claims (34)

  1. 一种多进程间的通信方法,其特征在于,包括:
    在进程的链接阶段,为可移动平台的多个进程预留同一块虚拟地址空间,所述同一虚拟地址空间映射到相同的物理内存;
    从所述物理内存中为第一进程分配至少一个第一内存块,所述第一进程为所述多个进程中的任一进程;
    当第一进程与至少一个第二进程需要共享数据时,将所述第一进程需要与所述至少一个第二进程共享的数据存储在所述第一内存块中,所述第二进程为所述多个进程中除所述第一进程外的任一进程;
    向所述至少一个第二进程分别发送通知消息,所述通知消息用于指示所述数据存储在第一内存块中的地址,以便各所述第二进程根据所述地址从所述第一内存块中获取所述数据。
  2. 根据权利要求1所述的方法,其特征在于,还包括:
    在所述至少一个第二进程都从所述第一内存块中获取数据之后,将所述数据从所述第一内存块中删除。
  3. 根据权利要求2所述的方法,其特征在于,还包括:
    确定所述至少一个第二进程的个数;
    在每个第二进程从所述第一内存块中获取数据时,累计计数数据获取次数;
    在所述数据获取次数等于所述个数时,确定所述至少一个第二进程都从所述第一内存块中获取数据。
  4. 根据权利要求1所述的方法,其特征在于,所述从所述物理内存中为第一进程分配至少一个第一内存块之前,还包括:
    从所述物理内存中划分出多种种类内存块,每种种类内存块的数量为至少一个,不同种的种类内存块的内存空间不同;
    所述从所述物理内存中为第一进程分配至少一个第一内存块,包括:
    根据所述第一进程所需内存块的内存空间,从所述多种种类内存块中确定出内存空间与所述第一进程所需内存的内存空间相同的种类内存块;
    根据确定的种类内存块,为所述第一进程分配至少一个第一内存块。
  5. 根据权利要求4所述的方法,其特征在于,所述从所述物理内存中划 分出多种种类内存块,包括:
    在进程初始化时,从所述物理内存中划分出多种种类内存块。
  6. 根据权利要求4或5所述的方法,其特征在于,还包括:
    在进程初始化时,启动管理进程。
  7. 根据权利要求6所述的方法,其特征在于,从所述物理内存中划分出多种种类内存块,包括:
    根据多个进程中每个进程所需内存块的内存空间,确定需要划分的内存块的种类;
    根据需要划分的内存块的种类,从所述物理内存中划分出多种种类内存块。
  8. 根据权利要求7所述的方法,其特征在于,每种种类内存块的数量与相匹配的进程的个数有关,每种种类内存块的内存空间与所述相匹配的进程所需内存的内存空间相同。
  9. 根据权利要求6所述的方法,其特征在于,所述物理内存包括:主选物理内存和备选物理内存;
    从所述物理内存中划分出多种种类内存块,包括:
    从所述主选物理内存中划出所述多种种类内存块。
  10. 根据权利要求9所述的方法,其特征在于,还包括:
    若从所述多种种类内存块中不包括内存空间与所述第一进程所需内存的内存空间相同的种类内存块,则从所述备选物理内存中为所述第一进程分配至少一个第一内存块。
  11. 根据权利要求9所述的方法,其特征在于,所述根据确定的种类内存块,为所述第一进程分配至少一个第一内存块,包括:
    若所述确定的种类内存块中未分配给进程的内存块的数量大于等于第一预设数量,则从所述确定的种类内存块中所述未分配给进程的内存块中为所述第一进程分配至少一个第一内存块;或者,
    在所述确定的种类内存块中未分配给进程的内存块的数量小于第一预设数量,但所述确定的种类内存块中已分配其它进程的未被占用的内存块的数量大于等于第二预设数量,则从所述确定的种类内存块中已分配其它进程的未被占用的内存块中为所述第一进程分配至少一个第一内存块。
  12. 根据权利要求11所述的方法,其特征在于,还包括:
    若所述确定的种类内存块中未分配给进程的内存块的数量小于第一预设数量,或者,所述确定的种类内存块中已分配其它进程的未被占用的内存块的数量小于或等于第二预设数量,则从所述备选物理内存中为所述第一进程分配至少一个第一内存块。
  13. 根据权利要求10-12任一项所述的方法,其特征在于,所述至少一个第一内存块由所述管理进程为所述第一进程分配。
  14. 根据权利要求6-13任一项所述的方法,其特征在于,所述从所述物理内存中为第一进程分配至少一个第一内存块之后,还包括:
    监测所述第一进程的未被占用的第一内存块的数量;
    在所述未被占用的第一内存块的数量小于等于第三预设数量时,从所述物理内存中为所述第一进程再次分配至少一个第一内存块,使得所述第一进程的未被占用的第一内存块的数量大于所述第三预设数量。
  15. 根据权利要求14所述的方法,其特征在于,所述未被占用的第一内存块的数量由所述管理进程监测。
  16. 根据权利要求1-15任一项所述的方法,其特征在于,所述数据包括以下任一项:所述可移动平台中成像装置采集的数据、所述可移动平台中雷达采集的数据。
  17. 根据权利要求1-16任一项所述的方法,其特征在于,所述数据存储在第一内存块中的地址为所述数据存储在所述第一内存块中的虚拟地址。
  18. 一种多进程间的通信系统,其特征在于,包括:物理内存、存储器和处理器;
    所述存储器,用于存储程序代码;
    所述处理器,用于当所述程序代码被调用时,以执行:
    在进程的链接阶段,为可移动平台的多个进程预留同一块虚拟地址空间,所述同一虚拟地址空间映射到所述物理内存中相同的物理内存;
    从所述同一虚拟地址空间映射到的物理内存中为第一进程分配至少一个第一内存块,所述第一进程为所述多个进程中的任一进程;
    当第一进程与至少一个第二进程需要共享数据时,将所述第一进程需要与所述至少一个第二进程共享的数据存储在所述第一内存块中,所述第二进 程为所述多个进程中除所述第一进程外的任一进程;
    向所述至少一个第二进程分别发送通知消息,所述通知消息用于指示所述数据存储在第一内存块中的地址,以便各所述第二进程根据所述地址从所述第一内存块中获取所述数据。
  19. 根据权利要求18所述的系统,其特征在于,所述处理器,还用于:
    在所述至少一个第二进程都从所述第一内存块中获取数据之后,将所述数据从所述第一内存块中删除。
  20. 根据权利要求19所述的系统,其特征在于,所述处理器,还用于:
    确定所述至少一个第二进程的个数;
    在每个第二进程从所述第一内存块中获取数据时,累计计数数据获取次数;
    在所述数据获取次数等于所述个数时,确定所述至少一个第二进程都从所述第一内存块中获取数据。
  21. 根据权利要求18所述的系统,其特征在于,所述处理器,还用于从所述物理内存中为第一进程分配至少一个第一内存块之前,从所述物理内存中划分出多种种类内存块,每种种类内存块的数量为至少一个,不同种的种类内存块的内存空间不同;
    所述处理器,在从所述物理内存中为第一进程分配至少一个第一内存块时,具体用于:根据所述第一进程所需内存块的内存空间,从所述多种种类内存块中确定出内存空间与所述第一进程所需内存的内存空间相同的种类内存块;根据确定的种类内存块,为所述第一进程分配至少一个第一内存块。
  22. 根据权利要求21所述的系统,其特征在于,所述处理器在从所述物理内存中划分出多种种类内存块时,具体用于:
    在进程初始化时,从所述物理内存中划分出多种种类内存块。
  23. 根据权利要求21或22所述的系统,其特征在于,所述处理器,还用于:在进程初始化时,启动管理进程。
  24. 根据权利要求23所述的系统,其特征在于,所述处理器,在从所述物理内存中划分出多种种类内存块时,具体用于:
    根据多个进程中每个进程所需内存块的内存空间,确定需要划分的内存块的种类;
    根据需要划分的内存块的种类,从所述物理内存中划分出多种种类内存块。
  25. 根据权利要求24所述的系统,其特征在于,每种种类内存块的数量与相匹配的进程的个数有关,每种种类内存块的内存空间与所述相匹配的进程所需内存的内存空间相同。
  26. 根据权利要求23所述的系统,其特征在于,所述物理内存包括:主选物理内存和备选物理内存;
    所述处理器在从所述物理内存中划分出多种种类内存块时,具体用于:从所述主选物理内存中划出所述多种种类内存块。
  27. 根据权利要求26所述的系统,其特征在于,所述处理器,还用于:
    若从所述多种种类内存块中不包括内存空间与所述第一进程所需内存的内存空间相同的种类内存块,则从所述备选物理内存中为所述第一进程分配至少一个第一内存块。
  28. 根据权利要求27所述的系统,其特征在于,所述处理器在根据确定的种类内存块,为所述第一进程分配至少一个第一内存块时,具体用于:
    若所述确定的种类内存块中未分配给进程的内存块的数量大于等于第一预设数量,则从所述确定的种类内存块中所述未分配给进程的内存块中为所述第一进程分配至少一个第一内存块;或者,
    在所述确定的种类内存块中未分配给进程的内存块的数量小于第一预设数量,但所述确定的种类内存块中已分配其它进程的未被占用的内存块的数量大于等于第二预设数量,则从所述确定的种类内存块中已分配其它进程的未被占用的内存块中为所述第一进程分配至少一个第一内存块。
  29. 根据权利要求28所述的系统,其特征在于,所述处理器,还用于:
    若所述确定的种类内存块中未分配给进程的内存块的数量小于第一预设数量,或者,所述确定的种类内存块中已分配其它进程的未被占用的内存块的数量小于或等于第二预设数量,则从所述备选物理内存中为所述第一进程分配至少一个第一内存块。
  30. 根据权利要求27-29任一项所述的系统,其特征在于,所述至少一个第一内存块由所述管理进程为所述第一进程分配。
  31. 根据权利要求23-30任一项所述的系统,其特征在于,所述处理器 在从所述物理内存中为第一进程分配至少一个第一内存块之后,还用于:
    监测所述第一进程的未被占用的第一内存块的数量;
    在所述未被占用的第一内存块的数量小于等于第三预设数量时,从所述同一虚拟地址空间映射到的物理内存中为所述第一进程再次分配至少一个第一内存块,使得所述第一进程的未被占用的第一内存块的数量大于所述第三预设数量。
  32. 根据权利要求31所述的系统,其特征在于,所述未被占用的第一内存块的数量由所述管理进程监测。
  33. 根据权利要求18-32任一项所述的系统,其特征在于,所述数据包括以下任一项:所述可移动平台中成像装置采集的数据、所述可移动平台中雷达采集的数据。
  34. 根据权利要求18-33任一项所述的系统,其特征在于,所述数据存储在第一内存块中的地址为所述数据存储在所述第一内存块中的虚拟地址。
PCT/CN2018/124805 2018-12-28 2018-12-28 多进程间的通信方法和系统 WO2020133197A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201880069530.8A CN111316244A (zh) 2018-12-28 2018-12-28 多进程间的通信方法和系统
PCT/CN2018/124805 WO2020133197A1 (zh) 2018-12-28 2018-12-28 多进程间的通信方法和系统

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2018/124805 WO2020133197A1 (zh) 2018-12-28 2018-12-28 多进程间的通信方法和系统

Publications (1)

Publication Number Publication Date
WO2020133197A1 true WO2020133197A1 (zh) 2020-07-02

Family

ID=71129491

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/124805 WO2020133197A1 (zh) 2018-12-28 2018-12-28 多进程间的通信方法和系统

Country Status (2)

Country Link
CN (1) CN111316244A (zh)
WO (1) WO2020133197A1 (zh)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112769640B (zh) * 2020-12-23 2022-09-16 中移(杭州)信息技术有限公司 进程通信方法、系统、服务器及存储介质
CN112650603B (zh) * 2020-12-28 2024-02-06 北京天融信网络安全技术有限公司 内存管理方法、装置、电子设备及存储介质
CN115129459A (zh) * 2021-03-24 2022-09-30 华为技术有限公司 一种内存管理的方法及设备
CN117914860A (zh) * 2022-10-12 2024-04-19 华为技术有限公司 集合通信方法及计算集群

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104461706A (zh) * 2014-11-24 2015-03-25 上海华为技术有限公司 一种将共享全局变量共享的方法和多处理装置
CN104572313A (zh) * 2013-10-22 2015-04-29 华为技术有限公司 一种进程间的通信方法及装置
US20160041923A1 (en) * 2013-04-26 2016-02-11 Huawei Technologies Co., Ltd. Inter-Manycore Communications Method and System
CN105868028A (zh) * 2015-01-23 2016-08-17 华为技术有限公司 一种进程间共享数据的方法、装置及终端

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104216862B (zh) * 2013-05-29 2017-08-04 华为技术有限公司 一种用户进程与系统服务之间的通信方法、装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160041923A1 (en) * 2013-04-26 2016-02-11 Huawei Technologies Co., Ltd. Inter-Manycore Communications Method and System
CN104572313A (zh) * 2013-10-22 2015-04-29 华为技术有限公司 一种进程间的通信方法及装置
CN104461706A (zh) * 2014-11-24 2015-03-25 上海华为技术有限公司 一种将共享全局变量共享的方法和多处理装置
CN105868028A (zh) * 2015-01-23 2016-08-17 华为技术有限公司 一种进程间共享数据的方法、装置及终端

Also Published As

Publication number Publication date
CN111316244A (zh) 2020-06-19

Similar Documents

Publication Publication Date Title
WO2020133197A1 (zh) 多进程间的通信方法和系统
CN110719314B (zh) 用于管理计算任务的方法和系统
KR102004060B1 (ko) 자율 주행 차량을 작동하는 컴퓨팅 노드들 사이의 효율적 통신
US9633040B2 (en) Distributed processing system including a name node and a plurality of data nodes, and method of operating the same
US10785296B1 (en) Dynamic exchange of data between processing units of a system
US9448901B1 (en) Remote direct memory access for high availability nodes using a coherent accelerator processor interface
CN110764901A (zh) 基于gpu资源的数据处理方法、电子设备及系统
WO2017113278A1 (zh) 数据处理方法、装置和系统
CN103942087A (zh) 虚拟机热迁移方法及相关装置和集群系统
CN113085842B (zh) 车辆控制方法、装置及车辆
JP2022105146A (ja) アクセラレーションシステム、アクセラレーション方法、及びコンピュータプログラム
CN105306882B (zh) 找出处理单元连接的传感器单元使用的设置的方法和装置
US9742976B2 (en) Peer to peer camera communication
JP2022515508A (ja) 車両制御方法、関連するデバイス、およびコンピュータ記憶媒体
US20180225141A1 (en) Guest-Influenced Packet Transmission
US20190268402A1 (en) Distributed computing of vehicle data
CN110278714B (zh) 障碍物检测方法、移动平台及计算机可读存储介质
CN110389825B (zh) 管理专用处理资源的方法、设备和计算机程序产品
CN108780437A (zh) 核间通信方法、处理器和多处理器通信系统
US20150212795A1 (en) Interfacing with a buffer manager via queues
CN107577733B (zh) 一种数据复制的加速方法及系统
CN110865636A (zh) 基于Docker容器的云机器人导航系统及其工作方法
CN106598696B (zh) 一种虚拟机之间数据交互的方法及装置
CN112005275B (zh) 使用视频内存池进行点云渲染的系统和方法
CN114826817A (zh) 一种通信控制方法、电子设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18945111

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18945111

Country of ref document: EP

Kind code of ref document: A1