+

WO2023103767A1 - Homogeneous multi-core-based multi-operating system, communication method, and chip - Google Patents

Homogeneous multi-core-based multi-operating system, communication method, and chip Download PDF

Info

Publication number
WO2023103767A1
WO2023103767A1 PCT/CN2022/133538 CN2022133538W WO2023103767A1 WO 2023103767 A1 WO2023103767 A1 WO 2023103767A1 CN 2022133538 W CN2022133538 W CN 2022133538W WO 2023103767 A1 WO2023103767 A1 WO 2023103767A1
Authority
WO
WIPO (PCT)
Prior art keywords
operating system
data
cache
cache unit
communication method
Prior art date
Application number
PCT/CN2022/133538
Other languages
French (fr)
Chinese (zh)
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 合肥杰发科技有限公司
Publication of WO2023103767A1 publication Critical patent/WO2023103767A1/en

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
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/543Local

Definitions

  • the present application relates to the technical field of multi-system communication, in particular to a multi-operating system based on homogeneous multi-core, a communication method, and a chip.
  • Single-chip multi-system solutions are currently mainstream in vehicles, such as software virtualization solutions (Hypervisor), hardware intra-chip isolation solutions (in the case of heterogeneous multi-systems), etc.
  • Different operating systems are responsible for different tasks.
  • the software virtualization solution its general implementation is to design a layer of software on the CPU EL2 (Exception Level), and the EL2 software is responsible for managing data sharing and synchronization.
  • the EL2 software is responsible for managing data sharing and synchronization.
  • it is usually implemented by using hardware IPC combined with shared memory technology.
  • the data synchronization efficiency between the systems of these two schemes is low.
  • the technical problem mainly solved by this application is to provide a multi-operating system based on isomorphic multi-core and its data synchronization method and chip, so as to improve the efficiency of data synchronization between operating systems.
  • the present application provides a communication method based on homogeneous multi-core multi-operating systems.
  • the multi-operating system includes at least a first operating system and a second operating system, the first operating system and the second operating system are located in different cores of the same processor, the communication method includes: monitoring the first data write operation, the first operating system Update the first data to the cache unit of the second operating system through the cache consistency mechanism; detect that the first data write operation is completed, and the first operating system sends a sharing notification to the second operating system; the second operating system receives the sharing notification , acquire the first data from the cache unit.
  • the present application provides a multi-operating system based on homogeneous multi-core.
  • the multi-operating system based on isomorphic multi-core at least includes: a first operating system and a second operating system, the first operating system and the second operating system are located in different cores of the same processor, and the first operating system detects the first data write operation , update the first data to the cache unit of the second operating system through the cache coherency mechanism; the first operating system detects that the first data write operation is completed, and sends a sharing notification to the second operating system; the second operating system receives the sharing Notify to obtain the first data from the cache unit.
  • the present application provides a chip.
  • the chip runs multiple operating systems based on isomorphic multi-core, and the multiple operating systems include at least a first operating system and a second operating system, and the first operating system and the second operating system are located in different cores of the same processor, wherein the processor adopts the above-mentioned
  • the communication method of the multi-operating system based on the homogeneous multi-core realizes the multi-communication system communication.
  • the multi-operating system of the present application includes at least a first operating system and a second operating system, the first operating system and the second operating system are located in different cores of the same processor, and the second operating system
  • An operating system first updates the first data to the cache unit of the second operating system through a cache consistency mechanism, and after the first data write operation is completed, it notifies the second operating system to directly obtain the first data from its cache unit; therefore, the first When an operating system synchronizes the first data to the second operating system, the first operating system does not need to store the first data in its cache unit in the physical memory, and the second operating system does not need to clear the data in its cache unit, Instead, the first data may be directly read from the cache unit of the first operating system after receiving the sharing notification from the first operating system. Therefore, the efficiency of data synchronization between operating systems can be improved.
  • FIG. 1 is a schematic structural diagram of an embodiment of a multi-operating system based on homogeneous multi-core in the present application;
  • FIG. 2 is a schematic flowchart of an embodiment of a communication method based on a homogeneous multi-core multi-operating system in the present application;
  • Fig. 3 is a schematic flow chart of step S21 in the embodiment of Fig. 2;
  • Fig. 4 is a schematic flow chart of step S35 in the embodiment of Fig. 2;
  • FIG. 5 is a schematic diagram of a data synchronization process in the prior art
  • Fig. 6 is a schematic diagram of the direction of data flow in the embodiment of Fig. 5;
  • Fig. 7 is a schematic diagram of the data synchronization process in the embodiment of Fig. 2;
  • Fig. 8 is a schematic diagram of the direction of data flow in the embodiment of Fig. 7;
  • FIG. 9 is a schematic flowchart of an embodiment of a communication method based on a homogeneous multi-core multi-operating system of the present application.
  • FIG. 10 is a schematic flowchart of an embodiment of a communication method based on a homogeneous multi-core multi-operating system in the present application.
  • Single-chip multi-system solutions are currently mainstream in vehicles, such as software virtualization solutions (Hypervisor), hardware intra-chip isolation solutions (in the case of heterogeneous multi-systems), etc.
  • Different operating systems are responsible for different tasks.
  • the software virtualization solution its general implementation is to design a layer of software on the CPU EL2 (Exception Level), and the EL2 software is responsible for managing data sharing and synchronization.
  • the EL2 software is responsible for managing data sharing and synchronization.
  • it is usually implemented by using hardware IPC combined with shared memory technology.
  • the data synchronization efficiency between the systems of these two schemes is low.
  • FIG. 1 is a schematic structural diagram of an embodiment of a multi-operating system based on homogeneous multi-core in the present application.
  • the multi-operating system (not shown) based on homogeneous multi-core in this embodiment includes at least a first operating system 10 and a second operating system 20 , and the first operating system 10 and the second operating system 20 are located in different cores of the same processor.
  • the first operating system 10 monitors the first data write operation (the operation of writing into the cache unit 11), and updates the first data (from the cache unit 11) to the cache unit of the second operating system 20 through the cache consistency mechanism
  • the first operating system 10 detects that the writing operation of the first data is completed, and sends a sharing notification to the second operating system 20 ; the second operating system 20 receives the sharing notification, and obtains the first data from the cache unit 21 .
  • the first operating system 10 of this embodiment synchronizes the first data to the second operating system 20
  • the first operating system 10 does not need to store the first data in its cache unit 11 in the physical memory 30, and the second operating system 20
  • the multi-operating system of isomorphic multi-core in the present embodiment and the following embodiment is described by taking the ARM processor (4 core CortexA53) as an example, the first operating system 10 is an audio-visual entertainment system IVI system, and the second operating system is an instrument system RTOS system.
  • the RTOS system control and IVI system control solutions are simultaneously implemented on the vehicle platform.
  • the IVI system tries to transmit phone information, map information, music playlist information, etc. to the RTOS system for displaying relevant information on the instrument side
  • the solution of this embodiment can realize efficient synchronization of data.
  • the IVI system configuration uses Core 0-Core2 three cores to run the Android system, and the RTOS system task is relatively simple, so the configuration uses Core3 one core to run the RTOS system.
  • the IVI system and the RTOS system are isomorphic systems, the two operating systems need to access exactly the same physical memory unit. Therefore, in order to prevent the mutual influence on memory data between the two operating systems, it is necessary to additionally configure MMU mapping for memory isolation, that is, to map the virtual addresses of some cache units 11 of the IVI system to the virtual addresses of the IVI system through the Stage2 mapping of the MMU mapping.
  • data synchronization between multiple operating systems requires a shared physical memory, which is used in the case where both the IVI system and the RTOS system can be accessed; through the Stage2 mapping of the MMU mapping, the other part of the IVI system is mapped The virtual address of a part of the cache unit and the virtual address of another part of the cache unit of the RTOS system are mapped to the shared physical memory unit.
  • the MMU mapping is controlled by the processor, and its function is to realize the conversion from the virtual address of the cache unit to the physical address.
  • the conversion process is divided into two stages: Stage 1, used to convert the input VA (virtual address) into PA (physical address) or IPA (corrected virtual address) output; Stage 2, used to convert IPA into pa. Or combine Stage 1 and Stage 2 to input VA->IPA->PA.
  • the physical memory of the multi-operating system is divided into three parts, in which the IVI system exclusively occupies one physical memory, and the RTOS system exclusively occupies the other physical memory, which can reduce the abnormality caused by stepping on the memory between the systems.
  • the VI system and the RTOS system share the shared physical memory. .
  • the effect of the physical memory unit on the cache consistency includes: as an intermediate bridge where the address of the cache unit 21 of the RTOS system is consistent with the address of the cache unit 11 of the IVI system, that is, the virtual addresses of the cache unit 21 and the cache unit 11 are respectively mapped to the shared physical memory unit, and the two virtual addresses are consistent; and after the data in the cache unit 11 is full, when writing data, it is necessary to transfer the existing data of the cache unit 11 to the shared physical memory unit. At this time, the shared physical memory unit is equivalent to the cache Trash can in unit 11.
  • the same spinlock driver is added in the first operating system 10 and the second operating system 20, and the first operating system 10 and the second operating system 20 are required to use the spinlock driver when applying for the protection of shared resources.
  • the address of the shared physical memory unit occupied by the applied spin lock is the same.
  • a separate hardware module “Exclusive Monitor (Exclusive Monitor)" is provided to support this function, and this embodiment only needs a local monitor to implement a more convenient spinlock mechanism, while saving Snooping on the external bus optimizes control transfer times.
  • the spin lock driver requires that the first operating system 10 and the second operating system 20 can be allocated on demand, and the same lock is used when mutually exclusive access between the first operating system 10 and the second operating system 20, This requires that the allocation of locks also needs to be in shared physical memory units.
  • FIG. 2 is a schematic structural diagram of an embodiment of a communication method based on a homogeneous multi-core multi-operating system in the present application. This embodiment specifically includes the following steps:
  • Step S21 When the first data writing operation is detected, the first operating system updates the first data to the cache unit of the second operating system through a cache coherence mechanism.
  • the first operating system After monitoring the operation of writing the first data into the cache unit of the first operating system, the first operating system updates the first data from the cache unit of the first operating system to the cache unit of the second operating system through a cache coherence mechanism.
  • a cache coherence mechanism is used to manage data transmission between cores of different operating systems. Its core mechanism is to represent each cache unit (Cache line) with a state:
  • M (Modify) bit: M is 1, indicating that the data contained in the current Cache line is inconsistent with the data in the physical memory unit, and it is only valid in the Cache line of this CPU (core), and does not exist in the Cache lines of other CPUs Copy, the data in this Cache row is the latest data copy in the current operating system.
  • the CPU replaces the Cache line, it will inevitably trigger a write cycle on the system bus to synchronize the data in the Cache line with the data in the memory.
  • E (Exclusive) bit When E is 1, it means that the data contained in the current Cache line is valid, and the data is only valid in the Cache line of the current CPU, and there is no copy in the Cache lines of other CPUs.
  • the data in the Cache row is the latest data copy in the current operating system, and is consistent with the data in the physical memory unit.
  • S (Shared) bit S being 1 indicates that the data contained in the Cache line is valid, and there is a copy in the current CPU and at least one other CPU.
  • S Shared
  • the state of a cache line is S, the data it contains is not necessarily consistent with the physical memory unit. If there is no copy with state O in the cache of other CPUs, the data in the cache line is consistent with the memory; if there is a copy with state O in the cache line of other CPUs, the data in the cache line is consistent with the physical memory Units are inconsistent.
  • I (Invalid) bit I being 1 indicates that there is no valid data in the current Cache line or the Cache line is not enabled.
  • the MESI protocol performs Cache line replacement, it will preferentially use the Cache line whose I bit is 1.
  • O (Owned) bit O being 1 indicates that the data contained in the current Cache line is the latest data copy of the current operating system, and there must be a copy of the Cache line in other CPUs, and the Cache line status of other CPUs is S. If the data of the physical memory unit has copies in the Cache lines of multiple CPUs, there is only one CPU whose Cache line status is O, and the Cache line status of other CPUs can only be S. Different from the S state in the MESI protocol, the data in the Cache row whose state is O is not consistent with the data in the physical memory unit.
  • the ARM processor is responsible for monitoring and maintaining the cache coherence between the cores through the snoop control unit (Snoop Control Unit, SCU), and also provides arbitration access to the L2Cache.
  • SCU snoop Control Unit
  • each core in the SMP system has a register to control the switch of the cache coherency unit. Taking the Cortex A53 of ARM as an example, if the register CPUECTLR.smp bit is set, the SCU is turned on.
  • the SCU combined with the MOESI protocol can maintain the consistency of the data in the cache unit in time, and ensure the accuracy of the data obtained between each core, and these operations do not require software participation, which improves the maintainability of the software.
  • the SCU can monitor changes in the status of the Cache line corresponding to the physical memory unit in the IVI system, and can actively maintain cache consistency.
  • step S21 may be implemented by the method shown in FIG. 3 .
  • the method of this embodiment includes step S30 to step S35.
  • Step S30 The first data writing operation is detected.
  • An operation of writing the first data into the cache unit of the first operating system is monitored.
  • Step S31 the first operating system writes the first data into the cache unit of the first operating system.
  • the first operating system writes the first data into a corresponding Cache line in the first operating system.
  • Step S32 If the cache unit of the second operating system is empty, the cache unit of the first operating system writes the first data into the cache unit of the second operating system.
  • the data of the cache unit of the core where the first operating system is located is automatically synchronized to the cache unit of the core where the second operating system is located.
  • the first operating system directly writes the first data in the corresponding Cache line into the corresponding Cache line in the RTOS.
  • Step S33 If the cache unit of the second operating system stores the second data, mark the status of the cache unit of the second operating system as invalid.
  • the state of the corresponding Cache line in the RTOS system is changed to I (Invalid).
  • Step S34 Determine whether there is a copy of the second data in the second operating system.
  • the RTOS system does not need to clear the cache when it starts to receive data, but can directly initiate a read request. At this time, other cores in the RTOS system can monitor the read request and actively check whether its own cache has a copy of the second data. .
  • Step S35 If the second operating system has a copy of the second data, update the first data to the cache unit of the second operating system based on the storage of the first data by the first operating system.
  • the first data may be updated to the Cache line in the RTOS system based on the storage of the first data by the IVI system.
  • step S35 may be implemented through the method shown in FIG. 4 .
  • the method of this implementation includes step S41 and step S42.
  • Step S41 If the first operating system has a copy of the first data, and the copy of the first data is consistent with the data in the corresponding physical memory, directly write the copy of the first data into the cache unit of the second operating system .
  • the CPU in the IVI system finds a local copy and the status is E, it will directly flush the first data in the Cache line to the Cache line in the RTOS system. At this time, the statuses of the Cache lines corresponding to the RTOS system and the IVI system are both changed to S.
  • Step S42 If the first operating system has a copy of the first data, and the copy of the first data is inconsistent with the data in the corresponding physical memory, first write the copy of the first data into the corresponding physical memory unit, and then Writing the copy of the first data in the corresponding physical memory unit into the cache unit of the second operating system.
  • the CPU in the IVI system finds a local copy, and the state is M, it first updates the content in the Cache line to the physical memory unit. At this time, the state of the Cache line in the IVI system changes from M to S. At this time, the RTOS system needs to change from Acquire the first data from the physical memory unit.
  • Step S22 Upon detecting that the first data writing operation is completed, the first operating system sends a sharing notification to the second operating system.
  • the sign that the shared data writing is completed is the completion of flushing the cache, but in this embodiment, the cache consistency mechanism is used for self-maintenance, so the sign that the shared data writing is completed is the writing operation of the software (for example: memcpy, memset, etc. ).
  • a shared notification can be sent to the RTOS system through an inter-core interrupt (Software Generate Interrupt, SGI).
  • SGI Software Generate Interrupt
  • Step S23 the second operating system receives the sharing notification, and acquires the first data from the cache unit.
  • the RTOS system receives the sharing notification, and acquires the first data from the corresponding cache unit.
  • the IVI system of the data sending party in order to eliminate the cache interference between the IVI system and the RTOS system and ensure the accuracy of the data, the IVI system of the data sending party usually has two methods: close the cache unit in the corresponding area or after each data write is completed Actively refresh the cache. If the RTOS system of the corresponding data receiver does not close the cache unit in the corresponding area, it will clear the cache of the RTOS system before trying to receive the data, and then obtain the data from the shared physical memory unit. If the IVI system does not refresh the cache, there will be data inconsistency: the IVI system writes the data, but some data still exists in the cache line and has not been written into the shared physical memory unit.
  • the data obtained by the physical memory unit is stale; if the RTOS system does not perform the operation of clearing the Cache, data inconsistency will also occur: the IVI system writes the data and completely flushes the data to the shared physical memory unit.
  • the RTOS system directly reads the data because there is a cache. If the current RTOS system has previously backed up the data of the corresponding address in the Cache line (that is, the CPU read operation), then the RTOS system will directly read from its own Cache when it reads again. The old data is read out from the row without re-acquiring new data from the shared physical memory unit.
  • FIG. 7 when the IVI system needs to synchronize data to the RTOS system, the operation flow is shown in FIG. 7 , and the corresponding data flow is shown in FIG. 8 .
  • This embodiment uses the cache consistency mechanism to solve the above problems.
  • When performing data synchronization operations there is no need to actively operate the cache unit, and there is no need to care about whether it is the operation of flushing the Cache of the write operator or the operation of clearing the Cache of the read operator.
  • the existence of the cache unit also increases the rate of data transfer.
  • FIG. 9 is a schematic structural diagram of an embodiment of a communication method based on a homogeneous multi-core multi-operating system in the present application. This embodiment specifically includes the following steps:
  • Step S91 Configuring a shared physical memory unit for the first operating system and the second operating system.
  • the first exclusive physical memory unit is configured for the first operating system
  • the second exclusive physical memory unit is configured for the second system
  • the shared physical memory unit is configured for the first operating system and the second operating system.
  • the role of the shared physical memory unit on cache coherence includes: as an intermediate bridge between the addresses of the cache unit of the RTOS system and the cache unit of the IVI system: the virtual address of each cache unit must be mapped to a real physical address (convenient in Non-cache consistency, that is, in the non-communication state, each operating system can access the shared physical memory unit separately), so they are respectively mapped to the shared physical memory unit, and the two virtual addresses are consistent; under the condition of cache consistency , shared physical memory provides the real physical address as an intermediate mapping of the addresses of the cache units of the two operating systems. After the data in the cache unit is full, when writing data, the existing data in the cache unit needs to be moved to the shared physical memory unit. At this time, the shared physical memory unit is equivalent to the trash can of the cache unit.
  • Step S92 Map the virtual address of the cache unit of the first operating system and the virtual address of the cache unit of the second operating system to the shared physical memory unit through MMU mapping.
  • the virtual address of another part of the cache unit of one operating system and the virtual address of another part of the cache unit of the second operating system are mapped to the shared physical memory unit.
  • the IVI system and the RTOS system achieve cache coherence through the shared physical memory unit of the two.
  • the two operating systems can access exactly the same physical memory unit, that is, share the physical memory unit. Therefore, in order to prevent the mutual influence of memory data between the two operating systems, it is necessary to additionally configure MMU mapping for memory isolation, that is, to map the virtual addresses of some cache units of the IVI system to the first stage of the IVI system through the Stage2 mapping of the MMU mapping.
  • MMU mapping for memory isolation, that is, to map the virtual addresses of some cache units of the IVI system to the first stage of the IVI system through the Stage2 mapping of the MMU mapping.
  • An exclusive physical memory unit and the virtual address of the part cache unit of the RTOS system are mapped to the second exclusive physical memory unit of the RTOS system.
  • the same physical address of multiple operating systems is mapped to the physical memory unit; for reducing the distance between the IVI system and the RTOS system
  • the time of data transfer, data synchronization between multiple operating systems requires a shared physical memory unit, which is used in the case where both the IVI system and the RTOS system can be accessed.
  • the Stage2 mapping of the MMU mapping will map the virtual address of another part of the cache unit of the IVI system and The virtual address of another part of the cache unit of the RTOS system is mapped to the shared physical memory unit.
  • the virtual address of the cache unit 11 of the IVI system and the virtual address of the cache unit 21 of the RTOS system are mapped to the same physical address of multiple operating systems through MMU mapping, that is, to a shared physical memory unit.
  • the data caching methods of multiple operating systems include: VIVT, VIPT or PIPT.
  • VIVT Virtual Index Virtual Tag
  • VIPT Virtual Index Physical Tag
  • PIPT Physical Index Physical Tag It is an index field using a physical address and a tag field of a physical address.
  • Step S93 In response to the fact that the data caching mode is VIVT, different flags are set for the virtual address space of the first operating system and the virtual address space of the second operating system.
  • the same mapping relationship is configured for the Stage1 mapping of the MMU mapping of the shared physical memory unit by the first operating system and the second operating system, and are respectively the virtual address space of the first operating system and the second operating system.
  • the operating system's virtual address space sets different flags.
  • the cache consistency maintenance can be designed to be consistent based on the physical address, for multiple operating systems
  • the mapping method does not require additional requirements. It only needs to use the same physical address when sharing data.
  • the cache consistency is maintained by the SCU itself.
  • the first operating system and the second operating system need to configure the same mapping relationship for the Stage1 mapping of the shared memory area, so as to ensure the consistency of the cache.
  • the data cache mode when the data cache mode is VIVT, it may cause the problem of cache aliases, that is, multiple identical virtual addresses may be mapped to the same physical address; for example, inter-process communication, which will lead to pointing to the same physical address
  • the caches of the virtual addresses are stored separately, so there may be consistency problems. For example, after changing the cache line of a virtual address, the cache of the virtual address pointing to the same physical address is not changed, resulting in data inconsistency.
  • different virtual address spaces are distinguished by adding a tag (ASID) to each virtual address space.
  • ASID tag
  • Step S94 The first operating system updates the first data into the cache unit of the second operating system through a cache coherence mechanism.
  • the first operating system After detecting the write operation of the first data, the first operating system updates the first data to the cache unit of the second operating system through a cache consistency mechanism.
  • Step S95 upon detecting that the first data writing operation is completed, the first operating system sends a sharing notification to the second operating system.
  • Step S96 The second operating system receives the sharing notification, and obtains data from the cache unit.
  • Steps S94 to S96 are similar to the above steps S11 to S13 and will not be repeated here.
  • FIG. 10 is a schematic structural diagram of an embodiment of a communication method based on a homogeneous multi-core multi-operating system in the present application. This embodiment specifically includes the following steps:
  • Step S101 upon detecting the first data write operation, the first operating system updates the first data to the cache unit of the second operating system through a cache coherence mechanism.
  • Step S102 upon detecting that the first data writing operation is completed, the first operating system sends a sharing notification to the second operating system.
  • Step S103 the second operating system receives the sharing notification, and obtains data from the cache unit.
  • Steps S101 to S103 are similar to the above steps S11 to S13 and will not be repeated here.
  • Step S104 It is detected that the first operating system and the second operating system jointly access the same shared physical memory unit, and the spin lock application of the first operating system or the second operating system is detected, and a variable is created in the shared physical memory unit to Store current data in the same shared physical memory unit.
  • Step S105 Locally monitor multiple operating systems, and write current data into the same shared physical memory unit after the monopoly of the same shared physical memory unit ends.
  • the ARM processor provides a separate hardware module "Exclusive Monitor (Exclusive Monitor)" to support this function, and this embodiment only needs a local monitor to implement a more convenient spinlock mechanism, and at the same time Elimination of external bus snooping optimizes control transfer times.
  • a hardware firewall may be added for monitoring memory access control, and the minimum unit that the hardware firewall can monitor needs to be each core. In this way, even if there is a problem with the system MMU configuration, the memory conflict of the system can be isolated from the hardware to ensure the independence of the system.
  • the present application further proposes a chip.
  • the chip in this embodiment runs multiple operating systems.
  • the multiple operating systems include at least a first operating system and a second operating system.
  • the first operating system and the second operating system are located in different cores of the same processor.
  • the processor adopts the communication method based on the homogeneous multi-core multi-operating system in the above-mentioned embodiment to implement multi-communication system communication.
  • the multi-operating system of the present application includes at least a first operating system and a second operating system.
  • the first operating system and the second operating system are located in different cores of the same processor.
  • the first operating system first passes the cache coherency
  • the mechanism updates the first data to the cache unit of the second operating system.
  • the second operating system After the first data write operation is completed, the second operating system is notified to obtain the first data directly from its cache unit; therefore, the first operating system synchronizes the first data
  • the first operating system When the second operating system arrives, the first operating system does not need to store the first data in its cache unit into the physical memory, and the second operating system does not need to clear the data in its cache unit, but directly receives the first
  • the first data can be directly read from its cache unit, therefore, the efficiency of data synchronization between operating systems can be improved.
  • the synchronization of data transmission between cores of different operating systems is more free, without too much software participation; memory isolation technology is added to clarify shared memory and non-shared memory, reducing multi-operation Interaction between systems; multiple operating systems use a unified spin lock driver to provide a more convenient protection mechanism for accessing critical resources between multiple operating systems.

