SOC-based file sharing method, system, storage medium and chip
By realizing file sharing between processes in SOC, the problem of high consumption of file sharing resources between cross-domain processes is solved, and efficient file transfer and big data transfer are achieved.
Patent Information
- Application Number
- CN202411442957.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2044-10-16
AI Technical Summary
File sharing between cross-domain processes requires multiple links and multiple copies, resulting in high resource consumption.
By implementing file sharing between processes in SOC, the first process obtains the file handle of the target file, maps its own file structure into shared memory, and the second process creates the corresponding file structure and points to the mapping address of the first process, thereby directly operating the target file.
It reduces the number of links and copies required during file sharing, saves resources, improves transmission rate, and realizes high-speed transmission of big data.
Smart Images

Figure CN118964320B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of chip technology, and in particular to a file sharing method, system, storage medium and chip based on SOC. Background Art
[0002] Different operating systems can be installed between different domains of the System on Chip (SOC), such as Linux and Android. Everything in Linux and Android is a file, even the drivers of some external devices are file nodes, such as input devices (keyboard, touch), output devices (display, serial port log, etc.). If file sharing between cross-domain processes can be opened up, communication can be carried out through files, so that input and output device sharing of multiple domains can be flexibly realized, and functions such as screen projection, cross-domain log output, and cross-domain touch can be flexibly and simply realized.
[0003] like Figure 1 As shown in the figure, process 1 in Domain 1 shares a file with process 2 in Domain 2. Specifically, process 1 copies the file to kernel 1 through the Transmission Control Protocol (TCP), kernel 1 copies the file to link layer 1, link layer 1 copies the file to link layer 2, link layer 2 copies the file to kernel 2, and kernel 2 copies the file to process 2 through TCP.
[0004] File sharing between cross-domain processes requires multiple links and multiple copies, which consumes more resources. Summary of the invention
[0005] The present application provides a SOC-based file sharing method, system, storage medium and chip, which are used to solve the problem that file sharing between cross-domain processes requires multiple links and multiple copies, and consumes a lot of resources. The technical solution is as follows:
[0006] According to a first aspect of the present application, a SOC-based file sharing method is provided, which is used in a SOC including at least two domains, and the method includes:
[0007] When a first process in a first domain shares a target file with a second process in a second domain, the first process obtains a file handle of the target file, where the file handle is used to identify the target file;
[0008] The first process maps its own first file structure into the shared memory to obtain a first mapping address, wherein the first file structure is used to operate the target file;
[0009] The second process creates a second file structure;
[0010] The second process obtains the first mapping address, points the second file structure to the first mapping address, and operates the target file according to the file handle through the second file structure.
[0011] In a possible implementation, the first domain further includes a first shared file system and a first file system manager, and the second domain further includes a second shared file system and a second file system manager; and the method further includes:
[0012] The first process is registered in the first file system manager through the first shared file system;
[0013] The first shared file system synchronizes the registration information of the first process to the second file system manager through the second shared file system;
[0014] The second process is registered in the second file system manager through the second shared file system;
[0015] The second shared file system synchronizes the registration information of the second process to the first file system manager through the first shared file system.
[0016] In a possible implementation manner, the second process obtaining the first mapping address includes:
[0017] The second process requests the first mapping address from the first file system manager;
[0018] The first file system manager maps the first mapping address into a shared memory, and sends the obtained second mapping address to the second process;
[0019] The second process obtains the first mapping address according to the second mapping address.
[0020] In a possible implementation manner, the second process requests the first file system manager for the first mapping address, including:
[0021] The second process requests the first mapping address from the second file system manager through the second shared file system;
[0022] The second file system manager requests the first mapping address from the first file system manager through the first shared file system.
[0023] In a possible implementation manner, sending the obtained second mapping address to the second process includes:
[0024] The first file system manager sends the obtained second mapping address to the second file system manager;
[0025] The second file system manager sends the second mapping address to the second process through the second shared file system.
[0026] In a possible implementation, the first process maps its own first file structure into a shared memory to obtain a first mapping address, including:
[0027] The first process maps its own first file structure to a shared memory pre-allocated in the memory to obtain a first mapping address; or,
[0028] The first process maps its own first file structure into the memory of the mailbox Mailbox to obtain a first mapping address.
[0029] In a possible implementation manner, the shared file system is Sharefs, and the file system manager is Fsmanager.
[0030] According to a second aspect of the present application, there is provided a SOC-based file sharing system for use in a SOC, wherein the SOC includes at least two domains;
[0031] When a first process in a first domain shares a target file with a second process in a second domain, the first process is used to obtain a file handle of the target file, where the file handle is used to identify the target file;
[0032] The first process is further used to map its own first file structure into the shared memory to obtain a first mapping address, and the first file structure is used to operate the target file;
[0033] The second process is used to create a second file structure;
[0034] The second process is further used to obtain the first mapping address, point the second file structure to the first mapping address, and operate the target file according to the file handle through the second file structure.
[0035] According to a third aspect of the present application, a computer-readable storage medium is provided, wherein at least one instruction is stored in the storage medium, and the at least one instruction is loaded and executed by a processor to implement the SOC-based file sharing method as described above.
[0036] According to a fourth aspect of the present application, a chip is provided, wherein the chip includes the above-mentioned SOC-based file sharing system.
[0037] The beneficial effects of the technical solution provided by this application include at least:
[0038] The first process in the first domain can obtain the file handle of the target file, map its own first file structure to the shared memory, and obtain the first mapping address; the second process in the second domain can create a second file structure, obtain the first mapping address, point the second file structure to the first mapping address, and operate the target file according to the file handle through the second file structure, so that the two cross-domain processes can communicate through the shared file, and there is no need to go through multiple links and multiple copies during the sharing process, which not only saves resources, but also improves the transmission rate, and can also achieve high-speed transmission of large data.
[0039] By mapping the file structure into the Mailbox memory, the security of inter-process data communication can be provided. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0041] Figure 1 It is a schematic diagram of a process of cross-domain file sharing according to the related technology;
[0042] Figure 2 is a schematic diagram of the structure of a SOC provided by an embodiment of the present application;
[0043] Figure 3 is a flow chart of a SOC-based file sharing method provided by an embodiment of the present application;
[0044] Figure 4 This is a flowchart of a SOC-based file sharing method provided by an embodiment of the present application. DETAILED DESCRIPTION
[0045] In order to make the objectives, technical solutions and advantages of the embodiments of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.
[0046] The system on chip (SOC) includes multiple domains and mailboxes. The data in each domain is stored in a memory. The number of domains and the specific type of memory are not limited in this application. For ease of understanding, Figure 2In the example, two domains include a first domain (Domain 1) 210 and a second domain (Domain 2) 220, and the memory is a double data rate (Double Data Rate, DDR) memory.
[0047] Each domain corresponds to a kernel, which includes file nodes (input, output and other devices), a shared file system ( / Dev / Sharefs), a file system manager (Fsmanager) and multiple processes. The number of processes is not limited in this application. For the sake of distinction, the process in the first domain 210 is called the first process 211, and the process in the second domain 220 is called the second process 221; the shared file system in the first domain 210 is called the first shared file system 212, and the file system manager in the first domain 210 is called the first file system manager 213; the shared file system in the second domain 220 is called the second shared file system 222, and the file system manager in the second domain 220 is called the second file system manager 223.
[0048] When multiple processes are created in a domain, the process names in Domain1 are recorded as D1_Process1 and D1_Process2; the process names in Domain1 are recorded as D2_Process1 and D2_Process2 to distinguish them.
[0049] The process and Sharefs communicate through system calls (Input / Output Control, IOCTL), Sharefs communicate with Fsmanager through IOCTL, and Sharefs in different domains communicate through Mailbox. Each Sharefs stores data in the shared memory in DDR or in the memory of Mailbox.
[0050] like Figure 3 As shown, it shows a method flow chart of a SOC-based file sharing method provided by an embodiment of the present application. The SOC-based file sharing method can be applied to Figure 2 The SOC-based file sharing method may include:
[0051] Step 301: When a first process in a first domain shares a target file with a second process in a second domain, the first process obtains a file handle of the target file, where the file handle is used to identify the target file.
[0052] A plurality of files are stored in the file node. In this embodiment, the file that the first process wants to share this time is referred to as a target file.
[0053] The first process may call a file operation function to open a target file in a file node and obtain a file handle of the target file.
[0054] Step 302: The first process maps its own first file structure into the shared memory to obtain a first mapping address. The first file structure is used to operate the target file.
[0055] For the sake of distinction, in this embodiment, the file structure created by the first process is referred to as a first file structure, and the file structure created by the second process is referred to as a second file structure.
[0056] Shared memory is memory that can be accessed by processes in multiple domains in a SOC.
[0057] The first process needs to call the first file structure so that the first file structure can operate the file according to the file handle.
[0058] Step 303: The second process creates a second file structure.
[0059] The second file structure is a file structure that needs to open the target file shared by the first process.
[0060] Step 304: the second process obtains the first mapping address, points the second file structure to the first mapping address, and operates the target file according to the file handle through the second file structure.
[0061] To summarize, in the SOC-based file sharing method provided by the embodiment of the present application, the first process in the first domain can obtain the file handle of the target file, map its own first file structure to the shared memory, and obtain the first mapping address; the second process in the second domain can create a second file structure, obtain the first mapping address, point the second file structure to the first mapping address, and operate the target file according to the file handle through the second file structure, so that two cross-domain processes can communicate through shared files, and there is no need to go through multiple links and multiple copies during the sharing process, which not only saves resources but also improves the transmission rate and can also realize high-speed transmission of large data.
[0062] By mapping the file structure into the Mailbox memory, the security of inter-process data communication can be provided.
[0063] like Figure 4 As shown, it shows a flowchart of a SOC-based file sharing method provided by an embodiment of the present application. The SOC-based file sharing method can be applied to Figure 2 The SOC-based file sharing method may include:
[0064] Step 401: When a first process in a first domain shares a target file with a second process in a second domain, the first process obtains a file handle of the target file, where the file handle is used to identify the target file.
[0065] A plurality of files are stored in the file node. In this embodiment, the file that the first process wants to share this time is referred to as a target file.
[0066] The first process may call a file operation function to open a target file in a file node and obtain a file handle of the target file.
[0067] Before sharing the target file, the first process and the second process need to be registered in the file system manager in their respective domains. In this embodiment, the registration order of the first process and the second process is not limited, that is, the execution order of steps 402-403 and steps 405-406 is not limited.
[0068] Step 402: A first process is registered in a first file system manager via a first shared file system.
[0069] The first process may send registration information to the first shared file system, the registration information carrying the process identifier of the first process; the first shared file system forwards the registration information to the first file system manager; the first file system manager stores the registration information of the first process. The shared file system may be Sharefs, and the file system manager may be Fsmanager.
[0070] Step 403: The first shared file system synchronizes the registration information of the first process to the second file system manager through the second shared file system.
[0071] The first shared file system obtains the process identifier of the first process and the domain identifier of the first domain, generates registration information carrying the process identifier and the domain identifier, and sends the registration information to the second shared file system. The second shared file system forwards the registration information to the second file system manager, and the second file system manager stores the registration information.
[0072] Step 404: the first process maps its own first file structure into the shared memory to obtain a first mapping address. The first file structure is used to operate the target file.
[0073] For the sake of distinction, in this embodiment, the file structure created by the first process is referred to as a first file structure, and the file structure created by the second process is referred to as a second file structure.
[0074] The first process needs to call the first file structure so that the first file structure can operate the file according to the file handle.
[0075] Shared memory is memory that can be accessed by processes in multiple domains in the SOC. The shared memory can be memory pre-allocated on the storage device or the memory of the Mailbox. Specifically, the first process can map its own first file structure to the pre-allocated shared memory in the storage device to obtain a first mapping address; or the first process can map its own first file structure to the memory of the Mailbox to obtain a first mapping address.
[0076] Generally speaking, the storage space of the shared memory of the storage device is larger than the storage space of the memory of the Mailbox. Therefore, when a large amount of data needs to be shared, the shared memory of the storage device can be selected; when a small amount of data needs to be shared, the memory of the Mailbox can be selected. Of course, other aspects can also be considered to determine which shared memory to use, which is not limited in this embodiment.
[0077] Step 405: The second process is registered in the second file system manager through the second shared file system.
[0078] The second process may send registration information to the second shared file system, the registration information carrying the process identifier of the second process; the second shared file system forwards the registration information to the second file system manager; the second file system manager stores the registration information of the second process.
[0079] Step 406: The second shared file system synchronizes the registration information of the second process to the first file system manager through the first shared file system.
[0080] The second shared file system obtains the process ID of the second process and the domain ID of the second domain, generates registration information carrying the process ID and the domain ID, and sends the registration information to the first shared file system. The first shared file system forwards the registration information to the first file system manager, and the first file system manager stores the registration information.
[0081] Step 407: The second process creates a second file structure.
[0082] The second file structure is a file structure that needs to open the target file shared by the first process.
[0083] The second process itself also has a third file structure, and the second process can call the third file structure to operate the file on the file node corresponding to the second process. When the second process needs to share files with other processes, the third file structure can be mapped to the shared memory, and the obtained third mapping address can be shared with other processes, so that other processes can operate the files shared by the second process according to the third mapping address.
[0084] Step 408: The second process requests the first mapping address from the second file system manager through the second shared file system.
[0085] The second process initiates an address acquisition request for the first mapping address to the second file system manager through the second shared file system. The address acquisition request includes at least the process identifier of the first process and may also include the domain identifier of the first domain.
[0086] Step 409: The second file system manager requests the first mapping address from the first file system manager through the first shared file system.
[0087] The second file system manager sends the address acquisition request to the second shared file system. The second shared file system initiates an address acquisition request for the first mapping address to the first file system manager through the first shared file system. The address acquisition request includes the process identifier of the first process.
[0088] Step 410: The first file system manager maps the first mapping address into the shared memory, and sends the obtained second mapping address to the second file system manager.
[0089] The first file system manager determines the registered first process according to the process identifier in the address acquisition request, obtains the first mapping address from the first process, maps the first mapping address to the shared memory of the storage device or the memory of the Mailbox, and sends the obtained second mapping address to the second file system manager through the second shared file system.
[0090] Step 411: The second file system manager sends the second mapping address to the second process through the second shared file system.
[0091] Step 412: The second process obtains the first mapping address according to the second mapping address.
[0092] The second process reads the first mapping address in the storage space corresponding to the second mapping address.
[0093] Step 413: The second process points the second file structure to the first mapping address, and operates the target file according to the file handle through the second file structure.
[0094] To summarize, in the SOC-based file sharing method provided by the embodiment of the present application, the first process in the first domain can obtain the file handle of the target file, map its own first file structure to the shared memory, and obtain the first mapping address; the second process in the second domain can create a second file structure, obtain the first mapping address, point the second file structure to the first mapping address, and operate the target file according to the file handle through the second file structure, so that two cross-domain processes can communicate through shared files, and there is no need to go through multiple links and multiple copies during the sharing process, which not only saves resources but also improves the transmission rate and can also realize high-speed transmission of large data.
[0095] By mapping the file structure into the Mailbox memory, the security of inter-process data communication can be provided.
[0096] like Figure 2 As shown, it shows a structural block diagram of a file sharing system based on SOC provided by an embodiment of the present application, and the SOC includes at least two domains, namely a first domain 210 and a second domain 220;
[0097] When the first process 211 in the first domain 210 shares a target file with the second process 221 in the second domain 220, the first process 211 is used to obtain a file handle of the target file, where the file handle is used to identify the target file;
[0098] The first process 211 is further used to map its own first file structure into the shared memory to obtain a first mapping address, and the first file structure is used to operate the target file;
[0099] The second process 221 is used to create a second file structure;
[0100] The second process 221 is further used to obtain the first mapping address, point the second file structure to the first mapping address, and operate the target file according to the file handle through the second file structure.
[0101] In an optional embodiment, the first domain 210 further includes a first shared file system 212 and a first file system manager 213, and the second domain 220 further includes a second shared file system 222 and a second file system manager 223;
[0102] The first process 211 is further used to register in the first file system manager 213 through the first shared file system 212;
[0103] The first shared file system 212 is further used to synchronize the registration information of the first process 211 to the second file system manager 223 through the second shared file system 222;
[0104] The second process 221 is further used to register in the second file system manager 223 through the second shared file system 222;
[0105] The second shared file system 222 is further used to synchronize the registration information of the second process 221 to the first file system manager 213 through the first shared file system 212 .
[0106] In an optional embodiment, the second process 221 is further used to request the first mapping address from the first file system manager 213;
[0107] The first file system manager 213 is further used to map the first mapping address into the shared memory, and send the obtained second mapping address to the second process 221;
[0108] The second process 221 is further configured to obtain the first mapping address according to the second mapping address.
[0109] In an optional embodiment, the second process 221 is further used to request the first mapping address from the second file system manager 223 through the second shared file system 222;
[0110] The second file system manager 223 is further configured to request the first mapping address from the first file system manager 213 through the first shared file system 212 .
[0111] In an optional embodiment, the first file system manager 213 is further configured to send the obtained second mapping address to the second file system manager 223;
[0112] The second file system manager 223 is further configured to send the second mapping address to the second process 221 through the second shared file system 222 .
[0113] In an optional embodiment, the first process 211 is further used to:
[0114] Mapping the first file structure of the device to the shared memory pre-allocated in the memory to obtain a first mapping address; or,
[0115] Map its own first file structure into the memory of the mailbox Mailbox to obtain a first mapping address.
[0116] In an optional embodiment, the shared file system is Sharefs, and the file system manager is Fsmanager.
[0117] To summarize, in the SOC-based file sharing system provided by the embodiment of the present application, the first process in the first domain can obtain the file handle of the target file, map its own first file structure to the shared memory, and obtain the first mapping address; the second process in the second domain can create a second file structure, obtain the first mapping address, point the second file structure to the first mapping address, and operate the target file according to the file handle through the second file structure, so that two cross-domain processes can communicate through shared files, and there is no need to go through multiple links and multiple copies during the sharing process, which not only saves resources but also improves the transmission rate and can also realize high-speed transmission of large data.
[0118] By mapping the file structure into the Mailbox memory, the security of inter-process data communication can be provided.
[0119] An embodiment of the present application provides a computer-readable storage medium, wherein the storage medium stores at least one instruction, and the at least one instruction is loaded and executed by a processor to implement the SOC-based file sharing method as described above.
[0120] An embodiment of the present application provides a chip, wherein the chip includes any of the above-mentioned SOC-based file sharing systems.
[0121] It should be noted that: the SOC-based file sharing system provided in the above embodiment only uses the division of the above functional modules as an example when performing SOC-based file sharing. In actual applications, the above functional distribution can be completed by different functional modules as needed, that is, the internal structure of the SOC-based file sharing system is divided into different functional modules to complete all or part of the functions described above. In addition, the SOC-based file sharing system provided in the above embodiment and the SOC-based file sharing method embodiment belong to the same concept. The specific implementation process is detailed in the method embodiment and will not be repeated here.
[0122] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.
[0123] The above description is not intended to limit the embodiments of the present application. Any adjustments, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the protection scope of the embodiments of the present application.
Claims
1. A file sharing method based on SOC, characterized in that: For use in a SOC comprising at least two domains, the method comprises: When a first process in a first domain shares a target file in a first file node with a second process in a second domain, the first process obtains a file handle of the target file, where the file handle is used to identify the target file, and the first file node is a file node in the first domain; The first process maps its own first file structure into the shared memory to obtain a first mapping address, and the first file structure can be called by the first process so as to operate the target file according to the file handle; The second process creates a second file structure; The second process obtains the first mapping address, points the second file structure to the first mapping address, and operates the target file according to the file handle through the second file structure; The first domain further includes a first shared file system and a first file system manager, and the second domain further includes a second shared file system and a second file system manager; the method further includes: The first process is registered in the first file system manager through the first shared file system; The first shared file system synchronizes the registration information of the first process to the second file system manager through the second shared file system; The second process is registered in the second file system manager through the second shared file system; The second shared file system synchronizes the registration information of the second process to the first file system manager through the first shared file system; The second process obtains the first mapping address, including: The second process requests the first mapping address from the second file system manager through the second shared file system; The second file system manager requests the first mapping address from the first file system manager through the first shared file system; The first file system manager maps the first mapping address to a shared memory, and sends the obtained second mapping address to the second file system manager; The second file system manager sends the second mapping address to the second process through the second shared file system; The second process obtains the first mapping address according to the second mapping address.
2. The SOC-based file sharing method according to claim 1, characterized in that: The first process maps its own first file structure into the shared memory to obtain a first mapping address, including: The first process maps its own first file structure to a shared memory pre-allocated in the memory to obtain a first mapping address; or, The first process maps its own first file structure into the memory of the mailbox Mailbox to obtain a first mapping address.
3. The SOC-based file sharing method according to claim 1 or 2, characterized in that: The first shared file system and the second shared file system are Sharefs, and the first file system manager and the second file system manager are Fsmanager.
4. A file sharing system based on SOC, characterized in that: Used in a SOC, the SOC comprising at least two domains; When a first process in a first domain shares a target file in a first file node with a second process in a second domain, the first process is used to obtain a file handle of the target file, where the file handle is used to identify the target file, and the first file node is a file node in the first domain; The first process is further used to map its own first file structure into the shared memory to obtain a first mapping address, and the first file structure can be called by the first process to operate the target file according to the file handle; The second process is used to create a second file structure; The second process is further used to obtain the first mapping address, point the second file structure to the first mapping address, and operate the target file according to the file handle through the second file structure; The first domain further includes a first shared file system and a first file system manager, and the second domain further includes a second shared file system and a second file system manager; the first process is further used to register in the first file system manager through the first shared file system; The first shared file system is used to synchronize the registration information of the first process to the second file system manager through the second shared file system; The second process is further used to register in the second file system manager through the second shared file system; The second shared file system is used to synchronize the registration information of the second process to the first file system manager through the first shared file system; The second process is further configured to request the first mapping address from the second file system manager through the second shared file system; The second file system manager is configured to request the first mapping address from the first file system manager through the first shared file system; The first file system manager is used to map the first mapping address into a shared memory, and send the obtained second mapping address to the second file system manager; The second file system manager is further configured to send the second mapping address to the second process through the second shared file system; The second process is further used to obtain the first mapping address according to the second mapping address.
5. A computer-readable storage medium, characterized in that: The storage medium stores at least one instruction, and the at least one instruction is loaded and executed by the processor to implement the SOC-based file sharing method according to any one of claims 1 to 3.
6. A chip, characterized in that: The chip includes: the SOC-based file sharing system as described in claim 4.
Citation Information
Patent Citations
Inter-process communication method and related equipment
CN113495795A
File sharing method and terminal device
CN113672576A
Inter-process communication method, system and chip based on multi-core heterogeneous SOC
CN118113496A
