Data sharing method and device
By setting the physical address of the shared virtual address in the processor to a volatile memory address and utilizing non-volatile memory management, the problem of high latency between processes is solved, and more efficient data sharing and lower latency is achieved.
Patent Information
- Application Number
- CN202410029039.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-05
- Publication Date
- 2025-07-08
AI Technical Summary
There is a high latency for sharing data between processes, mainly because the data takes a long time to copy between physical addresses.
The processor sets the physical address of the shared virtual address to the physical address of volatile memory, and allows other processes to directly access, avoid data copying, and combines the use of non-volatile memory to manage data sharing and reduce data copying operations.
It reduces the latency of sharing data between processes, improves the efficiency and concurrency of data sharing, and reduces the operational complexity and latency of processors.
Smart Images

Figure CN120281731A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of storage technology, and particularly to a data sharing method and apparatus. Background Art
[0002] In the field of storage technology, a process accesses the data stored at a physical address by accessing the virtual address corresponding to the physical address. Moreover, data can be shared between processes.
[0003] A process has a private virtual address which can only be accessed by the process itself and cannot be accessed by other processes. If the data stored at the physical address corresponding to the private virtual address of the first process wants to be shared with the second process, then the processor needs to copy the data stored at this physical address to the physical address corresponding to the shared virtual address. When the second process needs to access this data, it can access the shared virtual address. At this time, the processor can copy the data stored at the physical address corresponding to the shared virtual address to the physical address corresponding to the private virtual address of the second process. After that, the second process can access the data stored at the physical address corresponding to the private virtual address of the second process by accessing the private virtual address of the second process, thus realizing sharing the data of the first process with the second process.
[0004] However, copying data between physical addresses takes a long time, resulting in a high latency in sharing data between processes. Summary of the Invention
[0005] This application provides a data sharing method and apparatus, which can solve the problem of high latency in sharing data between processes. The solution provided by this application is as follows:
[0006] In a first aspect, this application provides a data sharing method, which is executed by a processor. The processor is connected to a volatile memory and a non-volatile memory, and the non-volatile memory can be accessed by the instructions of the processor. In this method, after the processor writes the first data of the first process into the first physical address of the volatile memory, it will set the physical address corresponding to the shared virtual address to the first physical address. Wherein, the first physical address is the physical address corresponding to the first private virtual address, the first private virtual address is allowed to be accessed by the first process and prohibited from being accessed by processes other than the first process; the shared virtual address is allowed to be accessed by any process.
[0007] In this way, it is convenient for other processes (such as the second process) except the first process to access the data at the first physical address by accessing the shared virtual address, thereby realizing the sharing of data from the first process to other processes. It can be seen that the processor can achieve data sharing between processes by setting the physical address corresponding to the virtual address, reducing the copy of shared data between processes. Therefore, the latency of shared data between processes can be reduced.
[0008] Optionally, the processor can also move the first data out of the first physical address; and when the first data exists in the second physical address of the non-volatile memory, lock the shared virtual address to prevent the shared virtual address from being accessed by the process, and change the physical address corresponding to the shared virtual address from the first physical address to the second physical address, and then unlock the shared virtual address to allow the shared virtual address to be accessed by the process. For example, the processor can move the first data out of the first physical address according to the satisfaction of the removal condition. The processor can judge whether the removal condition is satisfied. When the removal condition is satisfied, it will execute the operation of moving the first data out of the first physical address. When the removal condition is not satisfied, continue to judge whether the removal condition is satisfied.
[0009] There are various ways to implement the removal condition.
[0010] For example, the removal condition includes: the capacity of the free storage space in the volatile memory is less than the capacity threshold. The free storage space in the volatile memory refers to the storage space in the volatile memory that does not store data. When the capacity of the free storage space in the volatile memory is less than the capacity threshold, it is difficult for the volatile memory to support the storage of subsequent data. Therefore, the processor can move the data in the volatile memory out. After the data is moved out of the volatile memory, the storage space occupied by the data in the volatile memory is released, and this storage space becomes free storage space. In this way, the capacity of the free storage space in the volatile memory can be increased to support the storage of subsequent data.
[0011] For another example, the removal condition includes that within a target time period before the current moment, the number of processes accessing the shared virtual address is less than a quantity threshold. It can be seen that the processor can count the number of processes accessing the shared virtual address within the target time period before the current moment. When this number is less than the quantity threshold, it indicates that there are fewer processes accessing the shared virtual address, and the probability that the shared virtual address has been recently accessed is relatively high. At this time, the first data on the first physical address corresponding to the shared virtual address can be removed. In this way, the capacity of the free storage space in the volatile memory can be increased, facilitating subsequent data storage. Additionally, if within the target time period before the current moment, the number of processes accessing the shared virtual address is greater than or equal to the quantity threshold, it indicates that there are more processes accessing the shared virtual address recently, and the probability that the shared virtual address has been recently accessed is relatively low. It is not suitable to remove the data on the physical address corresponding to the shared virtual address currently to ensure the normal access of the process to the shared virtual address.
[0012] For yet another example, the removal condition includes that the capacity of the free storage space in the volatile memory is less than a capacity threshold, and within a target time period before the current moment, the number of processes accessing the shared virtual address is less than a quantity threshold.
[0013] It can be understood that generally, the physical address corresponding to a virtual address is managed by the virtual memory subsystem. In this application, however, the processor can also set the physical address corresponding to the virtual address. It can be seen that the virtual memory subsystem is exposed to the processor, and the processor can obtain the number of processes accessing the shared virtual address through the virtual memory subsystem. Therefore, this application supports the removal condition that within a target time period before the current moment, the number of processes accessing the shared virtual address is less than a quantity threshold.
[0014] Optionally, the processor can also set the physical address corresponding to the second private virtual address to the physical address corresponding to the shared virtual address according to the access request of the second process to the shared virtual address; the second private virtual address is allowed to be accessed by the second process and prohibited from being accessed by processes other than the second process. According to the above content, the physical address corresponding to the second private virtual address is the same as the physical address corresponding to the shared virtual address, and the processor does not copy the data in the physical address corresponding to the shared virtual address to the physical address corresponding to the second private virtual address. Therefore, data copying is avoided, and the delay in sharing data between processes caused by data copying is avoided.
[0015] In this application, when the physical address corresponding to the shared virtual address is not the first physical address of the volatile memory, if the physical address corresponding to the shared virtual address is the second physical address of the non-volatile memory, then the processor can set the physical address corresponding to the second private virtual address of the second process without copying data, so that the second process can access data, and the waiting time of the second process is short, reducing the latency of data sharing.
[0016] In addition, in this application, after the processor moves the data in the volatile memory out, if it changes the physical address corresponding to the shared virtual address to the physical address of the non-volatile memory, then it can avoid those complex processes in the related art. Therefore, the operations performed by the processor are fewer, which will further reduce the latency of sharing data between processes.
[0017] Further, after the processor sets the physical address corresponding to the second private virtual address to the physical address corresponding to the shared virtual address according to the access request of the second process for the shared virtual address, when the physical address corresponding to the shared virtual address is the second physical address, the processor can copy the first data in the second physical address to the third physical address of the volatile memory; lock both the shared virtual address and the second private virtual address to prevent the shared virtual address and the second private virtual address from being accessed by the process; then change the physical address corresponding to the shared virtual address and the physical address corresponding to the second private virtual address from the second physical address to the third physical address; and finally unlock both the shared virtual address and the second private virtual address to allow the shared virtual address and the second private virtual address to be accessed by the process.
[0018] When the physical address corresponding to the shared virtual address is the physical address of the non-volatile memory (such as the above-mentioned second physical address), considering that the access to the non-volatile memory is relatively slow, the processor can copy the first data in the second physical address to the third physical address of the volatile memory, and then change the physical address corresponding to the shared virtual address and the physical address corresponding to the second private virtual address from the second physical address to the third physical address. In this way, the second process can access the first data on the third physical address by accessing the second private virtual address. And since the third physical address is the physical address of the volatile memory, the second process can access the first data on the third physical address faster, which can further reduce the latency of sharing data between processes.
[0019] Optionally, when the processor sets the physical address corresponding to the second private virtual address to the physical address corresponding to the shared virtual address, it may copy the first data in the second physical address to the third physical address. Of course, copying the first data in the second physical address to the third physical address may also be performed after setting the physical address corresponding to the second private virtual address to the physical address corresponding to the shared virtual address. This application does not limit this.
[0020] The process of the first process sharing data with the second process is introduced above. Optionally, any process (such as the first process, the second process, or other processes) may also modify the data shared by the first process.
[0021] Exemplarily, the processor may lock the shared virtual address according to a data modification request for the shared virtual address to prevent the shared virtual address from being accessed by a process; the data modification request is used to request to modify the data on the physical address corresponding to the shared virtual address to the second data on the fourth physical address of the volatile memory; thereafter, the processor may change the physical address corresponding to the shared virtual address to the fourth physical address, and unlock the shared virtual address to allow the shared virtual address to be accessed by a process. If a process (such as the second process) accesses the shared virtual address subsequently, then the process will ultimately access the modified second data instead of the original first data.
[0022] According to the above content, the processor only needs to change the physical address corresponding to the shared virtual address to complete the data modification. Since the time required to change the physical address corresponding to the shared virtual address is short, the time for locking the shared virtual address is short, and the impact on the process accessing the shared virtual address is small.
[0023] Optionally, the processor in this application can also perform a dirty flush operation. For example, the processor may perform a dirty flush operation when the dirty flush condition is met. The dirty flush condition may be that the period for performing the dirty flush operation arrives, or the capacity of the free storage space in the volatile memory is less than a threshold, etc. The dirty flush operation may include: the processor first locks the shared virtual address to prevent the shared virtual address from being accessed by a process; thereafter, the processor sets the physical address corresponding to the dirty flush virtual address to the physical address corresponding to the shared virtual address, and then unlocks the shared virtual address to allow the shared virtual address to be accessed by a process; finally, the processor copies the data on the physical address corresponding to the dirty flush virtual address to the fifth physical address of the non-volatile memory.
[0024] According to the above dirty flushing operation, the way the processor performs dirty flushing is to first lock the shared virtual address, and then map the dirty flushing virtual address to the physical address corresponding to the shared virtual address (that is, set the physical address corresponding to the dirty flushing virtual address to the physical address corresponding to the shared virtual address). Subsequently, the shared virtual address is unlocked, and based on the dirty flushing virtual address, the data on the physical address corresponding to the shared virtual address is copied to the non-volatile memory. Since in the dirty flushing operation, the locking duration of the shared virtual address is the duration of mapping the dirty flushing virtual address to the physical address corresponding to the shared virtual address, and the duration of mapping the dirty flushing virtual address to the physical address corresponding to the shared virtual address is short, therefore, the locking time of the shared virtual address is short. Thus, the dirty flushing operation has a small impact on the process's access to the shared virtual address.
[0025] In addition, during the dirty flushing operation, if a process needs to modify the data on the physical address corresponding to the shared virtual address, then the processor will change the physical address corresponding to the shared virtual address to the physical address where the new data is located. However, at this time, the physical address corresponding to the dirty flushing virtual address is still the old physical address. Therefore, the processor still copies the data on the old physical address to the non-volatile memory.
[0026] Furthermore, when the processor copies the data on the physical address corresponding to the dirty flushing virtual address to the fifth physical address in the non-volatile memory, it can directly copy the data to the fifth physical address. Or, the processor can also first copy the data on the physical address corresponding to the dirty flushing virtual address to the log in the non-volatile memory; after successfully copying the data on the physical address corresponding to the dirty flushing virtual address to the log, the processor then copies the data on the log to the fifth physical address. In this way, it is ensured that the data copied by the processor to the fifth physical address is exactly the same as the data on the physical address corresponding to the dirty flushing virtual address, or the processor does not copy any data to the fifth physical address, ensuring the atomicity of the data on the non-volatile memory.
[0027] In a second aspect, the present application provides a data sharing method, which is executed by a processor. The processor is connected to a volatile memory and a non-volatile memory, and the non-volatile memory can be accessed by the instructions of the processor; in this method, the processor will set the physical address corresponding to the second private virtual address to the physical address corresponding to the shared virtual address according to the access request of the second process to the shared virtual address; the second private virtual address is allowed to be accessed by the second process and prohibited from being accessed by processes other than the second process, and the shared virtual address is allowed to be accessed by any process.
[0028] According to the above content, the physical address corresponding to the second private virtual address is the same as the physical address corresponding to the shared virtual address. The processor does not copy the data in the physical address corresponding to the shared virtual address to the physical address corresponding to the second private virtual address. Therefore, data copying is avoided, and the delay in sharing data between processes caused by data copying is avoided.
[0029] Optionally, before the processor sets the physical address corresponding to the second private virtual address to the physical address corresponding to the shared virtual address according to the access request of the second process to the shared virtual address, the method further includes: writing the first data of the first process to the first physical address of the volatile memory, and setting the physical address corresponding to the shared virtual address to the first physical address. The first physical address is the physical address corresponding to the first private virtual address, and the first private virtual address is allowed to be accessed by the first process and prohibited from being accessed by processes other than the first process; the shared virtual address is allowed to be accessed by any process.
[0030] Optionally, the method further includes: the processor moves the first data out of the first physical address; when the first data exists in the second physical address of the non-volatile memory, locks the shared virtual address to prevent the shared virtual address from being accessed by a process; changes the physical address corresponding to the shared virtual address from the first physical address to the second physical address; and unlocks the shared virtual address to allow the shared virtual address to be accessed by a process.
[0031] Optionally, the processor can move the first data in the first physical address out according to the satisfaction of the moving-out condition; the moving-out condition includes at least one of the following conditions: the capacity of the free storage space of the volatile memory is less than the capacity threshold; and the number of processes accessing the shared virtual address within a target time period before the current moment is less than the number threshold.
[0032] Optionally, after the processor sets the physical address corresponding to the second private virtual address to the physical address corresponding to the shared virtual address according to the access request of the second process to the shared virtual address, when the physical address corresponding to the shared virtual address is the second physical address, the processor can also copy the first data in the second physical address to the third physical address of the volatile memory; lock both the shared virtual address and the second private virtual address to prevent the shared virtual address and the second private virtual address from being accessed by a process; change both the physical address corresponding to the shared virtual address and the physical address corresponding to the second private virtual address from the second physical address to the third physical address; and unlock both the shared virtual address and the second private virtual address to allow the shared virtual address and the second private virtual address to be accessed by a process.
[0033] Optionally, when the processor sets the physical address corresponding to the second private virtual address to the physical address corresponding to the shared virtual address, the processor may copy the first data in the second physical address to the third physical address.
[0034] Optionally, the method further includes: the processor locks the shared virtual address according to a data modification request for the shared virtual address to prevent the shared virtual address from being accessed by a process; the data modification request is used to request to modify the data on the physical address corresponding to the shared virtual address to the second data on the fourth physical address of the volatile memory; then, the processor changes the physical address corresponding to the shared virtual address to the fourth physical address, and unlocks the shared virtual address to allow the shared virtual address to be accessed by a process.
[0035] Optionally, the method further includes: the processor locks the shared virtual address to prevent the shared virtual address from being accessed by a process; the processor then sets the physical address corresponding to the dirty virtual address to the physical address corresponding to the shared virtual address, and unlocks the shared virtual address to allow the shared virtual address to be accessed by a process; finally, the processor copies the data on the physical address corresponding to the dirty virtual address to the fifth physical address of the non-volatile memory.
[0036] Optionally, when the processor copies the data on the physical address corresponding to the dirty virtual address to the fifth physical address of the non-volatile memory, the processor may copy the data on the physical address corresponding to the dirty virtual address to a log in the non-volatile memory; after successfully copying the data on the physical address corresponding to the dirty virtual address to the log, the processor copies the data on the log to the fifth physical address.
[0037] In a third aspect, a data sharing device is provided. The data sharing device belongs to a processor. The processor is connected to a volatile memory and a non-volatile memory, and the non-volatile memory can be accessed by an instruction of the processor. The data sharing device includes: a writing module and a first setting module. The writing module is configured to write the first data of the first process into the first physical address of the volatile memory; the first physical address is the physical address corresponding to the first private virtual address, and the first private virtual address is allowed to be accessed by the first process and prohibited from being accessed by processes other than the first process; the first setting module is configured to set the physical address corresponding to the shared virtual address to the first physical address, and the shared virtual address is allowed to be accessed by any process.
[0038] Optionally, the data sharing device further includes: a removal module, a third locking module, a first modification module, and a third unlocking module. The removal module is configured to remove the first data from the first physical address; the third locking module is configured to lock the shared virtual address to prevent the shared virtual address from being accessed by a process when the first data exists in a second physical address of the non-volatile memory; the first modification module is configured to change the physical address corresponding to the shared virtual address from the first physical address to the second physical address; the third unlocking module is configured to unlock the shared virtual address to allow the shared virtual address to be accessed by a process.
[0039] Optionally, the removal module is configured to remove the first data from the first physical address when a removal condition is satisfied; the removal condition includes at least one of the following conditions: the capacity of the free storage space in the volatile memory is less than a capacity threshold; and the number of processes accessing the shared virtual address within a target time period before the current moment is less than a number threshold.
[0040] Optionally, the data sharing device further includes: a second setting module. The second setting module is configured to set the physical address corresponding to a second private virtual address as the physical address corresponding to the shared virtual address according to an access request of a second process for the shared virtual address; the second private virtual address is allowed to be accessed by the second process and prohibited from being accessed by processes other than the second process.
[0041] Optionally, the data sharing device further includes: a second setting module, a first copying module, a fourth locking module, a second modification module, and a fourth unlocking module. The second setting module is configured to set the physical address corresponding to a second private virtual address as the physical address corresponding to the shared virtual address according to an access request of a second process for the shared virtual address; the second private virtual address is allowed to be accessed by the second process and prohibited from being accessed by processes other than the second process; the first copying module is configured to copy the first data in the second physical address to a third physical address in the volatile memory when the physical address corresponding to the shared virtual address is the second physical address; the fourth locking module is configured to lock both the shared virtual address and the second private virtual address to prevent the shared virtual address and the second private virtual address from being accessed by a process; the second modification module is configured to change both the physical address corresponding to the shared virtual address and the physical address corresponding to the second private virtual address from the second physical address to the third physical address; the fourth unlocking module is configured to unlock both the shared virtual address and the second private virtual address to allow the shared virtual address and the second private virtual address to be accessed by a process.
[0042] Optionally, the first copy module is configured to: when setting the physical address corresponding to the second private virtual address to the physical address corresponding to the shared virtual address, copy the first data in the second physical address to the third physical address.
[0043] Optionally, the data sharing device further includes: a first locking module, a third changing module, and a first unlocking module. The first locking module is configured to lock the shared virtual address according to a data modification request for the shared virtual address, so as to prevent the shared virtual address from being accessed by a process; the data modification request is used to request to modify the data on the physical address corresponding to the shared virtual address to the second data on the fourth physical address of the volatile memory; the third changing module is configured to change the physical address corresponding to the shared virtual address to the fourth physical address; the first unlocking module is configured to unlock the shared virtual address, so as to allow the shared virtual address to be accessed by a process.
[0044] Optionally, the data sharing device further includes: a second locking module, a third setting module, a second unlocking module, and a second copy module. The second locking module is configured to lock the shared virtual address, so as to prevent the shared virtual address from being accessed by a process; the third setting module is configured to set the physical address corresponding to the dirty virtual address to the physical address corresponding to the shared virtual address; the second unlocking module is configured to unlock the shared virtual address, so as to allow the shared virtual address to be accessed by a process; the second copy module is configured to copy the data on the physical address corresponding to the dirty virtual address to the fifth physical address of the non-volatile memory.
[0045] Optionally, the second copy module is configured to: copy the data on the physical address corresponding to the dirty virtual address to the log in the non-volatile memory; after successfully copying the data on the physical address corresponding to the dirty virtual address to the log, copy the data on the log to the fifth physical address.
[0046] In a fourth aspect, the present application provides a data sharing device, which also belongs to a processor. The processor is connected to a volatile memory and a non-volatile memory, and the non-volatile memory can be accessed by an instruction of the processor; the data sharing device includes: a second setting module. The second setting module is configured to set the physical address corresponding to the second private virtual address to the physical address corresponding to the shared virtual address according to an access request of a second process for the shared virtual address; the second private virtual address is allowed to be accessed by the second process and prohibited from being accessed by processes other than the second process, and the shared virtual address is allowed to be accessed by any process.
[0047] Optionally, the data sharing device further includes: a writing module and a first setting module. The writing module is configured to write first data of a first process into a first physical address of a volatile memory; the first physical address is a physical address corresponding to a first private virtual address, the first private virtual address is allowed to be accessed by the first process and prohibited from being accessed by processes other than the first process; the first setting module is configured to set the physical address corresponding to a shared virtual address to the first physical address, and the shared virtual address is allowed to be accessed by any process.
[0048] Optionally, the data sharing device further includes: a removing module, a third locking module, a third unlocking module, and a first changing module. The removing module is configured to remove the first data from the first physical address; the third locking module is configured to lock the shared virtual address to prevent the shared virtual address from being accessed by a process when the first data exists in a second physical address of a non-volatile memory; the first changing module is configured to change the physical address corresponding to the shared virtual address from the first physical address to the second physical address; the third unlocking module is configured to unlock the shared virtual address to allow the shared virtual address to be accessed by a process.
[0049] Optionally, the removing module is configured to remove the first data from the first physical address when a removal condition is satisfied; the removal condition includes at least one of the following conditions: the capacity of free storage space in the volatile memory is less than a capacity threshold; and the number of processes accessing the shared virtual address within a target time period before the current moment is less than a number threshold.
[0050] Optionally, the data sharing device further includes: a first copying module, a fourth locking module, a fourth unlocking module, and a second changing module. The first copying module is configured to copy the first data in the second physical address to a third physical address of the volatile memory when the physical address corresponding to the shared virtual address is the second physical address; the fourth locking module is configured to lock both the shared virtual address and a second private virtual address to prevent the shared virtual address and the second private virtual address from being accessed by a process; the second changing module is configured to change both the physical address corresponding to the shared virtual address and the physical address corresponding to the second private virtual address from the second physical address to the third physical address; the fourth unlocking module is configured to unlock both the shared virtual address and the second private virtual address to allow the shared virtual address and the second private virtual address to be accessed by a process.
[0051] Optionally, the first copying module is configured to: copy the first data in the second physical address to the third physical address when setting the physical address corresponding to the second private virtual address to the physical address corresponding to the shared virtual address.
[0052] Optionally, the data sharing device further includes: a first locking module, a third changing module, and a first unlocking module. Among them, the first locking module is used to lock the shared virtual address according to a data modification request for the shared virtual address, so as to prevent the shared virtual address from being accessed by a process; the data modification request is used to request to modify the data on the physical address corresponding to the shared virtual address to the second data on the fourth physical address of the volatile memory; the third changing module is used to change the physical address corresponding to the shared virtual address to the fourth physical address; the first unlocking module is used to unlock the shared virtual address to allow the shared virtual address to be accessed by a process.
[0053] Optionally, the data sharing device further includes: a second locking module, a third setting module, a second unlocking module, and a second copying module. Among them, the second locking module is used to lock the shared virtual address to prevent the shared virtual address from being accessed by a process; the third setting module is used to set the physical address corresponding to the dirty virtual address to the physical address corresponding to the shared virtual address; the second unlocking module is used to unlock the shared virtual address to allow the shared virtual address to be accessed by a process; the second copying module is used to copy the data on the physical address corresponding to the dirty virtual address to the fifth physical address of the non-volatile memory.
[0054] Optionally, the second copying module is used to: copy the data on the physical address corresponding to the dirty virtual address to the log in the non-volatile memory; after successfully copying the data on the physical address corresponding to the dirty virtual address to the log, copy the data on the log to the fifth physical address.
[0055] In a fifth aspect, the present application provides a computer, including: a processor, a volatile memory, and a non-volatile memory, and the physical address of the non-volatile memory can be accessed by the instructions of the processor; the processor is used to execute the data sharing method according to any one of the designs in the first aspect or the second aspect.
[0056] In a sixth aspect, the present application provides a chip, which includes programmable logic circuits and / or program instructions, and is used to implement the data sharing method according to any one of the designs in the first aspect or the second aspect when the chip runs.
[0057] In a seventh aspect, the present application provides a computer storage medium, in which a computer program is stored, and when the computer program runs on a computer, it causes the computer to execute the data sharing method according to any one of the designs in the first aspect or the second aspect.
[0058] In an eighth aspect, the present application further provides a computer program product including instructions, which, when running on a computer, causes the computer to execute the data sharing method described in any one of the first aspect or the second aspect.
[0059] For the effects of the second aspect to the eighth aspect above, reference may be made to the effects of the corresponding designs in the first aspect above, and the present application will not elaborate herein. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 FIG. is a schematic structural diagram of a computer provided by an embodiment of the present application;
[0061] Figure 2 FIG. is a schematic diagram of a data copy process provided by an embodiment of the present application;
[0062] Figure 3 FIG. is a flowchart of a data sharing method provided by an embodiment of the present application;
[0063] Figure 4 FIG. is a schematic diagram of an example of a data sharing method provided by an embodiment of the present application;
[0064] Figure 5 FIG. is a schematic diagram of an example of another data sharing method provided by an embodiment of the present application;
[0065] Figure 6 FIG. is a schematic diagram of an example of another data sharing method provided by an embodiment of the present application;
[0066] Figure 7 FIG. is a schematic diagram of an example of another data sharing method provided by an embodiment of the present application;
[0067] Figure 8 FIG. is a schematic diagram of an example of another data sharing method provided by an embodiment of the present application;
[0068] Figure 9 FIG. is a schematic diagram of a data sharing device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0069] An embodiment of the present application provides a computer, as Figure 1 shown. The computer includes a processor 01 and a memory. And, with the development of storage technology, the memory gradually adopts a heterogeneous architecture. In the heterogeneous architecture, the memory is divided into a volatile memory 02 and a non-volatile memory 03, and the processor 01 is connected to both the volatile memory 02 and the non-volatile memory 03.
[0070] Volatile memory can be read from and written to at any time. Volatile memory is typically used as a temporary storage medium (which can be called a cache) for the operating system or other running processes. However, when the power is turned off, volatile memory cannot retain the stored data. If the data needs to be saved, it must be written from volatile memory to non-volatile memory. Non-volatile memory can retain data when the power is turned off or when the computer is suddenly and unexpectedly shut down.
[0071] Volatile memory can be dynamic random access memory (DRAM), compute express link memory (CXL Memory), etc. Non-volatile memory can be persistent memory (PM), three dee cross point (3DXPoint), compute express link-based solid-state drive (CXL-based SSD), etc.
[0072] Volatile memory typically features fast access, data volatility, and small capacity. Non-volatile memory typically features slow access, data non-volatility, and large capacity. Taking DRAM as volatile memory and PM as non-volatile memory as an example. The access speed of DRAM is relatively fast, and the latency for accessing DRAM is about 80 nanoseconds to 140 nanoseconds; while the access speed of PM is slower, and the latency for accessing PM is about 170 nanoseconds to 400 nanoseconds (or 3000 nanoseconds); moreover, the bandwidth and concurrency of PM are also significantly lower than those of DRAM.
[0073] In addition, in the embodiments of this application, the instructions of the processor can access not only volatile memory but also non-volatile memory. This heterogeneous architecture can be called a full memory architecture. The instructions of the processor can be load instructions or store instructions. The connection method between the non-volatile memory and the processor can be the compute express link (CXL) method, etc.
[0074] Furthermore, the processes running in the processor can access the data stored at the physical address by accessing the virtual address corresponding to the physical address. And, data can also be shared between processes.
[0075] Exemplarily, a process has private virtual addresses that can only be accessed by the process itself and are prohibited from being accessed by other processes. Taking the first process and the second process as an example, the private virtual addresses of the first process can only be accessed by the first process and are prohibited from being accessed by the second process; the private virtual addresses of the second process can only be accessed by the second process and are prohibited from being accessed by the first process. Therefore, if data needs to be shared between the first process and the second process, a shared virtual address that can be accessed by any process is required.
[0076] The data generated during the operation of the first process is stored at the physical address corresponding to the private virtual address of the first process. If the first process needs to share this data with the second process, then the processor needs to copy this data to the physical address corresponding to the shared virtual address (different from the physical address corresponding to the private virtual address of the first process). When the second process accesses this data, it can access the shared virtual address. At this time, the processor can copy the data at the physical address corresponding to the shared virtual address to the physical address corresponding to the private virtual address of the second process. Then, the second process can access the private virtual address of the second process to access the data stored at the physical address corresponding to this private virtual address, thereby realizing sharing the data of the first process with the second process.
[0077] As Figure 2 shown, the private virtual address 1.1 of the first process corresponds to the physical address 2.1, the private virtual address 1.2 of the second process corresponds to the physical address 2.2, and the shared virtual address 1.3 corresponds to the physical address 2.3. The physical addresses 2.1, 2.2, and 2.3 are all physical addresses in volatile memory. The data generated during the operation of the first process is stored at the physical address 2.1. Then, the processor copies this data from the physical address 2.1 to the physical address 2.3. When the second process accesses the shared virtual address 1.3, the processor can copy the data in the physical address 2.3 to the physical address 2.2. Then, the second process can access the private virtual address 1.2 to access the data at the physical address 2.2.
[0078] However, during the process of sharing data between the first process and the second process, data needs to be copied. For example, the processor needs to copy data from the physical address 2.1 to the physical address 2.3 and from the physical address 2.3 to the physical address 2.2. The time required to copy data is relatively long, which results in a relatively long time between the generation of data by the first process and the access to this data by the second process. Therefore, there is a relatively high latency in sharing data between processes.
[0079] When the capacity of the free storage space in the volatile memory is small, the processor will also move out the data in the volatile memory. In this way, when the second process accesses the shared virtual address, it is very likely that the processor cannot obtain the data from the physical address corresponding to the shared virtual address. At this time, the processor needs to search for the data in the non-volatile memory, and after finding the data, it will copy the data from the non-volatile memory to the physical address corresponding to the shared virtual address in the volatile memory, so that the subsequent processor can copy the data from the physical address corresponding to the shared virtual address to the physical address corresponding to the private virtual address of the second process. However, this process is relatively complex, and the processor performs many operations, which will also increase the delay of sharing data between processes.
[0080] In addition, in the related art, when the dirty flush condition is met, the processor will also perform a dirty flush operation. The dirty flush condition can be that the period for performing the dirty flush operation arrives, or the capacity of the free storage space in the volatile memory is less than a threshold value, etc. The dirty flush operation can include: the processor locks the shared virtual address to prohibit the shared virtual address from being accessed by the process; then, the processor copies the data in the physical address corresponding to the shared virtual address to the non-volatile memory for backup; after copying the data in the physical address corresponding to the shared virtual address to the non-volatile memory, the processor unlocks the shared virtual address to allow the shared virtual address to be accessed by the process. Since the shared virtual address is locked during the process of the processor performing the dirty flush operation, the shared virtual address cannot be accessed by the process during this process. Therefore, it will affect the sharing of data between processes and further increase the delay of sharing data between processes.
[0081] Experiments show that among the delays of sharing data between processes, the delay caused by data transmission (copying data) accounts for more than 30% of the total delay, and the software delay of the processor (the delay caused by the many operations performed by the processor) accounts for more than 50% of the total delay.
[0082] In the above content, the physical address corresponding to the shared virtual address is taken as an example of the physical address of the volatile memory. Optionally, in a full memory architecture, in the related art, the physical address corresponding to the above shared virtual address can also be set as an address in the non-volatile memory. However, there is still a problem of data copying. Therefore, the delay of sharing data is still high. And because the access to the volatile memory is relatively slow, copying data to the physical address in the volatile memory and copying data from the physical address in the volatile memory to other physical addresses takes a long time, which will further increase the delay of sharing data.
[0083] The embodiment of the present application provides a data sharing method, which can reduce the delay of sharing data between processes. This method is performed by Figure 1It is executed by a processor in the [system]. The processor is connected to a volatile memory and a non-volatile memory, and the non-volatile memory can be accessed by the instructions of the processor. It can be seen that this application is applicable to a memory with a heterogeneous architecture, and the heterogeneous architecture is a full memory architecture. The processor can call a data sharing process to execute the data sharing method provided in the embodiments of this application. The data sharing process can include one or more processes. When the data sharing process includes multiple processes, different processes are used to execute different operations in the data sharing method.
[0084] Exemplarily, Figure 3 is a flowchart of a data sharing method provided in the embodiments of this application. As Figure 3 shown, the data sharing method includes:
[0085] S101. The processor writes the first data of the first process into the first physical address of the volatile memory; the first physical address is the physical address corresponding to the first private virtual address of the first process.
[0086] During the running of the first process, the processor can write the first data of the first process into the first physical address corresponding to the first private virtual address of the first process, and the first physical address is the physical address of the volatile memory.
[0087] The first private virtual address is a virtual address private to the first process. The first private virtual address is allowed to be accessed by the first process and prohibited from being accessed by other processes except the first process.
[0088] In the embodiments of this application, the first process and the subsequent second process can be applications or processes of other modules. The applications to which the first process and the second process belong can be the same or different. This application does not make any limitations in this regard.
[0089] S102. The processor sets the physical address corresponding to the shared virtual address to the first physical address.
[0090] After writing the first data into the first physical address, the processor can map the shared virtual address to the first physical address, that is, set the physical address corresponding to the shared virtual address to the first physical address. The shared virtual address is allowed to be accessed by any process.
[0091] In this way, it is convenient for other processes (such as the second process) except the first process to access the data on the first physical address by accessing the shared virtual address, thereby realizing the sharing of data from the first process to other processes.
[0092] It can be seen that in S102, the physical address corresponding to the first private virtual address and the physical address corresponding to the shared virtual address are both the above-mentioned first physical address. The processor does not copy the data in the first physical address to the physical address corresponding to the shared virtual address. Therefore, data copying is avoided, and the delay in sharing data between processes caused by data copying is avoided.
[0093] S103. The processor sets the physical address corresponding to the second private virtual address of the second process as the physical address corresponding to the shared virtual address according to the access request of the second process to the shared virtual address.
[0094] The second private virtual address is the virtual address private to the second process. The second private virtual address is allowed to be accessed by the second process and prohibited from being accessed by other processes except the second process.
[0095] When the second process needs to read the first data, it can initiate an access request to the shared virtual address. At this time, the processor can map the second private virtual address of the second process to the physical address corresponding to the shared virtual address, that is, the processor sets the physical address corresponding to the second private virtual address of the second process as the physical address corresponding to the above-mentioned shared virtual address. After setting the physical address corresponding to the second private virtual address of the second process, the second process can access the first data on the corresponding physical address by accessing the second private virtual address.
[0096] According to the above content, it can be known that in S103, the physical address corresponding to the second private virtual address is the same as the physical address corresponding to the shared virtual address. The processor does not copy the data in the physical address corresponding to the shared virtual address to the physical address corresponding to the second private virtual address. Therefore, data copying is avoided, and the delay in sharing data between processes caused by data copying is avoided.
[0097] It can be understood that in the embodiments of the present application, it is taken as an example that no data copying is performed in both S102 and S103. It can be understood that it may also be that no data copying is performed in S102 and data copying is performed in S103. Or, data copying is performed in S102 and no data copying is performed in S103.
[0098] In the case where data copying is performed in S102, the first physical address corresponding to the first private virtual address is different from the physical address corresponding to the shared virtual address. The processor needs to copy the first data on the first physical address corresponding to the first private virtual address to the physical address corresponding to the shared virtual address in S102.
[0099] When data is copied in S103, the physical address corresponding to the second private virtual address is different from the physical address corresponding to the shared virtual address. In S103, the processor needs to copy the first data on the physical address corresponding to the shared virtual address to the physical address corresponding to the second private virtual address.
[0100] In summary, in the data sharing method provided by the embodiments of the present application, after the processor writes the first data of the first process to the first physical address of the volatile memory, the physical address corresponding to the shared virtual address is set to the first physical address. In this way, it is convenient for other processes (such as the second process) other than the first process to access the data on the first physical address by accessing the shared virtual address, thereby realizing the sharing of data from the first process to other processes. It can be seen that the processor can share data between processes by setting the physical address corresponding to the virtual address, reducing the copy of shared data between processes. Therefore, the latency of shared data between processes can be reduced.
[0101] The order of the steps in the method embodiments provided by the embodiments of the present application can be appropriately adjusted, and the steps can also be increased or decreased accordingly according to the situation. Any person skilled in the art can easily think of the changed methods within the technical scope disclosed in the present application and should be covered by the protection scope of the present application. Therefore, it will not be elaborated here.
[0102] The process of sharing data from the first process to the second process is introduced above. Optionally, any process (such as the first process, the second process, or other processes) can also modify the data shared by the first process.
[0103] Exemplarily, the processor can lock the shared virtual address according to the data modification request for the shared virtual address to prevent the shared virtual address from being accessed by the process. Assume that the data modification request is used to request to modify the data on the physical address corresponding to the shared virtual address to the second data on the fourth physical address of the volatile memory. Then, the processor can change the physical address corresponding to the shared virtual address to the fourth physical address. After changing the physical address corresponding to the shared virtual address to the fourth physical address, the processor can also unlock the shared virtual address to allow the shared virtual address to be accessed by the process. If a process (such as the second process) accesses the shared virtual address subsequently, then the process will finally access the modified second data instead of the original first data.
[0104] Further, after the data on the physical address corresponding to the shared virtual address is changed from the first data to the second data, the processor can further lock the shared virtual address according to other data modification requests for the shared virtual address, and change the physical address corresponding to the shared virtual address to the physical address where other data is located, and then unlock the shared virtual address. It can be seen that the processor can sequentially perform the above operations according to multiple data modification requests, and continuously modify the data on the physical address corresponding to the shared virtual address.
[0105] According to the above content, it can be known that the processor only needs to change the physical address corresponding to the shared virtual address to complete the data modification. Since the time required to change the physical address corresponding to the shared virtual address is short, the locking time of the shared virtual address is short, and the impact on the process accessing the shared virtual address is small.
[0106] In the related art, if it is necessary to modify the data on the physical address corresponding to the shared virtual address, the processor also needs to lock the shared virtual address first. Then, the processor copies the second data in the above fourth physical address to the physical address corresponding to the shared virtual address to change the data on the physical address corresponding to the shared virtual address from the first data to the second data. Finally, the processor unlocks the shared virtual address. However, in this technology, the time required to copy the data is long, which results in a long locking time of the shared virtual address and a large impact on the process accessing the shared virtual address.
[0107] Optionally, the processor in the embodiment of the present application can also perform a dirty flush operation. For example, the processor can perform a dirty flush operation when the dirty flush condition is met. The dirty flush condition can be that the period for performing the dirty flush operation arrives, or the capacity of the free storage space in the volatile memory is less than the capacity threshold, etc. The dirty flush operation can include: the processor first locks the shared virtual address to prevent the shared virtual address from being accessed by the process; then, the processor sets the physical address corresponding to the dirty flush virtual address to the physical address corresponding to the shared virtual address, and then unlocks the shared virtual address to allow the shared virtual address to be accessed by the process; finally, the processor copies the data on the physical address corresponding to the dirty flush virtual address to the fifth physical address in the non-volatile memory.
[0108] The above dirty flush virtual address can be the private virtual address of the process that performs the dirty flush operation in the processor, or can be other shared virtual addresses different from the aforementioned shared virtual address.
[0109] According to the above dirty flushing operation, the way the processor performs dirty flushing is to first lock the shared virtual address, and then map the dirty flushing virtual address to the physical address corresponding to the shared virtual address (that is, set the physical address corresponding to the dirty flushing virtual address to the physical address corresponding to the shared virtual address). Subsequently, the shared virtual address is unlocked, and based on the dirty flushing virtual address, the data on the physical address corresponding to the shared virtual address is copied to the non-volatile memory. Since in the dirty flushing operation, the duration for which the shared virtual address is locked is the duration for mapping the dirty flushing virtual address to the physical address corresponding to the shared virtual address, and the duration for mapping the dirty flushing virtual address to the physical address corresponding to the shared virtual address is short, therefore, the time for which the shared virtual address is locked is short. Thus, the dirty flushing operation has a small impact on the process's access to the shared virtual address.
[0110] In addition, during the dirty flushing operation, if a process needs to modify the data on the physical address corresponding to the shared virtual address, then the processor will change the physical address corresponding to the shared virtual address to the physical address where the new data is located. However, at this time, the physical address corresponding to the dirty flushing virtual address is still the old physical address. Therefore, the processor still copies the data on the old physical address to the non-volatile memory.
[0111] For example, assume that the shared virtual address corresponds to physical address 1, and data 1 is stored on physical address 1. The data accessed by the process when accessing the shared virtual address is data 1. If the dirty flushing condition is met at this time, then during the dirty flushing operation, the processor sets physical address 1 as the physical address corresponding to the dirty flushing virtual address, and based on this dirty flushing virtual address, copies the data 1 on physical address 1 to the non-volatile memory. During the dirty flushing operation, if a process needs to change the data associated with the shared virtual address from data 1 on physical address 1 to data 2 on physical address 2, then the processor can change the physical address corresponding to the shared virtual address from physical address 1 to physical address 2. In this way, the data accessed by the subsequent process when accessing the shared virtual address is data 2. However, at this time, the processor still copies data 1 to the non-volatile memory, rather than copying data 2 to the non-volatile memory. After that, if the dirty flushing condition is met again, then the processor can refer to the process of copying data 1 to the non-volatile memory and copy data 2 to the non-volatile memory.
[0112] It can be seen that during the dirty flushing operation, if there is a modification to the data associated with the shared virtual address, then there will be two versions of the data associated with the shared virtual address existing in the memory simultaneously. Moreover, the processor copies the old version of the data to the non-volatile memory, and the data accessed by the process when accessing the shared virtual address is the new version of the data.
[0113] Further, when the processor copies the data at the physical address corresponding to the dirty virtual address to the fifth physical address of the non-volatile memory, it can directly copy the data to the fifth physical address. Alternatively, the processor can first copy the data at the physical address corresponding to the dirty virtual address to the log in the non-volatile memory; after successfully copying the data at the physical address corresponding to the dirty virtual address to the log, the processor then copies the data on the log to the fifth physical address. In this way, it is ensured that the data copied by the processor to the fifth physical address is exactly the same as the data at the physical address corresponding to the dirty virtual address, or the processor does not copy any data to the fifth physical address, ensuring the atomicity of the data on the non-volatile memory.
[0114] In the embodiment of the present application, the processor can also move data out of the free storage space to expand the capacity of the free storage space of the volatile memory.
[0115] Exemplarily, the processor can move the above-mentioned first data out of the first physical address. For example, the processor can move the first data out of the first physical address according to the satisfaction of the moving condition. The processor can judge whether the moving condition is satisfied, and when the moving condition is satisfied, move the first data out of the first physical address. When the moving condition is not satisfied, continue to judge whether the moving condition is satisfied. After the data is moved out of the volatile memory, the storage space occupied by the data in the volatile memory is released, and this storage space becomes free storage space. In this way, the capacity of the free storage space of the volatile memory can be increased to support the storage of subsequent data.
[0116] There are various implementation manners of the moving condition.
[0117] For example, the moving condition includes: the capacity of the free storage space of the volatile memory is less than the capacity threshold. The capacity threshold in the moving condition is different from the capacity threshold in the dirty condition. For example, the capacity threshold in the moving condition is the first capacity threshold, and the capacity threshold in the dirty condition is the second capacity threshold, and the first capacity threshold can be less than the second capacity threshold. The free storage space of the volatile memory refers to the storage space in the volatile memory where no data is stored. When the capacity of the free storage space of the volatile memory is less than the capacity threshold, it is difficult for the volatile memory to support the storage of subsequent data. Therefore, the processor can move the data in the volatile memory out.
[0118] For another example, the removal condition includes that within a target time period before the current moment, the number of processes accessing the shared virtual address is less than a quantity threshold. It can be seen that the processor can count the number of processes accessing the shared virtual address within the target time period before the current moment. When this number is less than the quantity threshold, it indicates that there are fewer processes accessing the shared virtual address, the data on the physical address corresponding to the shared virtual address is cold data, and the probability that the shared virtual address has been recently accessed is relatively high. At this time, the first data on the first physical address corresponding to the shared virtual address can be removed.
[0119] In addition, if within the target time period before the current moment, the number of processes accessing the shared virtual address is greater than or equal to the quantity threshold, it indicates that there are more processes accessing the shared virtual address recently, the data on the physical address corresponding to the shared virtual address is hot data, and the probability that the shared virtual address has been recently accessed is relatively low. It is not suitable to remove the data on the physical address corresponding to the shared virtual address at present to ensure the normal access of the process to the shared virtual address.
[0120] For yet another example, the removal condition includes that the capacity of the free storage space in the volatile memory is less than a capacity threshold, and within the target time period before the current moment, the number of processes accessing the shared virtual address is less than the quantity threshold.
[0121] It can be understood that generally, the physical address corresponding to the virtual address is managed by the virtual memory subsystem. In the embodiments of the present application, however, the processor can also set the physical address corresponding to the virtual address. It can be seen that the virtual memory subsystem is exposed to the processor, and the processor can obtain the number of processes accessing the shared virtual address through the virtual memory subsystem. Therefore, the embodiments of the present application support that the removal condition includes that within the target time period before the current moment, the number of processes accessing the shared virtual address is less than the quantity threshold.
[0122] Furthermore, after the processor removes the first data from the first physical address, it can also determine whether the first data exists in the non-volatile memory. If the first data exists on the second physical address in the non-volatile memory, then the processor can also perform subsequent operations to change the physical address corresponding to the shared virtual address from the first physical address to the second physical address.
[0123] Exemplarily, when the first data exists on the second physical address, the processor can lock the shared virtual address to prevent the shared virtual address from being accessed by the process; then, the processor changes the physical address corresponding to the shared virtual address from the first physical address to the second physical address; finally, the processor unlocks the shared virtual address to allow the shared virtual address to be accessed by the process.
[0124] It can be understood that the first data at the second physical address in the volatile memory may be the first data copied by the processor at the second physical address during the execution of the dirty flush operation; or, the first data is pre-stored by the user at the second physical address in the volatile memory. In short, the embodiments of the present application do not limit the way in which the first data stored at the second physical address is obtained.
[0125] In addition, when the first data is not stored in the non-volatile memory, the processor does not need to change the physical address corresponding to the shared virtual address from the first physical address to the second physical address.
[0126] It can be understood that S103 in the above embodiment may occur before the processor changes the physical address corresponding to the shared virtual address from the first physical address to the second physical address, or may occur after the processor changes the physical address corresponding to the shared virtual address from the first physical address to the second physical address. When S103 occurs before the processor changes the physical address corresponding to the shared virtual address from the first physical address to the second physical address, the physical address corresponding to the shared virtual address is the first physical address of the volatile memory. When S103 occurs after the processor changes the physical address corresponding to the shared virtual address from the first physical address to the second physical address, the physical address corresponding to the shared virtual address is the second physical address of the non-volatile memory.
[0127] In the related art, the physical address corresponding to the shared virtual address is the physical address of the volatile memory. After the processor moves out the data in the physical address corresponding to the shared virtual address, if a process accesses the shared virtual address, the processor will find that the physical address corresponding to the shared virtual address does not hit the data. At this time, the processor needs to search for the data in the non-volatile memory and copy the found data to the physical address corresponding to the shared virtual address. And during this process, the process accessing the shared virtual address is in a waiting state, which will significantly increase the latency of data sharing. Moreover, the process executed by the processor is relatively complex and involves many operations, which will also increase the latency of data sharing between processes.
[0128] In the embodiments of the present application, when the physical address corresponding to the shared virtual address is not the first physical address of the volatile memory, if the physical address corresponding to the shared virtual address is the second physical address of the non-volatile memory, then the processor can set the corresponding physical address for the second private virtual address of the second process without copying data, so that the second process can access the data, and the waiting time of the second process is shorter, reducing the latency of data sharing.
[0129] Moreover, in the embodiments of the present application, after the processor moves the data in the volatile memory, if the physical address corresponding to the shared virtual address is changed to the physical address of the non-volatile memory, then the complex processes in the related art can be avoided. Therefore, the processor performs fewer operations, which further reduces the latency of sharing data between processes. Additionally, since the operations of the processor in the embodiments of the present application are relatively simple, the input / output (I / O) stack related to the operations of the processor in the present application is shorter.
[0130] Optionally, if the physical address corresponding to the shared virtual address in S103 above is the physical address of the non-volatile memory, then the processor can further perform the following operations to further reduce the latency of sharing data.
[0131] Exemplarily, when the physical address corresponding to the shared virtual address is the second physical address, the processor can copy the first data in the second physical address to the third physical address of the volatile memory. After that, the processor locks the shared virtual address to prevent the shared virtual address from being accessed by the process; then, the processor changes the physical address corresponding to the shared virtual address and the physical address corresponding to the second private virtual address from the second physical address to the third physical address. Finally, the processor unlocks the shared virtual address to allow the shared virtual address to be accessed by the process.
[0132] When the physical address corresponding to the shared virtual address is the physical address of the non-volatile memory (such as the second physical address above), considering that the access to the non-volatile memory is relatively slow, the processor can copy the first data in the second physical address to the third physical address of the volatile memory, and then change the physical address corresponding to the shared virtual address and the physical address corresponding to the second private virtual address from the second physical address to the third physical address. In this way, the second process can access the first data on the third physical address by accessing the second private virtual address. And since the third physical address is the physical address of the volatile memory, the second process can access the first data on the third physical address at a faster speed, which can further reduce the latency of sharing data between processes.
[0133] Optionally, the processor's copying of the first data in the second physical address to the third physical address of the volatile memory can be parallel to S103. For example, when the processor sets the physical address corresponding to the second private virtual address to the physical address corresponding to the shared virtual address, it copies the first data in the second physical address to the third physical address. In this way, the copying of the first data can be completed earlier, further improving the efficiency of data sharing. Of course, the processor can also copy the first data in the second physical address to the third physical address of the volatile memory after S103, and the embodiments of the present application do not limit this.
[0134] Optionally, after the processor copies the first data in the second physical address to the third physical address in the volatile memory, the processor may also move out the first data in the second physical address to increase the free storage space of the non-volatile memory. Of course, the processor may also not move out the first data in the second physical address, and the embodiments of the present application do not limit this.
[0135] In the above content, taking the data sharing between the first process and the second process through a shared virtual address as an example, it can be understood that there may be multiple shared virtual addresses, and other processes can also share data through the shared virtual address.
[0136] Before executing the method provided by the embodiments of the present application, the processor may also perform an initialization operation. The initialization operation may include: the processor first divides the shared virtual addresses that need to be used subsequently and creates relevant page tables for these shared virtual addresses. The virtual storage space composed of these shared virtual addresses may be referred to as a flat cache (FLAC) virtual storage space.
[0137] It should be noted that at this time, the processor does not set the physical addresses corresponding to these shared virtual addresses. Therefore, the page table of the shared virtual address at this time is not a complete page table. During the execution of the method provided by the embodiments of the present application, when setting the physical address corresponding to the shared virtual address, the page table of the shared virtual address can be completed so that the page table points to the physical address corresponding to the shared virtual address.
[0138] When the processor sets the physical address corresponding to a virtual address (such as a shared virtual address), it can be implemented by calling the page attach system.
[0139] In addition, during the execution of the embodiments of the present application by the processor, the physical address corresponding to the shared virtual address may be set to the physical address in the volatile memory or may be set to the physical address in the non-volatile memory, but the process does not actually perceive these physical addresses, and the process only needs to perceive the shared virtual address.
[0140] According to the foregoing introduction, the latency of data sharing between processes in the embodiments of the present application is relatively low. Therefore, when multiple processes concurrently access the shared virtual address, the access time of each process to the shared virtual address is relatively short. Therefore, the total time for multiple processes to concurrently access the shared virtual address is also relatively short, making the degree of concurrency supported by the embodiments of the present application relatively high. The process accessing the shared virtual address can be used to read or modify the data on the physical address corresponding to the shared virtual address, etc.
[0141] The following will be combined with Figure 4 、 Figure 5 、 Figure 6 、 Figure 7And Figure 8 An example of the method provided by the embodiments of this application will be given.
[0142] As Figure 4 shown, assume that the private virtual address 1.1 of the first process corresponds to the physical address 2.1 in the volatile memory. The processor can write the data 1 of the first process to the physical address 2.1. After that, the processor sets the physical address corresponding to the shared virtual address 3.1 to the physical address 2.1. After that, if a second process's access request to the shared virtual address 3.1 is received, the processor can also, according to the access request, set the physical address corresponding to the private virtual address 4.1 of the second process to the physical address 2.1 corresponding to the shared virtual address 3.1. After that, the second process can access the data 1 on the physical address 2.1 by accessing the private virtual address 4.1.
[0143] As Figure 5 shown, the processor can also move the data 1 in the physical address 2.1 out; assume that the data 1 is stored in the physical address 5.1 of the non-volatile memory, then the processor can also lock the shared virtual address 3.1 to prevent the shared virtual address 3.1 from being accessed by the process; after that, the processor changes the physical address corresponding to the shared virtual address 3.1 from the physical address 2.1 to the physical address 5.1; finally, the processor can also unlock the shared virtual address 3.1 to allow the shared virtual address 3.1 to be accessed by the process. After that, if a second process's access request to the shared virtual address 3.1 is received, the processor can also, according to the access request, set the physical address corresponding to the private virtual address 4.1 of the second process to the physical address 5.1 corresponding to the shared virtual address 3.1. After that, the second process can access the data 1 on the physical address 5.1 by accessing the private virtual address 4.1.
[0144] And, as Figure 6 shown, after that, the processor can also copy the data 1 in the physical address 5.1 to the physical address 2.2 of the volatile memory; the processor can also lock both the shared virtual address 3.1 and the private virtual address 401 to prevent the shared virtual address 3.1 and the private virtual address 4.1 from being accessed by the process; change the physical address corresponding to the shared virtual address 3.1 and the physical address corresponding to the private virtual address 4.1 from the physical address 5.1 to the physical address 2.2; then unlock both the shared virtual address 3.1 and the private virtual address 401 to allow the shared virtual address 3.1 and the private virtual address 4.1 to be accessed by the process. After that, the second process can access the data 1 on the physical address 2.2 by accessing the private virtual address 4.1.
[0145] The processor can also lock the shared virtual address 3.1 according to a data modification request for the data of the shared virtual address 3.1 to prevent the shared virtual address 3.1 from being accessed by a process; the data modification request is used to request to modify the data on the physical address corresponding to the shared virtual address 3.1 to the data 2 on the physical address 2.3 of the volatile memory; as Figure 7 shown, assuming that the data modification request is received Figure 6 after that, then the processor can change the physical address 2.2 corresponding to the shared virtual address 3.1 to the physical address 2.3 of the volatile memory. Finally, the processor unlocks the shared virtual address 3.1 to allow the shared virtual address 3.1 to be accessed by a process.
[0146] The processor can also lock the shared virtual address 3.1 to prevent the shared virtual address 3.1 from being accessed by a process; and, the processor sets the physical address corresponding to the dirty virtual address 3.2 to the physical address corresponding to the shared virtual address 3.1; as Figure 8 shown, assuming that the dirty operation is performed Figure 7 after that, then the processor can set the physical address corresponding to the dirty virtual address 3.2 to the physical address 2.3 corresponding to the shared virtual address 3.1. After that, the processor can unlock the shared virtual address 3.1 to allow the shared virtual address 3.1 to be accessed by a process; the processor can also copy the data 2 on the physical address 2.3 corresponding to the dirty virtual address 3.2 to the physical address 5.2 of the non-volatile memory.
[0147] Furthermore, the data shared by adopting the method provided by the embodiment of the present application can be part of the data or all of the data of the process. Taking the data shared by adopting the method provided by the embodiment of the present application can be part of the data of the process as an example, assuming that the data of the first process includes: data 1 and the metadata of data 1, then, data 1 can be shared by adopting the method provided by the embodiment of the present application, while the metadata of data 1 is not shared by adopting the method provided by the embodiment of the present application. Exemplarily, the processor can adopt a hashing method to allocate shared memory in the volatile memory and shared memory in the non-volatile memory for the metadata of data 1, and the metadata is stored in both of these two shared memories. When the metadata needs to be shared to the second process, the processor obtains the metadata from the shared memory in the volatile memory and feeds it back to the second process.
[0148] Through experiments, it is found that the method provided by the embodiment of the present application is compared with the related art, and the latency of sharing data between processes in the related art is at least 10 times that of sharing data between processes in the method provided by the embodiment of the present application. In the scenario where the total read / write data volume is 64 gigabytes (GB) and the data volume of each read / write is 2 mebibytes (MB), the efficiency of process reading / writing data in the present application is more than 200 times higher than that of process reading / writing data in the related art.
[0149] Based on the data sharing method provided in the embodiment of the present application, the embodiment of the present application also provides a data sharing device, which belongs to a processor, the processor is connected to a volatile memory and a non-volatile memory, and the non-volatile memory can be accessed by instructions of the processor; Figure 9 As shown, the data sharing device includes:
[0150] The write module 901 is used to write the first data of the first process into the first physical address of the volatile memory; the first physical address is the physical address corresponding to the first private virtual address, the first private virtual address is allowed to be accessed by the first process, and is prohibited from being accessed by processes other than the first process; the operations performed by the write module 901 can refer to S101 in the aforementioned embodiment, and the embodiments of the present application will not be repeated here.
[0151] The first setting module 902 is used to set the physical address corresponding to the shared virtual address to the first physical address, and the shared virtual address is allowed to be accessed by any process. The operation performed by the first setting module 902 can refer to S102 in the above embodiment, and the embodiment of the present application will not be repeated here.
[0152] Optionally, the data sharing device further includes: a removal module, a third locking module, a first changing module and a third unlocking module ( Figure 9 (not shown in the figure). The removal module is used to move the first data out of the first physical address; the third locking module is used to lock the shared virtual address when the first data exists in the second physical address of the non-volatile memory to prevent the shared virtual address from being accessed by the process; the first changing module is used to change the physical address corresponding to the shared virtual address from the first physical address to the second physical address. The third unlocking module is used to unlock the shared virtual address to allow the shared virtual address to be accessed by the process. The operations performed by the removal module, the third locking module, the first changing module and the third unlocking module can refer to the relevant description in the aforementioned embodiments, and the embodiments of the present application will not be repeated here.
[0153] Optionally, the removal module is configured to remove the first data from the first physical address when a removal condition is met. The removal condition includes at least one of the following conditions: the capacity of the free storage space in the volatile memory is less than a capacity threshold; and the number of processes accessing the shared virtual address within a target time period before the current moment is less than a number threshold.
[0154] Optionally, the data sharing device further includes:
[0155] A second setting module ( Figure 9 not shown in the figure) configured to set the physical address corresponding to a second private virtual address to the physical address corresponding to the shared virtual address according to an access request of a second process to the shared virtual address. The second private virtual address is allowed to be accessed by the second process and prohibited from being accessed by processes other than the second process. The operations performed by the second setting module may refer to S103 in the foregoing embodiment, and details are not described herein again in this embodiment of the present application.
[0156] Optionally, the data sharing device further includes: a second setting module, a first copy module, a fourth locking module, a second changing module, and a fourth unlocking module ( Figure 9 not shown in the figure).
[0157] The second setting module is configured to set the physical address corresponding to a second private virtual address to the physical address corresponding to the shared virtual address according to an access request of a second process to the shared virtual address. The second private virtual address is allowed to be accessed by the second process and prohibited from being accessed by processes other than the second process. The first copy module is configured to copy the first data in the second physical address to a third physical address in the volatile memory when the physical address corresponding to the shared virtual address is the second physical address. The fourth locking module is configured to lock both the shared virtual address and the second private virtual address to prevent the shared virtual address and the second private virtual address from being accessed by processes. The second changing module is configured to change both the physical address corresponding to the shared virtual address and the physical address corresponding to the second private virtual address from the second physical address to the third physical address. The fourth unlocking module is configured to unlock both the shared virtual address and the second private virtual address to allow the shared virtual address and the second private virtual address to be accessed by processes. The operations performed by the second setting module, the first copy module, the fourth locking module, the second changing module, and the fourth unlocking module may refer to the relevant descriptions in the foregoing embodiment, and details are not described herein again in this embodiment of the present application.
[0158] Optionally, the first copy module is configured to: when setting the physical address corresponding to the second private virtual address to the physical address corresponding to the shared virtual address, copy the first data in the second physical address to the third physical address.
[0159] Optionally, the data sharing device further includes:
[0160] A first locking module ( Figure 9 not shown in the figure) for locking the shared virtual address according to a data modification request for the shared virtual address to prevent the shared virtual address from being accessed by a process; the data modification request is used to request modifying the data on the physical address corresponding to the shared virtual address to the second data on the fourth physical address of the volatile memory;
[0161] A third changing module ( Figure 9 not shown in the figure) for changing the physical address corresponding to the shared virtual address to the fourth physical address;
[0162] A first unlocking module ( Figure 9 not shown in the figure) for unlocking the shared virtual address to allow the shared virtual address to be accessed by a process.
[0163] The operations to be performed by the first locking module, the third changing module, and the first unlocking module can refer to the introduction of the process of modifying the data associated with the shared virtual address in the foregoing embodiments, and details are not described herein again in the embodiments of the present application.
[0164] Optionally, the data sharing device further includes:
[0165] A second locking module ( Figure 9 not shown in the figure) for locking the shared virtual address to prevent the shared virtual address from being accessed by a process;
[0166] A third setting module ( Figure 9 not shown in the figure) for setting the physical address corresponding to the dirty virtual address to the physical address corresponding to the shared virtual address;
[0167] A second unlocking module ( Figure 9 not shown in the figure) for unlocking the shared virtual address to allow the shared virtual address to be accessed by a process;
[0168] A second copy module ( Figure 9 not shown in the figure) for copying the data on the physical address corresponding to the dirty virtual address to the fifth physical address of the non-volatile memory.
[0169] The operations to be performed by the second locking module, the third setting module, the second unlocking module, and the second copying module can refer to the introduction of the dirty brushing operation in the foregoing embodiments, and will not be elaborated in the embodiments of the present application.
[0170] Optionally, the second copying module is configured to: copy the data on the physical address corresponding to the dirty brushing virtual address to the log in the non-volatile memory; after successfully copying the data on the physical address corresponding to the dirty brushing virtual address to the log, copy the data on the log to the fifth physical address.
[0171] An embodiment of the present application provides another data sharing device, which also belongs to a processor. The processor is connected to a volatile memory and a non-volatile memory, and the non-volatile memory can be accessed by the instructions of the processor; the data sharing device includes:
[0172] A second setting module, configured to set the physical address corresponding to the second private virtual address to the physical address corresponding to the shared virtual address according to the access request of the second process to the shared virtual address; the second private virtual address is allowed to be accessed by the second process and prohibited from being accessed by processes other than the second process, and the shared virtual address is allowed to be accessed by any process.
[0173] Optionally, the data sharing device further includes:
[0174] A writing module, configured to write the first data of the first process to the first physical address of the volatile memory; the first physical address is the physical address corresponding to the first private virtual address, and the first private virtual address is allowed to be accessed by the first process and prohibited from being accessed by processes other than the first process;
[0175] A first setting module, configured to set the physical address corresponding to the shared virtual address to the first physical address, and the shared virtual address is allowed to be accessed by any process.
[0176] Optionally, the data sharing device further includes: a removal module, a third locking module, a third unlocking module, and a first modification module. The removal module is configured to remove the first data from the first physical address; the third locking module is configured to lock the shared virtual address to prevent the shared virtual address from being accessed by a process when the first data exists in the second physical address of the non-volatile memory; the first modification module is configured to change the physical address corresponding to the shared virtual address from the first physical address to the second physical address; the third unlocking module is configured to unlock the shared virtual address to allow the shared virtual address to be accessed by a process.
[0177] Optionally, the removal module is used to move the first data out of the first physical address according to whether a removal condition is met; the removal condition includes at least one of the following conditions: the capacity of the free storage space of the volatile memory is less than a capacity threshold; and, within a target time period before the current moment, the number of processes accessing the shared virtual address is less than a number threshold.
[0178] Optionally, the data sharing device further includes: a first copy module, a fourth locking module, a fourth unlocking module and a second changing module. The first copy module is used to copy the first data in the second physical address to the third physical address of the volatile memory when the physical address corresponding to the shared virtual address is the second physical address; the fourth locking module is used to lock both the shared virtual address and the second private virtual address to prevent the shared virtual address and the second private virtual address from being accessed by the process; the second changing module is used to change the physical address corresponding to the shared virtual address and the physical address corresponding to the second private virtual address from the second physical address to the third physical address; the fourth unlocking module is used to unlock both the shared virtual address and the second private virtual address to allow the shared virtual address and the second private virtual address to be accessed by the process.
[0179] Optionally, the first copy module is used to: when the physical address corresponding to the second private virtual address is set to the physical address corresponding to the shared virtual address, copy the first data in the second physical address to the third physical address.
[0180] Optionally, the data sharing device further includes: a first locking module, a third changing module and a first unlocking module. The first locking module is used to lock the shared virtual address according to a data modification request for the shared virtual address to prevent the shared virtual address from being accessed by a process; the data modification request is used to request that the data at the physical address corresponding to the shared virtual address be modified to the second data at the fourth physical address of the volatile memory; the third changing module is used to change the physical address corresponding to the shared virtual address to the fourth physical address; and the first unlocking module is used to unlock the shared virtual address to allow the shared virtual address to be accessed by a process.
[0181] Optionally, the data sharing device further includes: a second locking module, a third setting module, a second unlocking module, and a second copying module. Among them, the second locking module is used to lock the shared virtual address to prevent the shared virtual address from being accessed by a process; the third setting module is used to set the physical address corresponding to the dirty virtual address as the physical address corresponding to the shared virtual address; the second unlocking module is used to unlock the shared virtual address to allow the shared virtual address to be accessed by a process; the second copying module is used to copy the data on the physical address corresponding to the dirty virtual address to the fifth physical address of the non-volatile memory.
[0182] Optionally, the second copying module is used to: copy the data on the physical address corresponding to the dirty virtual address to the log in the non-volatile memory; after successfully copying the data on the physical address corresponding to the dirty virtual address to the log, copy the data on the log to the fifth physical address.
[0183] An embodiment of the present application further provides a chip, which includes programmable logic circuits and / or program instructions, and is used to implement any data sharing method provided by the embodiment of the present application when the chip runs.
[0184] An embodiment of the present application further provides a computer-readable storage medium, in which instructions are stored;
[0185] When the instructions run on a computer, the computer is made to execute any data sharing method provided by the embodiment of the present application.
[0186] The present application provides a computer program product containing instructions, which, when running on a computer, causes the computer to execute any data sharing method provided by the present application.
[0187] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product, which includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from a website, computer, server, or data center to another website, computer, server, or data center in a wired manner (such as coaxial cable, optical fiber, digital subscriber line) or a wireless manner (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium, or a semiconductor medium (such as a solid-state drive), etc.
[0188] In the present application, terms such as "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance. The term "at least one" means one or more, and "a plurality" means two or more, unless otherwise clearly defined.
[0189] The method embodiments, device embodiments, and other different types of embodiments provided in the embodiments of the present application can refer to each other, and the embodiments of the present application do not make any limitations in this regard. The order of operations in the method embodiments provided in the embodiments of the present application can be appropriately adjusted, and operations can also be increased or decreased accordingly according to the situation. Any person skilled in the art can easily think of a changed method within the technical scope disclosed in the present application, and it should be covered by the protection scope of the present application, so it will not be elaborated here.
[0190] In the corresponding embodiments provided in the present application, it should be understood that the disclosed devices and the like can be implemented in other constitutive manners. For example, the device embodiments described above are only illustrative. For example, the division of modules is only a logical function division. In actual implementation, there can be other division methods. For example, multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection to each other can be an indirect coupling or communication connection through some interfaces, devices, or modules, and can be in an electrical or other form.
[0191] The unit described as a separating component may or may not be physically separated. The component described as a unit may or may not be a physical unit, and it may be located in one place or distributed across multiple devices. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0192] As described above, the foregoing is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present application can easily think of various equivalent modifications or substitutions, and these modifications or substitutions should be covered within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A data sharing method, characterized in that, The method is executed by a processor, which is connected to a volatile memory and a non-volatile memory, and the non-volatile memory can be accessed by the instructions of the processor; the method includes: Writing the first data of the first process to the first physical address of the volatile memory; the first physical address is the physical address corresponding to the first private virtual address, and the first private virtual address is allowed to be accessed by the first process and prohibited from being accessed by processes other than the first process; Setting the physical address corresponding to the shared virtual address to the first physical address, and the shared virtual address is allowed to be accessed by any process.
2. The method according to claim 1, characterized in that, The method further includes: Moving the first data out of the first physical address; When the first data exists in the second physical address of the non-volatile memory, locking the shared virtual address to prevent the shared virtual address from being accessed by a process; Changing the physical address corresponding to the shared virtual address from the first physical address to the second physical address; Unlocking the shared virtual address to allow the shared virtual address to be accessed by a process.
3. The method according to claim 2, wherein Moving the first data out of the first physical address includes: Moving the first data out of the first physical address according to the satisfaction of the moving condition; The moving condition includes at least one of the following conditions: The capacity of the free storage space of the volatile memory is less than the capacity threshold; And, within a target time period before the current moment, the number of processes accessing the shared virtual address is less than the number threshold.
4. The method according to any one of claims 1 to 3, characterized in that The method further includes: According to the access request of the second process to the shared virtual address, setting the physical address corresponding to the second private virtual address to the physical address corresponding to the shared virtual address; the second private virtual address is allowed to be accessed by the second process and prohibited from being accessed by processes other than the second process.
5. The method according to claim 2 or 3, characterized in that, The method further includes: According to the access request of the second process to the shared virtual address, setting the physical address corresponding to the second private virtual address to the physical address corresponding to the shared virtual address; the second private virtual address is allowed to be accessed by the second process and prohibited from being accessed by processes other than the second process; When the physical address corresponding to the shared virtual address is the second physical address, copying the first data in the second physical address to the third physical address of the volatile memory; Locking both the shared virtual address and the second private virtual address to prevent the shared virtual address and the second private virtual address from being accessed by a process; Changing both the physical address corresponding to the shared virtual address and the physical address corresponding to the second private virtual address from the second physical address to the third physical address; Unlocking both the shared virtual address and the second private virtual address to allow the shared virtual address and the second private virtual address to be accessed by a process.
6. The method according to claim 5, wherein Copying the first data in the second physical address to the third physical address of the volatile memory includes: When setting the physical address corresponding to the second private virtual address to the physical address corresponding to the shared virtual address, copy the first data in the second physical address to the third physical address.
7. The method according to any one of claims 1 to 6, characterized in that, The method further includes: According to a data modification request for the shared virtual address, lock the shared virtual address to prevent the shared virtual address from being accessed by a process; the data modification request is used to request modifying the data on the physical address corresponding to the shared virtual address to the second data on the fourth physical address of the volatile memory. Change the physical address corresponding to the shared virtual address to the fourth physical address. Unlock the shared virtual address to allow the shared virtual address to be accessed by a process.
8. The method according to any one of claims 1 to 7, characterized in that, The method further includes: Lock the shared virtual address to prevent the shared virtual address from being accessed by a process. Set the physical address corresponding to the dirty virtual address to the physical address corresponding to the shared virtual address. Unlock the shared virtual address to allow the shared virtual address to be accessed by a process. Copy the data on the physical address corresponding to the dirty virtual address to the fifth physical address of the non-volatile memory.
9. The method according to claim 8, wherein Copying the data on the physical address corresponding to the dirty virtual address to the fifth physical address of the non-volatile memory includes: Copy the data on the physical address corresponding to the dirty virtual address to the log in the non-volatile memory. After successfully copying the data on the physical address corresponding to the dirty virtual address to the log, copy the data on the log to the fifth physical address.
10. A data sharing method, characterized in that, The method is executed by a processor, the processor is connected to a volatile memory and a non-volatile memory, and the non-volatile memory can be accessed by the instructions of the processor; the method includes: According to an access request of a second process to a shared virtual address, set the physical address corresponding to the second private virtual address to the physical address corresponding to the shared virtual address; the second private virtual address is allowed to be accessed by the second process and prohibited from being accessed by processes other than the second process, and the shared virtual address is allowed to be accessed by any process.
11. A data sharing device, characterized in that, The data sharing device belongs to the processor, the processor is connected to a volatile memory and a non-volatile memory, and the non-volatile memory can be accessed by the instructions of the processor; The data sharing device includes: A writing module, configured to write the first data of the first process to the first physical address of the volatile memory; the first physical address is the physical address corresponding to the first private virtual address, the first private virtual address is allowed to be accessed by the first process and prohibited from being accessed by processes other than the first process. A first setting module, configured to set the physical address corresponding to the shared virtual address to the first physical address, and the shared virtual address is allowed to be accessed by any process.
12. A data sharing device, characterized in that, The data sharing device belongs to the processor, the processor is connected to a volatile memory and a non-volatile memory, and the non-volatile memory can be accessed by the instructions of the processor; The data sharing device includes: A first setting module, configured to set the physical address corresponding to a second private virtual address as the physical address corresponding to the shared virtual address according to an access request of a second process to the shared virtual address; the second private virtual address is allowed to be accessed by the second process and prohibited from being accessed by processes other than the second process, and the shared virtual address is allowed to be accessed by any process.
13. A computer, characterized in that, Comprising: A processor, a volatile memory, and a non-volatile memory, and the physical address of the non-volatile memory can be accessed by an instruction of the processor; The processor is configured to execute the data sharing method according to any one of claims 1 to 10.
14. A chip, characterized in that, The chip includes programmable logic circuits and / or program instructions, which are configured to implement the data sharing method according to any one of claims 1 to 10 when the chip runs.
15. A computer storage medium, characterized in that, A computer program is stored in the storage medium, and when the computer program runs on a computer, the computer is caused to execute the data sharing method according to any one of claims 1 to 10.