Landscapes

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

Abstract

Provided in the present application are a homogeneous multi-core-based multi-operating system, a communication method therefor, and a chip. The multi-operating system at least comprises a first operating system and a second operating system, wherein the first operating system and the second operating system are located in different cores of the same processor. The communication method comprises: upon detecting a first data write operation, a first operating system updating first data to a cache unit of a second operating system by means of a cache coherence mechanism; upon detecting that the first data write operation is completed, the first operating system sending a sharing notification to the second operating system; and the second operating system receiving the sharing notification and acquiring the first data from the cache unit. By means of the method, the efficiency of data synchronization between operating systems can be improved.

Description

基于同构多核的多操作系统及通信方法、芯片Multi-operating system, communication method, and chip based on isomorphic multi-core 【技术领域】【Technical field】

本申请涉及多系统通信技术领域,特别是涉及一种基于同构多核的多操作系统及通信方法、芯片。The present application relates to the technical field of multi-system communication, in particular to a multi-operating system based on homogeneous multi-core, a communication method, and a chip.

【背景技术】【Background technique】

当前,在车机上“单芯片多系统”的方案越来越流行。复杂的工作常常需要多操作系统间的协调配合来完成,系统间的配合需要良好的数据通信机制。At present, the "single-chip multi-system" solution on the car is becoming more and more popular. Complicated work often requires the coordination and cooperation between multiple operating systems to complete, and the cooperation between systems requires a good data communication mechanism.

单芯片多系统的方案在车机上目前主流的如软件虚拟化方案(Hypervisor)、硬件芯片内隔离方案(异构多系统的情况)等,不同的操作系统负责不同的任务内容。对于软件虚拟化方案,其通用实现是在CPU EL2(Exception Level)设计一层软件,由EL2的软件统一负责管理数据的共享以及同步。对于异构多系统的方案,通常使用硬件IPC结合共享内存的技术来实现。但这两种方案的系统间的数据同步效率较低。Single-chip multi-system solutions are currently mainstream in vehicles, such as software virtualization solutions (Hypervisor), hardware intra-chip isolation solutions (in the case of heterogeneous multi-systems), etc. Different operating systems are responsible for different tasks. For the software virtualization solution, its general implementation is to design a layer of software on the CPU EL2 (Exception Level), and the EL2 software is responsible for managing data sharing and synchronization. For heterogeneous multi-system solutions, it is usually implemented by using hardware IPC combined with shared memory technology. However, the data synchronization efficiency between the systems of these two schemes is low.

【发明内容】【Content of invention】

本申请主要解决的技术问题是提供一种基于同构多核的多操作系统及其数据同步方法、芯片,以提高操作系统间数据同步的效率。The technical problem mainly solved by this application is to provide a multi-operating system based on isomorphic multi-core and its data synchronization method and chip, so as to improve the efficiency of data synchronization between operating systems.

为解决上述技术问题,本申请提供一种基于同构多核的多操作系统的通信方法。该多操作系统至少包括第一操作系统及第二操作系统,第一操作系统与第二操作系统位于同一处理器的不同内核,该通信方法包括:监测到第一数据写操作,第一操作系统通过缓存一致性机制将第一数据更新到第二操作系统的缓存单元中;监测到第一数据写操作完成,第一操作系统向第二操作系统发送共享通知;第二操作系统接收到共享通知,从缓存单元中获取第一数据。In order to solve the above technical problems, the present application provides a communication method based on homogeneous multi-core multi-operating systems. The multi-operating system includes at least a first operating system and a second operating system, the first operating system and the second operating system are located in different cores of the same processor, the communication method includes: monitoring the first data write operation, the first operating system Update the first data to the cache unit of the second operating system through the cache consistency mechanism; detect that the first data write operation is completed, and the first operating system sends a sharing notification to the second operating system; the second operating system receives the sharing notification , acquire the first data from the cache unit.

为解决上述技术问题,本申请提供一种基于同构多核的多操作系统。该基于同构多核的多操作系统至少包括:第一操作系统及第二操作系统,第一操作系统及第二操作系统位于同一处理器的不同内核,第一操作系统监测到第一数据写操作,通过缓存一致性机制将第一数据更新到第二操作系统的缓存单元中;第一操作系统监测到第一数据写操作完成,向第二操作系统发送共享通知;第二操作系统接收到共享通知,从缓存单元中获取第一数据。In order to solve the above technical problems, the present application provides a multi-operating system based on homogeneous multi-core. The multi-operating system based on isomorphic multi-core at least includes: a first operating system and a second operating system, the first operating system and the second operating system are located in different cores of the same processor, and the first operating system detects the first data write operation , update the first data to the cache unit of the second operating system through the cache coherency mechanism; the first operating system detects that the first data write operation is completed, and sends a sharing notification to the second operating system; the second operating system receives the sharing Notify to obtain the first data from the cache unit.

为解决上述技术问题,本申请提供一种芯片。该芯片基于同构多核的运行多操作系统,多操作系统至少包括第一操作系统及第二操作系统,第一操作系 统及第二操作系统位于同一处理器的不同内核,其中,处理器采用上述基于同构多核的多操作系统的通信方法实现多通信系统通信。In order to solve the above technical problems, the present application provides a chip. The chip runs multiple operating systems based on isomorphic multi-core, and the multiple operating systems include at least a first operating system and a second operating system, and the first operating system and the second operating system are located in different cores of the same processor, wherein the processor adopts the above-mentioned The communication method of the multi-operating system based on the homogeneous multi-core realizes the multi-communication system communication.

与现有技术相比,本申请的有益效果是:本申请的多操作系统至少包括第一操作系统及第二操作系统,第一操作系统及第二操作系统位于同一处理器不同的内核,第一操作系统先通过缓存一致性机制将第一数据更新到第二操作系统的缓存单元中,第一数据写操作完成后,通知第二操作系统直接从其缓存单元获取第一数据;因此,第一操作系统将第一数据同步到第二操作系统时,第一操作系统无需将其缓存单元中的第一数据存到物理内存中,第二操作系统也无需将其缓存单元中的数据清空,而是直接在接收到第一操作系统的共享通知后直接从其缓存单元读取第一数据即可,因此,能够提高操作系统间数据同步的效率。Compared with the prior art, the beneficial effects of the present application are: the multi-operating system of the present application includes at least a first operating system and a second operating system, the first operating system and the second operating system are located in different cores of the same processor, and the second operating system An operating system first updates the first data to the cache unit of the second operating system through a cache consistency mechanism, and after the first data write operation is completed, it notifies the second operating system to directly obtain the first data from its cache unit; therefore, the first When an operating system synchronizes the first data to the second operating system, the first operating system does not need to store the first data in its cache unit in the physical memory, and the second operating system does not need to clear the data in its cache unit, Instead, the first data may be directly read from the cache unit of the first operating system after receiving the sharing notification from the first operating system. Therefore, the efficiency of data synchronization between operating systems can be improved.

【附图说明】【Description of drawings】

图1是本申请基于同构多核的多操作系统一实施例的结构示意图;FIG. 1 is a schematic structural diagram of an embodiment of a multi-operating system based on homogeneous multi-core in the present application;

图2是本申请基于同构多核的多操作系统的通信方法一实施例的流程示意图;FIG. 2 is a schematic flowchart of an embodiment of a communication method based on a homogeneous multi-core multi-operating system in the present application;

图3是图2实施例中步骤S21的具体流程示意图;Fig. 3 is a schematic flow chart of step S21 in the embodiment of Fig. 2;

图4是图2实施例中步骤S35的具体流程示意图;Fig. 4 is a schematic flow chart of step S35 in the embodiment of Fig. 2;

图5是现有技术的数据同步流程示意图;FIG. 5 is a schematic diagram of a data synchronization process in the prior art;

图6是图5实施例的数据流走向的示意图;Fig. 6 is a schematic diagram of the direction of data flow in the embodiment of Fig. 5;

图7是图2实施例中数据同步流程示意图;Fig. 7 is a schematic diagram of the data synchronization process in the embodiment of Fig. 2;

图8是图7实施例的数据流走向的示意图;Fig. 8 is a schematic diagram of the direction of data flow in the embodiment of Fig. 7;

图9是本申请基于同构多核的多操作系统的通信方法一实施例的流程示意图;FIG. 9 is a schematic flowchart of an embodiment of a communication method based on a homogeneous multi-core multi-operating system of the present application;

图10是本申请基于同构多核的多操作系统的通信方法一实施例的流程示意图。FIG. 10 is a schematic flowchart of an embodiment of a communication method based on a homogeneous multi-core multi-operating system in the present application.

【具体实施方式】【Detailed ways】

下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅是本申请的一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of them. Based on the embodiments in this application, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the scope of protection of this application.

单芯片多系统的方案在车机上目前主流的如软件虚拟化方案(Hypervisor)、硬件芯片内隔离方案(异构多系统的情况)等,不同的操作系统负责不同的任务内容。对于软件虚拟化方案,其通用实现是在CPU EL2(Exception Level)设计一层软件,由EL2的软件统一负责管理数据的共享以及同步。对于异构多系统的方案,通常使用硬件IPC结合共享内存的技术来实现。但这两种方案的系统间的数据同步效率较低。Single-chip multi-system solutions are currently mainstream in vehicles, such as software virtualization solutions (Hypervisor), hardware intra-chip isolation solutions (in the case of heterogeneous multi-systems), etc. Different operating systems are responsible for different tasks. For the software virtualization solution, its general implementation is to design a layer of software on the CPU EL2 (Exception Level), and the EL2 software is responsible for managing data sharing and synchronization. For heterogeneous multi-system solutions, it is usually implemented by using hardware IPC combined with shared memory technology. However, the data synchronization efficiency between the systems of these two schemes is low.

而异构系统之间的通信需要增加外部硬件来触发中断,而同构系统的多核之间可以更快的触发中断;异构系统之间的缓存通常是不共享的,因此也无法保证一致性,这就导致了系统之间传递数据需要经过:写入缓存+刷到内存及清空缓存+从内存读的漫长流程,影响了数据的同步效率。Communication between heterogeneous systems requires additional external hardware to trigger interrupts, while multi-cores in homogeneous systems can trigger interrupts faster; caches between heterogeneous systems are usually not shared, so consistency cannot be guaranteed , This leads to the long process of data transfer between systems: writing cache + flushing to memory and clearing cache + reading from memory, which affects the synchronization efficiency of data.

为解决上述问题,本申请首先提出一种基于同构多核的多操作系统,如图1所示,图1是本申请基于同构多核的多操作系统一实施例的结构示意图。本实施例基于同构多核的多操作系统(图未标)至少包括第一操作系统10及第二操作系统20,第一操作系统10及第二操作系统20位于同一处理器的不同内核。其中,第一操作系统10监测到第一数据写操作(写入缓存单元11的操作),通过缓存一致性机制将第一数据(从缓存单元11中)更新到第二操作系统20的缓存单元21中;第一操作系统10监测到第一数据写操作完成,向第二操作系统20发送共享通知;第二操作系统20接收到共享通知,从缓存单元21中获取第一数据。In order to solve the above problems, the present application first proposes a multi-operating system based on homogeneous multi-core, as shown in FIG. 1 , which is a schematic structural diagram of an embodiment of a multi-operating system based on homogeneous multi-core in the present application. The multi-operating system (not shown) based on homogeneous multi-core in this embodiment includes at least a first operating system 10 and a second operating system 20 , and the first operating system 10 and the second operating system 20 are located in different cores of the same processor. Wherein, the first operating system 10 monitors the first data write operation (the operation of writing into the cache unit 11), and updates the first data (from the cache unit 11) to the cache unit of the second operating system 20 through the cache consistency mechanism In 21 : the first operating system 10 detects that the writing operation of the first data is completed, and sends a sharing notification to the second operating system 20 ; the second operating system 20 receives the sharing notification, and obtains the first data from the cache unit 21 .

本实施例的第一操作系统10将第一数据同步到第二操作系统20时,第一操作系统10无需将其缓存单元11中的第一数据存到物理内存30中,第二操作系统20也无需将其缓存单元21中的数据清空,而是直接在接收到第一操作系统10的共享通知后直接从其缓存单元21读取第一数据即可,因此,能够提高操作系统间数据同步的效率。When the first operating system 10 of this embodiment synchronizes the first data to the second operating system 20, the first operating system 10 does not need to store the first data in its cache unit 11 in the physical memory 30, and the second operating system 20 There is also no need to clear the data in its cache unit 21, but directly read the first data from its cache unit 21 after receiving the sharing notification from the first operating system 10. Therefore, data synchronization between operating systems can be improved s efficiency.

本实施例及下文实施例中的同构多核的多操作系统以ARM处理器(4核CortexA53)为例进行描述,第一操作系统10为影音娱乐系统IVI系统,第二操作系统为仪表系统RTOS系统。The multi-operating system of isomorphic multi-core in the present embodiment and the following embodiment is described by taking the ARM processor (4 core CortexA53) as an example, the first operating system 10 is an audio-visual entertainment system IVI system, and the second operating system is an instrument system RTOS system.

使用一个ARM CortexA53(4核),在车载平台上同时实现RTOS系统的管控和IVI系统的管控方案。当IVI系统试图将电话信息、地图信息、音乐播放列表信息等传递给RTOS系统,用于在仪表端显示相关信息,通过本实施例的方案能够实现数据的高效同步。Using an ARM CortexA53 (4 cores), the RTOS system control and IVI system control solutions are simultaneously implemented on the vehicle platform. When the IVI system tries to transmit phone information, map information, music playlist information, etc. to the RTOS system for displaying relevant information on the instrument side, the solution of this embodiment can realize efficient synchronization of data.

其中,IVI系统配置使用Core 0-Core2三个核来运行Android系统,RTOS系统任务相对简单,故配置使用Core3一个核运行RTOS系统。因IVI系统与RTOS系统为同构系统,因此这两个操作系统需要访问完全相同的物理内存单元。因此,为了防止两个操作系统之间对内存数据的互相影响,需要额外配置MMU映射来进行内存隔离,即通过MMU映射的Stage2映射将IVI系统的部分缓存单元11的虚拟地址映射到IVI系统的独占物理内存单元及将RTOS系统的部分缓存单元21的虚拟地址映射到RTOS系统的独占物理内存单元。为减少IVI系统与RTOS系统间数据传递的时间,多操作系统间的数据同步需要一段共享物理内存,用于IVI系统与RTOS系统都可以访问的情况;通过MMU映射的Stage2映射将IVI系统的另一部分缓存单元的虚拟地址及RTOS系统的另一部分缓存单元的虚拟地址映射到共享物理内存单元。Among them, the IVI system configuration uses Core 0-Core2 three cores to run the Android system, and the RTOS system task is relatively simple, so the configuration uses Core3 one core to run the RTOS system. Because the IVI system and the RTOS system are isomorphic systems, the two operating systems need to access exactly the same physical memory unit. Therefore, in order to prevent the mutual influence on memory data between the two operating systems, it is necessary to additionally configure MMU mapping for memory isolation, that is, to map the virtual addresses of some cache units 11 of the IVI system to the virtual addresses of the IVI system through the Stage2 mapping of the MMU mapping. Exclusive physical memory unit and mapping the virtual address of part of the cache unit 21 of the RTOS system to the exclusive physical memory unit of the RTOS system. In order to reduce the data transmission time between the IVI system and the RTOS system, data synchronization between multiple operating systems requires a shared physical memory, which is used in the case where both the IVI system and the RTOS system can be accessed; through the Stage2 mapping of the MMU mapping, the other part of the IVI system is mapped The virtual address of a part of the cache unit and the virtual address of another part of the cache unit of the RTOS system are mapped to the shared physical memory unit.

其中,MMU映射由处理器控制,其功能是实现缓存单元的虚拟地址到物理地址的转换。该转换过程分为两个阶段将:Stage 1,用于将输入的VA(虚拟地址)转换成PA(物理地址)或者IPA(修正后的虚拟地址)输出;Stage 2,用于将IPA转换成PA。或者结合Stage 1和Stage 2将输入的VA->IPA->PA。Wherein, the MMU mapping is controlled by the processor, and its function is to realize the conversion from the virtual address of the cache unit to the physical address. The conversion process is divided into two stages: Stage 1, used to convert the input VA (virtual address) into PA (physical address) or IPA (corrected virtual address) output; Stage 2, used to convert IPA into pa. Or combine Stage 1 and Stage 2 to input VA->IPA->PA.

多操作系统的物理内存被划分为3个部分,其中IVI系统独占一个物理内存、RTOS系统独占另一物理内存,可以减少系统间因踩内存导致的异常,VI系统和RTOS系统共同使用共享物理内存。The physical memory of the multi-operating system is divided into three parts, in which the IVI system exclusively occupies one physical memory, and the RTOS system exclusively occupies the other physical memory, which can reduce the abnormality caused by stepping on the memory between the systems. The VI system and the RTOS system share the shared physical memory. .

其中,物理内存单元对缓存一致性的作用包括:作为RTOS系统的缓存单元21与IVI系统的缓存单元11的地址一致的中间桥梁,即缓存单元21与缓存单元11的虚拟地址分别映射到共享物理内存单元,且两个虚拟地址一致;且缓存单元11的数据写满后,在写入数据时,需要将缓存单元11已有数据搬运到共享物理内存单元,此时共享物理内存单元相当于缓存单元11的垃圾桶。Among them, the effect of the physical memory unit on the cache consistency includes: as an intermediate bridge where the address of the cache unit 21 of the RTOS system is consistent with the address of the cache unit 11 of the IVI system, that is, the virtual addresses of the cache unit 21 and the cache unit 11 are respectively mapped to the shared physical memory unit, and the two virtual addresses are consistent; and after the data in the cache unit 11 is full, when writing data, it is necessary to transfer the existing data of the cache unit 11 to the shared physical memory unit. At this time, the shared physical memory unit is equivalent to the cache Trash can in unit 11.

本实施例在第一操作系统10及第二操作系统20内添加相同的自旋锁驱动,并要求第一操作系统10及第二操作系统20在申请共享资源的保护时通过自旋锁驱动来申请锁,申请到的自旋锁所占用共享物理内存单元的地址是相同的。为了实现内存的独占访问,有提供单独的硬件模块“独占监视器(Exclusive Monitor)”支持此功能,且本实施例只需要本地监视器即可实现更加便捷的自旋锁机制,同时省去了外部总线的监听优化了控制传递时间。In this embodiment, the same spinlock driver is added in the first operating system 10 and the second operating system 20, and the first operating system 10 and the second operating system 20 are required to use the spinlock driver when applying for the protection of shared resources. When applying for a lock, the address of the shared physical memory unit occupied by the applied spin lock is the same. In order to achieve exclusive access to memory, a separate hardware module "Exclusive Monitor (Exclusive Monitor)" is provided to support this function, and this embodiment only needs a local monitor to implement a more convenient spinlock mechanism, while saving Snooping on the external bus optimizes control transfer times.

其中,自旋锁驱动要求第一操作系统10及第二操作系统20间使用时可以按需分配,并且第一操作系统10及第二操作系统20间互斥访问时使用的是同 一把锁,这就要求锁的分配也需要在共享物理内存单元。Among them, the spin lock driver requires that the first operating system 10 and the second operating system 20 can be allocated on demand, and the same lock is used when mutually exclusive access between the first operating system 10 and the second operating system 20, This requires that the allocation of locks also needs to be in shared physical memory units.

本申请进一步提出一种基于同构多核的多操作系统的通信方法,用于上述基于同构多核的多操作系统。如图2所示,图2是本申请基于同构多核的多操作系统的通信方法一实施例的结构示意图。本实施例具体包括以下步骤:The present application further proposes a communication method for multi-operating systems based on homogeneous multi-cores, which is used for the above-mentioned multi-operating systems based on homogeneous multi-cores. As shown in FIG. 2 , FIG. 2 is a schematic structural diagram of an embodiment of a communication method based on a homogeneous multi-core multi-operating system in the present application. This embodiment specifically includes the following steps:

步骤S21:监测到第一数据写操作,第一操作系统通过缓存一致性机制将第一数据更新到第二操作系统的缓存单元中。Step S21: When the first data writing operation is detected, the first operating system updates the first data to the cache unit of the second operating system through a cache coherence mechanism.

监测到第一数据写入第一操作系统的缓存单元的操作,第一操作系统通过缓存一致性机制将第一数据从第一操作系统的缓存单元更新到第二操作系统的缓存单元中。After monitoring the operation of writing the first data into the cache unit of the first operating system, the first operating system updates the first data from the cache unit of the first operating system to the cache unit of the second operating system through a cache coherence mechanism.

以MOESI协议为例对缓存一致性机制进行介绍:Taking the MOESI protocol as an example to introduce the cache consistency mechanism:

本实施例利用缓存一致性机制对不同操作系统的核之间的数据传输进行管理。其核心机制是对每个缓存单元(Cache行)用一个状态来表示:In this embodiment, a cache coherence mechanism is used to manage data transmission between cores of different operating systems. Its core mechanism is to represent each cache unit (Cache line) with a state:

M(Modify)位:M为1,表示当前Cache行中包含的数据与物理内存单元中的数据不一致,而且它仅在本CPU(核)的Cache行中有效,不在其他CPU的Cache行中存在拷贝,在这个Cache行的数据是当前操作系统中最新的数据拷贝。当CPU对这个Cache行进行替换操作时,必然会引发系统总线的写周期,将Cache行中数据与内存中的数据同步。M (Modify) bit: M is 1, indicating that the data contained in the current Cache line is inconsistent with the data in the physical memory unit, and it is only valid in the Cache line of this CPU (core), and does not exist in the Cache lines of other CPUs Copy, the data in this Cache row is the latest data copy in the current operating system. When the CPU replaces the Cache line, it will inevitably trigger a write cycle on the system bus to synchronize the data in the Cache line with the data in the memory.

E(Exclusive)位:E为1时表示当前Cache行中包含的数据有效,而且该数据仅在当前CPU的Cache行中有效,而不在其他CPU的Cache行中存在拷贝。在该Cache行中的数据是当前操作系统中最新的数据拷贝,而且与物理内存单元中的数据一致。E (Exclusive) bit: When E is 1, it means that the data contained in the current Cache line is valid, and the data is only valid in the Cache line of the current CPU, and there is no copy in the Cache lines of other CPUs. The data in the Cache row is the latest data copy in the current operating system, and is consistent with the data in the physical memory unit.

S(Shared)位:S为1表示Cache行中包含的数据有效,而且在当前CPU和至少在其他一个CPU中具有副本。当一个Cache行状态为S时,其包含的数据并不一定与物理内存单元一致。如果在其他CPU的Cache中不存在状态为O的副本时,该Cache行中的数据与内存一致;如果在其他CPU的Cache行中存在状态为O的副本时,Cache行中的数据与物理内存单元不一致。S (Shared) bit: S being 1 indicates that the data contained in the Cache line is valid, and there is a copy in the current CPU and at least one other CPU. When the state of a cache line is S, the data it contains is not necessarily consistent with the physical memory unit. If there is no copy with state O in the cache of other CPUs, the data in the cache line is consistent with the memory; if there is a copy with state O in the cache line of other CPUs, the data in the cache line is consistent with the physical memory Units are inconsistent.

I(Invalid)位:I为1表示当前Cache行中没有有效数据或者该Cache行没有使能。MESI协议在进行Cache行替换时,将优先使用I位为1的Cache行。I (Invalid) bit: I being 1 indicates that there is no valid data in the current Cache line or the Cache line is not enabled. When the MESI protocol performs Cache line replacement, it will preferentially use the Cache line whose I bit is 1.

O(Owned)位:O为1表示在当前Cache行中包含的数据是当前操作系统最新的数据拷贝,而且在其他CPU中一定具有该Cache行的副本,其他CPU的Cache行状态为S。如果物理内存单元的数据在多个CPU的Cache行中都具有 副本时,有且仅有一个CPU的Cache行状态为O,其他CPU的Cache行状态只能为S。与MESI协议中的S状态不同,状态为O的Cache行中的数据与物理内存单元中的数据并不一致。O (Owned) bit: O being 1 indicates that the data contained in the current Cache line is the latest data copy of the current operating system, and there must be a copy of the Cache line in other CPUs, and the Cache line status of other CPUs is S. If the data of the physical memory unit has copies in the Cache lines of multiple CPUs, there is only one CPU whose Cache line status is O, and the Cache line status of other CPUs can only be S. Different from the S state in the MESI protocol, the data in the Cache row whose state is O is not consistent with the data in the physical memory unit.

ARM处理器通过窥探控制单元(Snoop Control Unit,SCU)责监控和维护各个核之间的缓存一致性,同时还提供了对L2Cache的仲裁访问。通常情况下,SMP系统中各个核都存在一个寄存器用于控制缓存一致性单元的开关,以ARM的Cortex A53为例,若寄存器CPUECTLR.smp bit被置位,则开启SCU。本实施例利用SCU结合MOESI协议能够及时维护缓存单元中数据的一致性,保证各个核之间获取数据的准确性,而这些操作也无需软件参与,提高了软件的可维护性。The ARM processor is responsible for monitoring and maintaining the cache coherence between the cores through the snoop control unit (Snoop Control Unit, SCU), and also provides arbitration access to the L2Cache. Usually, each core in the SMP system has a register to control the switch of the cache coherency unit. Taking the Cortex A53 of ARM as an example, if the register CPUECTLR.smp bit is set, the SCU is turned on. In this embodiment, the SCU combined with the MOESI protocol can maintain the consistency of the data in the cache unit in time, and ensure the accuracy of the data obtained between each core, and these operations do not require software participation, which improves the maintainability of the software.

当系统中缓存单元被填满后,如需填冲新的缓存单元,那么就需要进行cache Evict操作,由硬件完成。When the cache unit in the system is filled, if a new cache unit needs to be filled, a cache Evict operation is required, which is completed by hardware.

IVI系统在写数据到缓存时,SCU即可监控到IVI系统中对应物理内存单元的Cache行状态有所变化,并且能够主动进行缓存一致性维护。When the IVI system writes data to the cache, the SCU can monitor changes in the status of the Cache line corresponding to the physical memory unit in the IVI system, and can actively maintain cache consistency.

可选地,可以通过如图3所示的方法实现步骤S21。本实施例的方法包括步骤S30至步骤S35。Optionally, step S21 may be implemented by the method shown in FIG. 3 . The method of this embodiment includes step S30 to step S35.

步骤S30:监测到第一数据写操作。Step S30: The first data writing operation is detected.

监测到第一数据写入第一操作系统的缓存单元的操作。An operation of writing the first data into the cache unit of the first operating system is monitored.

步骤S31:第一操作系统将第一数据写入第一操作系统的缓存单元。Step S31: the first operating system writes the first data into the cache unit of the first operating system.

第一操作系统将第一数据写入第一操作系统中对应Cache行。The first operating system writes the first data into a corresponding Cache line in the first operating system.

步骤S32:若第二操作系统的缓存单元为空,则第一操作系统的缓存单元将第一数据写入第二操作系统的缓存单元中。Step S32: If the cache unit of the second operating system is empty, the cache unit of the first operating system writes the first data into the cache unit of the second operating system.

第一操作系统所在核的缓存单元的数据自动同步至第二操作系统所在核的缓存单元中。The data of the cache unit of the core where the first operating system is located is automatically synchronized to the cache unit of the core where the second operating system is located.

若RTOS系统中对应Cache行中无数据,第一操作系统将对应Cache行中的第一数据直接写入到RTOS中对应Cache行中。If there is no data in the corresponding Cache line in the RTOS system, the first operating system directly writes the first data in the corresponding Cache line into the corresponding Cache line in the RTOS.

步骤S33:若第二操作系统的缓存单元存有第二数据,则将第二操作系统的缓存单元的状态标记为无效。Step S33: If the cache unit of the second operating system stores the second data, mark the status of the cache unit of the second operating system as invalid.

若RTOS系统中对应Cache行已经存有第二数据,则将RTOS系统中对应Cache行的状态修改为I(Invalid)。If the corresponding Cache line in the RTOS system has stored the second data, the state of the corresponding Cache line in the RTOS system is changed to I (Invalid).

步骤S34:确定第二操作系统是否存在第二数据的副本。Step S34: Determine whether there is a copy of the second data in the second operating system.

RTOS系统在开始接收数据时无需再进行缓存清空操作,而是可以直接发起读请求,此时RTOS系统中的其他核能够监听到该读请求,并且主动检查自身的是否缓存有第二数据的副本。The RTOS system does not need to clear the cache when it starts to receive data, but can directly initiate a read request. At this time, other cores in the RTOS system can monitor the read request and actively check whether its own cache has a copy of the second data. .

步骤S35:若第二操作系统存在第二数据的副本,则基于第一操作系统对第一数据的存储情况将第一数据更新到第二操作系统的缓存单元中。Step S35: If the second operating system has a copy of the second data, update the first data to the cache unit of the second operating system based on the storage of the first data by the first operating system.

如果RTOS系统中缓存有第二数据的副本,则将IVI系统同步来的第一数据写入RTOS系统中存有第二数据的Cache行中,也不会导致第二数据丢失。此时可以基于IVI系统对第一数据的存储情况将第一数据更新到RTOS系统中的Cache行中。If a copy of the second data is cached in the RTOS system, writing the first data synchronized from the IVI system into the Cache line storing the second data in the RTOS system will not cause loss of the second data. At this time, the first data may be updated to the Cache line in the RTOS system based on the storage of the first data by the IVI system.

可选地,本实施例可以通过如图4所示的方法实现步骤S35。本实施的方法包括步骤S41及步骤S42。Optionally, in this embodiment, step S35 may be implemented through the method shown in FIG. 4 . The method of this implementation includes step S41 and step S42.

步骤S41:若第一操作系统存有第一数据的副本,且第一数据的副本与对应的物理内存中的数据一致,则直接将第一数据的副本写入第二操作系统的缓存单元中。Step S41: If the first operating system has a copy of the first data, and the copy of the first data is consistent with the data in the corresponding physical memory, directly write the copy of the first data into the cache unit of the second operating system .

如果IVI系统中CPU发现本地副本,并且状态为S,则直接将该Cache行中的第一数据刷到RTOS系统中的Cache行中,此时RTOS系统对应的Cache行状态改为S;If the CPU in the IVI system finds a local copy, and the status is S, then directly flush the first data in the Cache row to the Cache row in the RTOS system, and the status of the corresponding Cache row in the RTOS system is changed to S;

如果IVI系统中CPU发现本地副本,并且状态为E,则直接将该Cache行中的第一数据刷到RTOS系统中的Cache行中,此时RTOS系统和IVI系统对应的Cache行状态均改为S。If the CPU in the IVI system finds a local copy and the status is E, it will directly flush the first data in the Cache line to the Cache line in the RTOS system. At this time, the statuses of the Cache lines corresponding to the RTOS system and the IVI system are both changed to S.

步骤S42:若第一操作系统存有第一数据的副本,且第一数据的副本与对应的物理内存中的数据不一致,则先将第一数据的副本写入对应的物理内存单元中,然后将对应的物理内存单元中的第一数据的副本写入第二操作系统的缓存单元中。Step S42: If the first operating system has a copy of the first data, and the copy of the first data is inconsistent with the data in the corresponding physical memory, first write the copy of the first data into the corresponding physical memory unit, and then Writing the copy of the first data in the corresponding physical memory unit into the cache unit of the second operating system.

如果IVI系统中CPU发现本地副本,并且状态为M,则先将该Cache行中的内容更新到物理内存单元中,这时IVI系统中Cache行状态从M变为了S,此时RTOS系统需要从物理内存单元中获取第一数据。If the CPU in the IVI system finds a local copy, and the state is M, it first updates the content in the Cache line to the physical memory unit. At this time, the state of the Cache line in the IVI system changes from M to S. At this time, the RTOS system needs to change from Acquire the first data from the physical memory unit.

步骤S22:监测到第一数据写操作完成,第一操作系统向第二操作系统发送共享通知。Step S22: Upon detecting that the first data writing operation is completed, the first operating system sends a sharing notification to the second operating system.

现有技术中,共享数据写入完成的标志是刷cache完成,而本实施例利用缓存一致性机制进行自行维护,因此共享数据写入完成的标志就是软件的写操作 (例如:memcpy、memset等)。In the prior art, the sign that the shared data writing is completed is the completion of flushing the cache, but in this embodiment, the cache consistency mechanism is used for self-maintenance, so the sign that the shared data writing is completed is the writing operation of the software (for example: memcpy, memset, etc. ).

当IVI系统的第一数据写完成后,即可通过核间中断(Software Generate Interrupt,SGI)方式向RTOS系统发送共享通知。After the first data writing of the IVI system is completed, a shared notification can be sent to the RTOS system through an inter-core interrupt (Software Generate Interrupt, SGI).

传统异构系统间需要额外的硬件以支持不同CPU间的中断控制,而对于同构系统下实现虚拟化的方案,其操作系统之间的通信在软件实现上更加复杂。本实施例基于核间通信机制,实现不同操作系统间的消息传递方式。以ARM为例,可以通过SGI的方式实现操作系统间的中断通知,无需外部对接硬件,同时通信方式更加便捷。Traditional heterogeneous systems require additional hardware to support interrupt control between different CPUs. For the solution of virtualization under homogeneous systems, the communication between operating systems is more complicated in software implementation. This embodiment implements a message transmission mode between different operating systems based on an inter-core communication mechanism. Taking ARM as an example, the interrupt notification between operating systems can be realized through SGI, without external docking hardware, and the communication method is more convenient.

步骤S23:第二操作系统接收到共享通知,从缓存单元中获取第一数据。Step S23: the second operating system receives the sharing notification, and acquires the first data from the cache unit.

RTOS系统接收到共享通知,从对应的缓存单元中获取第一数据。The RTOS system receives the sharing notification, and acquires the first data from the corresponding cache unit.

现有技术中,当IVI系统需要共享数据给RTOS系统时,IVI系统需要首先将数据写入共享物理内存单元中;当IVI系统的数据写完之后,由RTOS系统读取共享物理内存单元中的数据。对比业内常用的多系统通信方案而言,其操作流程大致如图5所示,其对应的数据流如图6所示。In the prior art, when the IVI system needs to share data to the RTOS system, the IVI system needs to first write the data in the shared physical memory unit; after the data of the IVI system is written, the RTOS system reads the data in the shared physical memory unit. data. Compared with the multi-system communication scheme commonly used in the industry, its operation process is roughly shown in Figure 5, and its corresponding data flow is shown in Figure 6.

现有技术中,为了消除IVI系统与RTOS系统之间的缓存的干扰,保证数据的准确性,发送数据方IVI系统通常都会有两种做法:关闭对应区域的缓存单元或者每次写数据完成后主动刷新缓存,对应的数据接收方RTOS系统如果没有关闭对应区域的缓存单元,那么在试图接收数据前也会先清空RTOS系统的缓存之后再从共享物理内存单元中获取数据。如果IVI系统不做刷Cache操作,那么会出现数据不一致的问题:IVI系统写完数据,但是部分数据仍然存在于Cache行中并且尚未写入到共享物理内存单元中,此时RTOS系统直接从共享物理内存单元获取到的数据是陈旧的;如果RTOS系统不做清空Cache的操作,也会出现数据不一致的问题:IVI系统写完数据,并完整的将数据刷到了共享物理内存单元中,此时RTOS系统直接读取数据,因为存在缓存,如果当前RTOS系统已经在此前在Cache行中备份了对应地址的数据(也就是CPU读操作),那么RTOS系统再次读取时就会直接从自身的Cache行中读出旧数据,而不会再重新从共享物理内存单元中获取新数据。关闭缓存的方式虽然避免了上述两种问题,但无疑影响了数据的整体传输效率,而主动刷新和清空缓存的方式也在一定程度上增加了软件的复杂度和时延。In the prior art, in order to eliminate the cache interference between the IVI system and the RTOS system and ensure the accuracy of the data, the IVI system of the data sending party usually has two methods: close the cache unit in the corresponding area or after each data write is completed Actively refresh the cache. If the RTOS system of the corresponding data receiver does not close the cache unit in the corresponding area, it will clear the cache of the RTOS system before trying to receive the data, and then obtain the data from the shared physical memory unit. If the IVI system does not refresh the cache, there will be data inconsistency: the IVI system writes the data, but some data still exists in the cache line and has not been written into the shared physical memory unit. The data obtained by the physical memory unit is stale; if the RTOS system does not perform the operation of clearing the Cache, data inconsistency will also occur: the IVI system writes the data and completely flushes the data to the shared physical memory unit. The RTOS system directly reads the data because there is a cache. If the current RTOS system has previously backed up the data of the corresponding address in the Cache line (that is, the CPU read operation), then the RTOS system will directly read from its own Cache when it reads again. The old data is read out from the row without re-acquiring new data from the shared physical memory unit. Although the way of closing the cache avoids the above two problems, it undoubtedly affects the overall data transmission efficiency, and the way of actively refreshing and clearing the cache also increases the complexity and delay of the software to a certain extent.

而本实施例中,当IVI系统需要同步数据至RTOS系统时,操作流程如图7所示,对应的数据流如图8所示。本实施例利用缓存一致性机制能够解决上述 问题,在进行数据同步操作时无需主动操作缓存单元,无论是写操作方的刷Cache操作还是读操作方的清空Cache操作都无需关心,同时因为有了缓存单元的存在也提高了数据传输的速率。In this embodiment, when the IVI system needs to synchronize data to the RTOS system, the operation flow is shown in FIG. 7 , and the corresponding data flow is shown in FIG. 8 . This embodiment uses the cache consistency mechanism to solve the above problems. When performing data synchronization operations, there is no need to actively operate the cache unit, and there is no need to care about whether it is the operation of flushing the Cache of the write operator or the operation of clearing the Cache of the read operator. The existence of the cache unit also increases the rate of data transfer.

本申请进一步提出另一实施例的基于同构多核的多操作系统的通信方法,用于上述基于同构多核的多操作系统。如图9所示,图9是本申请基于同构多核的多操作系统的通信方法一实施例的结构示意图。本实施例具体包括以下步骤:The present application further proposes a communication method for a multi-OS based on homogeneous multi-core in another embodiment, which is used in the multi-OS based on homogeneous multi-core. As shown in FIG. 9 , FIG. 9 is a schematic structural diagram of an embodiment of a communication method based on a homogeneous multi-core multi-operating system in the present application. This embodiment specifically includes the following steps:

步骤S91:为第一操作系统及第二操作系统配置共享物理内存单元。Step S91: Configuring a shared physical memory unit for the first operating system and the second operating system.

为第一操作系统配置第一独占物理内存单元,为第二系统配置第二独占物理内存单元,及为第一操作系统及第二操作系统配置共享物理内存单元。The first exclusive physical memory unit is configured for the first operating system, the second exclusive physical memory unit is configured for the second system, and the shared physical memory unit is configured for the first operating system and the second operating system.

其中,共享物理内存单元对缓存一致性的作用包括:作为RTOS系统的缓存单元与IVI系统的缓存单元的地址一致的中间桥梁:每个缓存单元的虚拟地址必须映射到真实的物理地址(方便在非缓存一致性,也就是非通信状态下,每个操作系统可以单独访问共享物理内存单元),因此分别映射到共享物理内存单元,且两个虚拟地址是一致的;在缓存一致性的条件下,共享物理内存提供了真实的物理地址作为两个操作系统的缓存单元的地址的中间映射。在缓存单元的数据写满后,在写入数据时,需要将缓存单元已有数据搬运到共享物理内存单元,此时共享物理内存单元相当于缓存单元的垃圾桶。Among them, the role of the shared physical memory unit on cache coherence includes: as an intermediate bridge between the addresses of the cache unit of the RTOS system and the cache unit of the IVI system: the virtual address of each cache unit must be mapped to a real physical address (convenient in Non-cache consistency, that is, in the non-communication state, each operating system can access the shared physical memory unit separately), so they are respectively mapped to the shared physical memory unit, and the two virtual addresses are consistent; under the condition of cache consistency , shared physical memory provides the real physical address as an intermediate mapping of the addresses of the cache units of the two operating systems. After the data in the cache unit is full, when writing data, the existing data in the cache unit needs to be moved to the shared physical memory unit. At this time, the shared physical memory unit is equivalent to the trash can of the cache unit.

步骤S92:通过MMU映射将第一操作系统的缓存单元的虚拟地址及第二操作系统的缓存单元的虚拟地址映射到共享物理内存单元。Step S92: Map the virtual address of the cache unit of the first operating system and the virtual address of the cache unit of the second operating system to the shared physical memory unit through MMU mapping.

通过MMU映射将第一操作系统的部分缓存单元的虚拟地址映射到第一独占物理内存单元及将第二操作系统的部分缓存单元的虚拟地址映射到第二独占物理内存单元,通过MMU映射将第一操作系统的另一部分缓存单元的虚拟地址及第二操作系统的另一部分缓存单元的虚拟地址映射到共享物理内存单元。Map the virtual address of part of the cache unit of the first operating system to the first exclusive physical memory unit and map the virtual address of the part of the cache unit of the second operating system to the second exclusive physical memory unit through MMU mapping, and map the second exclusive physical memory unit through MMU mapping. The virtual address of another part of the cache unit of one operating system and the virtual address of another part of the cache unit of the second operating system are mapped to the shared physical memory unit.

IVI系统与RTOS系统通过二者的共享物理内存单元实现缓存一致性。The IVI system and the RTOS system achieve cache coherence through the shared physical memory unit of the two.

因IVI系统与RTOS系统为同构系统,因此这两个操作系统可以访问完全相同的物理内存单元,即共享物理内存单元。因此,为了防止两个操作系统之间对内存数据的互相影响,需要额外配置MMU映射来进行内存隔离,即通过MMU映射的Stage2映射将IVI系统的部分缓存单元的虚拟地址映射到IVI系统的第一独占物理内存单元及将RTOS系统的部分缓存单元的虚拟地址映射到RTOS系统的第二独占物理内存单元多操作系统相同的物理地址,即映射到物理内存 单元;为减少IVI系统与RTOS系统间数据传递的时间,多操作系统间的数据同步需要一段共享物理内存单元,用于IVI系统与RTOS系统都可以访问的情况,通过MMU映射的Stage2映射将IVI系统的另一部分缓存单元的虚拟地址及RTOS系统的另一部分缓存单元的虚拟地址映射到共享物理内存单元。Because the IVI system and the RTOS system are isomorphic systems, the two operating systems can access exactly the same physical memory unit, that is, share the physical memory unit. Therefore, in order to prevent the mutual influence of memory data between the two operating systems, it is necessary to additionally configure MMU mapping for memory isolation, that is, to map the virtual addresses of some cache units of the IVI system to the first stage of the IVI system through the Stage2 mapping of the MMU mapping. An exclusive physical memory unit and the virtual address of the part cache unit of the RTOS system are mapped to the second exclusive physical memory unit of the RTOS system. The same physical address of multiple operating systems is mapped to the physical memory unit; for reducing the distance between the IVI system and the RTOS system The time of data transfer, data synchronization between multiple operating systems requires a shared physical memory unit, which is used in the case where both the IVI system and the RTOS system can be accessed. The Stage2 mapping of the MMU mapping will map the virtual address of another part of the cache unit of the IVI system and The virtual address of another part of the cache unit of the RTOS system is mapped to the shared physical memory unit.

即通过MMU映射将IVI系统的缓存单元11的虚拟地址及RTOS系统的缓存单元21的虚拟地址映射到多操作系统相同的物理地址,即映射到共享物理内存单元。That is, the virtual address of the cache unit 11 of the IVI system and the virtual address of the cache unit 21 of the RTOS system are mapped to the same physical address of multiple operating systems through MMU mapping, that is, to a shared physical memory unit.

其中,多操作系统的数据缓存方式包括:VIVT、VIPT或PIPT。Wherein, the data caching methods of multiple operating systems include: VIVT, VIPT or PIPT.

具体地,VIVT(Virtual Index Virtual Tag)为使用虚拟地址索引域和虚拟地址的标记域;VIPT(Virtual Index Physical Tag)为使用虚拟地址的索引域和物理地址的标记;PIPT(Physical Index Physical Tag)为使用物理地址的索引域和物理地址的标记域。Specifically, VIVT (Virtual Index Virtual Tag) is a tag field using a virtual address index field and a virtual address; VIPT (Virtual Index Physical Tag) is a tag using a virtual address index field and a physical address; PIPT (Physical Index Physical Tag) It is an index field using a physical address and a tag field of a physical address.

步骤S93:响应于数据缓存方式为VIVT,则分别为第一操作系统的虚拟地址空间及第二操作系统的虚拟地址空间设置不同的标记。Step S93: In response to the fact that the data caching mode is VIVT, different flags are set for the virtual address space of the first operating system and the virtual address space of the second operating system.

响应于数据缓存方式为VIVT,则为第一操作系统及第二操作系统对共享物理内存单元的MMU映射的Stage1映射配置相同的映射关系,且分别为第一操作系统的虚拟地址空间及第二操作系统的虚拟地址空间设置不同的标记。In response to the fact that the data cache mode is VIVT, the same mapping relationship is configured for the Stage1 mapping of the MMU mapping of the shared physical memory unit by the first operating system and the second operating system, and are respectively the virtual address space of the first operating system and the second operating system. The operating system's virtual address space sets different flags.

当数据缓存方式(即缓存单元与内存单元之间的关系)为VIPT和PIPT时,缓存中的位置与物理地址强相关,因此缓存一致性维护可以设计为基于物理地址的一致,对多操作系统的映射方式不需要额外要求,只需要共享数据时使用相同的物理地址即可,两个操作系统操作相同物理地址对应的虚拟地址时,缓存一致性由SCU自行维护。When the data caching mode (that is, the relationship between the cache unit and the memory unit) is VIPT and PIPT, the position in the cache is strongly related to the physical address, so the cache consistency maintenance can be designed to be consistent based on the physical address, for multiple operating systems The mapping method does not require additional requirements. It only needs to use the same physical address when sharing data. When two operating systems operate on the virtual address corresponding to the same physical address, the cache consistency is maintained by the SCU itself.

当数据缓存方式为VIVT时,第一操作系统及第二操作系统对于共享内存区域的Stage1映射需要配置为相同的映射关系,这样才能保证缓存的一致性。When the data cache mode is VIVT, the first operating system and the second operating system need to configure the same mapping relationship for the Stage1 mapping of the shared memory area, so as to ensure the consistency of the cache.

进一步地,当数据缓存方式为VIVT时,可能会导致缓存别名的问题,也就是多个相同的虚拟地址可能会被映射到同一个物理地址;例如进程间通信,这会导致指向同一个物理地址的虚拟地址的缓存被分开存储,所以可能产生一致性问题,比如更改了一个虚拟地址的缓存行后,与它指向相同物理地址的虚拟地址的缓存没有更改,导致数据不一致。针对此种情况,本实施例通过为每个虚拟地址空间加上标记(ASID)的方式来区分不同的虚拟地址空间。Furthermore, when the data cache mode is VIVT, it may cause the problem of cache aliases, that is, multiple identical virtual addresses may be mapped to the same physical address; for example, inter-process communication, which will lead to pointing to the same physical address The caches of the virtual addresses are stored separately, so there may be consistency problems. For example, after changing the cache line of a virtual address, the cache of the virtual address pointing to the same physical address is not changed, resulting in data inconsistency. In this case, in this embodiment, different virtual address spaces are distinguished by adding a tag (ASID) to each virtual address space.

步骤S94:第一操作系统通过缓存一致性机制将第一数据更新到第二操作系 统的缓存单元中。Step S94: The first operating system updates the first data into the cache unit of the second operating system through a cache coherence mechanism.

监测到第一数据的写操作,第一操作系统通过缓存一致性机制将第一数据更新到第二操作系统的缓存单元中。After detecting the write operation of the first data, the first operating system updates the first data to the cache unit of the second operating system through a cache consistency mechanism.

步骤S95:监测到第一数据写操作完成,第一操作系统向第二操作系统发送共享通知。Step S95: upon detecting that the first data writing operation is completed, the first operating system sends a sharing notification to the second operating system.

步骤S96:第二操作系统接收到共享通知,从缓存单元中获取数据。Step S96: The second operating system receives the sharing notification, and obtains data from the cache unit.

步骤S94至步骤S96与上述步骤S11至步骤S13类似,这里不赘述。Steps S94 to S96 are similar to the above steps S11 to S13 and will not be repeated here.

本申请进一步提出另一实施例的基于同构多核的多操作系统的通信方法,用于上述基于同构多核的多操作系统。如图10所示,图10是本申请基于同构多核的多操作系统的通信方法一实施例的结构示意图。本实施例具体包括以下步骤:The present application further proposes a communication method for a multi-OS based on homogeneous multi-core in another embodiment, which is used in the multi-OS based on homogeneous multi-core. As shown in FIG. 10 , FIG. 10 is a schematic structural diagram of an embodiment of a communication method based on a homogeneous multi-core multi-operating system in the present application. This embodiment specifically includes the following steps:

步骤S101:监测到第一数据写操作,第一操作系统通过缓存一致性机制将第一数据更新到第二操作系统的缓存单元中。Step S101: upon detecting the first data write operation, the first operating system updates the first data to the cache unit of the second operating system through a cache coherence mechanism.

步骤S102:监测到第一数据写操作完成,第一操作系统向第二操作系统发送共享通知。Step S102: upon detecting that the first data writing operation is completed, the first operating system sends a sharing notification to the second operating system.

步骤S103:第二操作系统接收到共享通知,从缓存单元中获取数据。Step S103: the second operating system receives the sharing notification, and obtains data from the cache unit.

步骤S101至步骤S103与上述步骤S11至步骤S13类似,这里不赘述。Steps S101 to S103 are similar to the above steps S11 to S13 and will not be repeated here.

步骤S104:监测到第一操作系统及第二操作系统共同访问同一共享物理内存单元,且监测到第一操作系统或者第二操作系统的自旋锁申请,在共享物理内存单元中创建变量,以存储同一共享物理内存单元的当前数据。Step S104: It is detected that the first operating system and the second operating system jointly access the same shared physical memory unit, and the spin lock application of the first operating system or the second operating system is detected, and a variable is created in the shared physical memory unit to Store current data in the same shared physical memory unit.

步骤S105:对多操作系统进行本地监视,并在同一共享物理内存单元独占结束后将当前数据写入同一共享物理内存单元。Step S105: Locally monitor multiple operating systems, and write current data into the same shared physical memory unit after the monopoly of the same shared physical memory unit ends.

本实施例在多操作系统中某个资源(共享物理内存单元)被多个操作系统的核共同访问时,例如读写操作时,多操作系统需要对这部分资源进行保护;本实施例在第一操作系统及第二操作系统内添加相同的自旋锁驱动,并要求第一操作系统及第二操作系统在申请共享资源的保护时通过自旋锁驱动来申请锁,申请到的自旋锁所占用共享物理内存单元的地址是相同的(在VIPT和PIPT的实现基础上)。为了实现内存的独占访问,ARM处理器有提供单独的硬件模块“独占监视器(Exclusive Monitor)”支持此功能,且本实施例只需要本地监视器即可实现更加便捷的自旋锁机制,同时省去了外部总线的监听优化了控制传递时间。In this embodiment, when a certain resource (shared physical memory unit) in multiple operating systems is jointly accessed by cores of multiple operating systems, such as during read and write operations, the multiple operating systems need to protect this part of the resource; this embodiment is described in The same spin lock driver is added to the first operating system and the second operating system, and the first operating system and the second operating system are required to apply for the lock through the spin lock driver when applying for the protection of shared resources. The applied spin lock The addresses of the occupied shared physical memory units are the same (based on the implementation of VIPT and PIPT). In order to achieve exclusive access to memory, the ARM processor provides a separate hardware module "Exclusive Monitor (Exclusive Monitor)" to support this function, and this embodiment only needs a local monitor to implement a more convenient spinlock mechanism, and at the same time Elimination of external bus snooping optimizes control transfer times.

在多线程的情况下要保持数据的同步,需要引入称作Load-Link(LL)和Store-Conditional(SC)的操作,并在共享物理内存单元中创建变量,LL操作将被访问的共享物理内存单元中的当前数据存在变量中,并且标记该共享物理内存单元为独占;SC操作,在被访问的共享物理内存单元中占用结束后,将变量中的当前数据写回该共享物理内存单元中,并取消独占标记。对于ARM平台来说,也在硬件层面上提供了对LL/SC的支持,以Cortex-A53为例,LL操作用的是LDREX指令,SC操作用的是STREX指令。To keep data synchronized in the case of multi-threading, it is necessary to introduce operations called Load-Link (LL) and Store-Conditional (SC), and create variables in the shared physical memory unit, and the shared physical memory to be accessed by the LL operation The current data in the memory unit is stored in the variable, and the shared physical memory unit is marked as exclusive; SC operation, after the occupied shared physical memory unit is completed, the current data in the variable is written back to the shared physical memory unit , and cancel the exclusive mark. For the ARM platform, it also provides support for LL/SC at the hardware level. Taking Cortex-A53 as an example, the LL operation uses the LDREX instruction, and the SC operation uses the STREX instruction.

进一步地,在其它实施例中,对内存访问的管控可以增加硬件firewall来进行监控,硬件firewall能够监控的最小单位需要到每个核。这样即使系统MMU配置出现问题,也能从硬件上隔离系统的内存冲突,以保证系统的独立。Furthermore, in other embodiments, a hardware firewall may be added for monitoring memory access control, and the minimum unit that the hardware firewall can monitor needs to be each core. In this way, even if there is a problem with the system MMU configuration, the memory conflict of the system can be isolated from the hardware to ensure the independence of the system.

进一步地,由于缓存存在换出机制,因此对于共享数据的部分可以增加汇编级别的流程优化,以降低数据换进换出带来的高时延。Furthermore, since there is a swapping-out mechanism in the cache, assembly-level process optimization can be added to the part of shared data to reduce the high latency caused by data swapping in and out.

进一步地,上述流程基于ARM系列CPU进行考量,对于其他架构的CPU而言可能会有不同的缓存一致性机制和硬件模块,需要针对性的去实现相关的软件。Furthermore, the above process is considered based on ARM series CPUs. For CPUs with other architectures, there may be different cache coherence mechanisms and hardware modules, and related software needs to be implemented in a targeted manner.

本申请进一步提出一种芯片,本实施例芯片运行多操作系统,多操作系统至少包括第一操作系统及第二操作系统,第一操作系统及第二操作系统位于同一处理器的不同内核,其中,处理器采用上述实施例基于同构多核的多操作系统的通信方法实现多通信系统通信。The present application further proposes a chip. The chip in this embodiment runs multiple operating systems. The multiple operating systems include at least a first operating system and a second operating system. The first operating system and the second operating system are located in different cores of the same processor. , the processor adopts the communication method based on the homogeneous multi-core multi-operating system in the above-mentioned embodiment to implement multi-communication system communication.

区别于现有技术,本申请的多操作系统至少包括第一操作系统及第二操作系统,第一操作系统及第二操作系统位于同一处理器不同的内核,第一操作系统先通过缓存一致性机制将第一数据更新到第二操作系统的缓存单元中,第一数据写操作完成后,通知第二操作系统直接从其缓存单元获取第一数据;因此,第一操作系统将第一数据同步到第二操作系统时,第一操作系统无需将其缓存单元中的第一数据存到物理内存中,第二操作系统也无需将其缓存单元中的数据清空,而是直接在接收到第一操作系统的共享通知后直接从其缓存单元读取第一数据即可,因此,能够提高操作系统间数据同步的效率。Different from the prior art, the multi-operating system of the present application includes at least a first operating system and a second operating system. The first operating system and the second operating system are located in different cores of the same processor. The first operating system first passes the cache coherency The mechanism updates the first data to the cache unit of the second operating system. After the first data write operation is completed, the second operating system is notified to obtain the first data directly from its cache unit; therefore, the first operating system synchronizes the first data When the second operating system arrives, the first operating system does not need to store the first data in its cache unit into the physical memory, and the second operating system does not need to clear the data in its cache unit, but directly receives the first After the sharing notification of the operating system, the first data can be directly read from its cache unit, therefore, the efficiency of data synchronization between operating systems can be improved.

进一步地,基于缓存一致性机制,使得不同操作系统的核之间数据的传输同步更加自如,无需软件进行过多的参与;增加了内存隔离技术,明确共享内存和非共享内存,降低了多操作系统间的互相影响;多个操作系统采用统一的自旋锁驱动,为多操作系统间访问临界资源提供更便捷的保护机制。Furthermore, based on the cache coherence mechanism, the synchronization of data transmission between cores of different operating systems is more free, without too much software participation; memory isolation technology is added to clarify shared memory and non-shared memory, reducing multi-operation Interaction between systems; multiple operating systems use a unified spin lock driver to provide a more convenient protection mechanism for accessing critical resources between multiple operating systems.

以上所述仅为本申请的实施方式,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。The above is only the implementation of the application, and does not limit the patent scope of the application. Any equivalent structure or equivalent process conversion made by using the specification and drawings of the application, or directly or indirectly used in other related technologies fields, are all included in the scope of patent protection of this application in the same way.

Claims (10)

一种基于同构多核的多操作系统的通信方法,其特征在于,所述多操作系统至少包括第一操作系统及第二操作系统,所述第一操作系统及所述第二操作系统位于同一处理器的不同内核,所述通信方法包括:A communication method based on a homogeneous multi-core multi-operating system, characterized in that the multi-operating system includes at least a first operating system and a second operating system, and the first operating system and the second operating system are located in the same different cores of the processor, the communication method comprising: 监测到第一数据写操作,所述第一操作系统通过缓存一致性机制将所述第一数据更新到所述第二操作系统的缓存单元中;When a first data write operation is detected, the first operating system updates the first data to the cache unit of the second operating system through a cache coherency mechanism; 监测到所述第一数据写操作完成,所述第一操作系统向所述第二操作系统发送共享通知;Upon detecting that the first data writing operation is completed, the first operating system sends a sharing notification to the second operating system; 所述第二操作系统接收到所述共享通知,从所述缓存单元中获取所述第一数据。The second operating system receives the sharing notification, and obtains the first data from the cache unit. 根据权利要求1所述的通信方法,其特征在于,所述第一操作系统通过缓存一致性机制将所述第一数据更新到所述第二操作系统的缓存单元中,包括:The communication method according to claim 1, wherein the first operating system updates the first data into the cache unit of the second operating system through a cache coherence mechanism, comprising: 所述第一操作系统将所述第一数据写入所述第一操作系统的缓存单元;The first operating system writes the first data into a cache unit of the first operating system; 若所述第二操作系统的缓存单元为空,则所述第一操作系统的缓存单元将所述第一数据写入所述第二操作系统的缓存单元中。If the cache unit of the second operating system is empty, the cache unit of the first operating system writes the first data into the cache unit of the second operating system. 根据权利要求1所述的通信方法,其特征在于,所述第一操作系统通过缓存一致性机制将所述第一数据更新到所述第二操作系统缓存单元中,进一步包括:The communication method according to claim 1, wherein the first operating system updates the first data into the cache unit of the second operating system through a cache coherency mechanism, further comprising: 若所述第二操作系统的缓存单元存有第二数据,则将所述第二操作系统的缓存单元的状态修改为无效;If the cache unit of the second operating system stores the second data, modify the state of the cache unit of the second operating system to be invalid; 确定所述第二操作系统是否存在所述第二数据的副本;determining whether a copy of the second data exists for the second operating system; 若所述第二操作系统存在所述第二数据的副本,则基于所述第一操作系统对所述第一数据的存储情况将所述数据更新到所述第二操作系统的缓存单元中。If the second operating system has a copy of the second data, updating the data into the cache unit of the second operating system based on the storage of the first data by the first operating system. 根据权利要求3所述的通信方法,其特征在于,所述基于所述第一操作系统对所述第一数据的存储情况将所述数据更新到所述第二操作系统的缓存单元中,包括:The communication method according to claim 3, wherein the updating of the data into the cache unit of the second operating system based on the storage of the first data by the first operating system includes : 若所述第一操作系统存有所述第一数据的副本,且所述第一数据的副本与对应的物理内存单元中的数据一致,则直接将所述第一数据的副本写入所述第二操作系统的缓存单元中。If the first operating system stores a copy of the first data, and the copy of the first data is consistent with the data in the corresponding physical memory unit, directly write the copy of the first data into the In the cache unit of the second operating system. 根据权利要求3所述的通信方法,其特征在于,所述基于所述第一操作系统对所述第一数据的存储情况将所述第一数据更新到所述第二操作系统的缓存单元中,进一步包括:The communication method according to claim 3, wherein the first data is updated to the cache unit of the second operating system based on the storage of the first data by the first operating system , further including: 若所述第一操作系统存有所述第一数据的副本,且所述第一数据的副本与对应的物理内存中的数据不一致,则先将所述第一数据的副本写入所述对应的物理内存单元中,然后将所述对应的物理内存单元中的所述第一数据的副本写入所述第二操作系统的缓存单元中。If the first operating system stores a copy of the first data, and the copy of the first data is inconsistent with the data in the corresponding physical memory, first write the copy of the first data into the corresponding and then write the copy of the first data in the corresponding physical memory unit into the cache unit of the second operating system. 根据权利要求1所述的通信方法,其特征在于,进一步包括:The communication method according to claim 1, further comprising: 为所述第一操作系统及所述第二操作系统配置共享物理内存单元;configuring a shared physical memory unit for the first operating system and the second operating system; 通过MMU映射将所述第一操作系统的缓存单元的虚拟地址及所述第二操作系统的缓存单元的虚拟地址映射到所述共享物理内存单元。The virtual address of the cache unit of the first operating system and the virtual address of the cache unit of the second operating system are mapped to the shared physical memory unit through MMU mapping. 根据权利要求6所述的通信方法,其特征在于,所述多操作系统的数据缓存方式包括:VIVT、VIPT或PIPT,所述通信方法进一步包括:The communication method according to claim 6, wherein the data caching method of the multi-operating system comprises: VIVT, VIPT or PIPT, and the communication method further comprises: 响应于所述数据缓存方式为所述VIVT,则分别为所述第一操作系统的虚拟地址空间及所述第二操作系统的虚拟地址空间设置不同的标记。In response to the data caching mode being the VIVT, different flags are respectively set for the virtual address space of the first operating system and the virtual address space of the second operating system. 根据权利要求1所述的通信方法,其特征在于,监测到所述数据写操作完成,所述第一操作系统向所述第二操作系统发送共享通知,包括:The communication method according to claim 1, wherein upon detecting that the data writing operation is completed, the first operating system sends a sharing notification to the second operating system, comprising: 监测到所述第一数据写操作完成,所述述第一操作系统使用核间中断方式向第二操作系统发送共享通知。After detecting that the first data writing operation is completed, the first operating system sends a sharing notification to the second operating system in an inter-core interrupt manner. 一种基于同构多核的多操作系统,其特征在于,至少包括:第一操作系统及第二操作系统,所述第一操作系统及所述第二操作系统位于同一处理器的不同内核,所述第一操作系统监测到第一数据写操作,通过缓存一致性机制将所述第一数据更新到所述第二操作系统的缓存单元中;所述第一操作系统监测到所述第一数据写操作完成,向所述第二操作系统发送共享通知;所述第二操作系统接收到所述共享通知,从所述缓存单元中获取所述第一数据。A multi-operating system based on isomorphic multi-core, characterized in that it includes at least: a first operating system and a second operating system, the first operating system and the second operating system are located in different cores of the same processor, so The first operating system detects the first data write operation, and updates the first data to the cache unit of the second operating system through a cache coherence mechanism; the first operating system detects that the first data After the write operation is completed, a sharing notification is sent to the second operating system; the second operating system receives the sharing notification, and acquires the first data from the cache unit. 一种芯片,其特征在于,运行基于同构多核的多操作系统,所述多操作系统至少包括第一操作系统及第二操作系统,所述第一操作系统及所述第二操作系统位于同一处理器的不同内核,其中,所述处理器采用权利要求1-8任一项所述的基于同构多核的多操作系统的通信方法实现所述多通信系统通信。A chip, characterized in that it runs a multi-operating system based on isomorphic multi-core, the multi-operating system includes at least a first operating system and a second operating system, and the first operating system and the second operating system are located in the same Different cores of the processor, wherein the processor implements the multi-communication system communication by using the communication method based on the multi-operating system based on homogeneous multi-core according to any one of claims 1-8.
PCT/CN2022/133538 2021-12-06 2022-11-22 Homogeneous multi-core-based multi-operating system, communication method, and chip WO2023103767A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111476557.9 2021-12-06
CN202111476557.9A CN114416387A (en) 2021-12-06 2021-12-06 Multi-operating system based on homogeneous multi-core, communication method and chip

Publications (1)

Publication Number Publication Date
WO2023103767A1 true WO2023103767A1 (en) 2023-06-15

Family

ID=81265791

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/133538 WO2023103767A1 (en) 2021-12-06 2022-11-22 Homogeneous multi-core-based multi-operating system, communication method, and chip

Country Status (2)

Country Link
CN (1) CN114416387A (en)
WO (1) WO2023103767A1 (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114416387A (en) * 2021-12-06 2022-04-29 合肥杰发科技有限公司 Multi-operating system based on homogeneous multi-core, communication method and chip
CN115933494B (en) * 2022-12-28 2023-11-07 睿尔曼智能科技(北京)有限公司 Embedded homogeneous multi-core control system for robots
CN115840650B (en) * 2023-02-20 2023-06-02 麒麟软件有限公司 Method for realizing three-terminal system communication based on kvisor isolated real-time domain
CN116243995B (en) * 2023-05-12 2023-08-04 苏州浪潮智能科技有限公司 Communication method, device, computer-readable storage medium, and electronic device

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060080398A1 (en) * 2004-10-08 2006-04-13 International Business Machines Corporation Direct access of cache lock set data without backing memory
CN101477511A (en) * 2008-12-31 2009-07-08 杭州华三通信技术有限公司 Method and apparatus for sharing memory medium between multiple operating systems
US20120110303A1 (en) * 2010-10-28 2012-05-03 International Business Machines Corporation Method for Process Synchronization of Embedded Applications in Multi-Core Systems
CN105740164A (en) * 2014-12-10 2016-07-06 阿里巴巴集团控股有限公司 Multi-core processor supporting cache consistency, reading and writing methods and apparatuses as well as device
CN110865968A (en) * 2019-04-17 2020-03-06 成都海光集成电路设计有限公司 Multi-core processing device and data transmission method between cores thereof
CN112416615A (en) * 2020-11-05 2021-02-26 珠海格力电器股份有限公司 Multi-core processor, method and device for realizing cache consistency of multi-core processor and storage medium
CN114416387A (en) * 2021-12-06 2022-04-29 合肥杰发科技有限公司 Multi-operating system based on homogeneous multi-core, communication method and chip

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101233109B1 (en) * 2010-09-13 2013-02-15 한국과학기술원 System and method of reducing traffic among multi-cores used to meet cache coherence
CN102929832B (en) * 2012-09-24 2015-05-13 杭州中天微系统有限公司 Cache-coherence multi-core processor data transmission system based on no-write allocation
CN104991868B (en) * 2015-06-09 2018-02-02 浪潮(北京)电子信息产业有限公司 A kind of multi-core processor system and caching consistency processing method

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060080398A1 (en) * 2004-10-08 2006-04-13 International Business Machines Corporation Direct access of cache lock set data without backing memory
CN101477511A (en) * 2008-12-31 2009-07-08 杭州华三通信技术有限公司 Method and apparatus for sharing memory medium between multiple operating systems
US20120110303A1 (en) * 2010-10-28 2012-05-03 International Business Machines Corporation Method for Process Synchronization of Embedded Applications in Multi-Core Systems
CN105740164A (en) * 2014-12-10 2016-07-06 阿里巴巴集团控股有限公司 Multi-core processor supporting cache consistency, reading and writing methods and apparatuses as well as device
CN110865968A (en) * 2019-04-17 2020-03-06 成都海光集成电路设计有限公司 Multi-core processing device and data transmission method between cores thereof
CN112416615A (en) * 2020-11-05 2021-02-26 珠海格力电器股份有限公司 Multi-core processor, method and device for realizing cache consistency of multi-core processor and storage medium
CN114416387A (en) * 2021-12-06 2022-04-29 合肥杰发科技有限公司 Multi-operating system based on homogeneous multi-core, communication method and chip

Also Published As

Publication number Publication date
CN114416387A (en) 2022-04-29

Similar Documents

Publication Publication Date Title
WO2023103767A1 (en) Homogeneous multi-core-based multi-operating system, communication method, and chip
US11822786B2 (en) Delayed snoop for improved multi-process false sharing parallel thread performance
US10031857B2 (en) Address translation services for direct accessing of local memory over a network fabric
JP5153172B2 (en) Method and system for maintaining low cost cache coherency for accelerators
US7657710B2 (en) Cache coherence protocol with write-only permission
CN107506312B (en) Techniques to share information between different cache coherency domains
JP4123621B2 (en) Main memory shared multiprocessor system and shared area setting method thereof
CN102929832B (en) Cache-coherence multi-core processor data transmission system based on no-write allocation
US20050005073A1 (en) Power control within a coherent multi-processing system
US20110004729A1 (en) Block Caching for Cache-Coherent Distributed Shared Memory
JP3264319B2 (en) Bus bridge
US20130103912A1 (en) Arrangement
JPH06243035A (en) Generalized shared memory in cluster architecture for computer system
US20140006716A1 (en) Data control using last accessor information
US8095617B2 (en) Caching data in a cluster computing system which avoids false-sharing conflicts
JP2002157164A (en) Data consistency memory management system and method and related multiprocessor network
US20140229678A1 (en) Method and apparatus for accelerated shared data migration
CN110737407A (en) data buffer memory realizing method supporting mixed writing strategy
US8627016B2 (en) Maintaining data coherence by using data domains
US20250103508A1 (en) Memory module with memory-ownership exchange
JP2016508650A (en) Implementing coherency with reflective memory
WO2023133830A1 (en) Shared storage system and apparatus, and method for invalidating cache data
JPH0822418A (en) Virtual address space managing device
CN117971716A (en) Cache management method, device, apparatus and storage medium
CN113094297A (en) Data buffer memory device supporting mixed write strategy

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: 22903190

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: 22903190

Country of ref document: EP

Kind code of ref document: A1

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载