File writing method and device of microkernel, electronic equipment and storage medium
By merging file write requests in the microkernel system, the file writing process is optimized, the problem of low write efficiency in the existing technology is solved, and the hardware service life is improved.
Patent Information
- Application Number
- CN202311315735.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-11
- Publication Date
- 2025-04-11
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The data writing schemes in existing microkernel systems have low write efficiency, resulting in reduced hardware service life.
By determining the target address and storage space of the file to be written, a write request is established and added to the write sequence. According to whether the existing write request target address in the write sequence is logically adjacent to the target address of the file to be written, the write request is merged, and the merged write request is finally sent to the driver for file writing.
Improves file writing efficiency, reduces the number of interactions between drivers and hardware, and extends the service life of hardware.
Smart Images

Figure CN119806380A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a microkernel file writing method, device, electronic device and storage medium. Background Art
[0002] In a microkernel system, according to the existing data writing scheme, it is necessary to obtain the corresponding medium physical address according to the file logical address, convert the file data into a write request, and then write the physical address data through the driver. The entire file writing process is direct, and each write request is sent directly to the driver, and different write requests are independent and unrelated. In this way, the data of several write requests needs to be written several times, and the corresponding driver issues several write commands to interact with the hardware. This will result in a very low write efficiency and greatly reduce the service life of the hardware. Summary of the invention
[0003] In view of this, the present application provides a microkernel file writing method, device, electronic device and storage medium, which can solve the problem of low writing efficiency of current data writing solutions and at the same time improve the service life of hardware.
[0004] In a first aspect, the present application provides a file writing method of a microkernel, comprising:
[0005] Determine the target address and storage space corresponding to the physical medium in which the file to be written is written;
[0006] Establishing a write request for the file to be written according to the target address and the storage space, and adding the request to the write sequence;
[0007] According to the target addresses of the existing write requests in the write sequence, and depending on whether the target addresses of the existing write requests and the target address of the file to be written have a logically adjacent relationship, merging the write request of the file to be written with the existing write requests in the write sequence;
[0008] Send the merged write request to the driver to write the file.
[0009] Optionally, determining a target address and storage space corresponding to writing the file to be written into a physical medium includes:
[0010] Detect the space status of each storage space in the current physical medium;
[0011] When it is detected that the current space state is idle, the target storage space in the idle state is written into the corresponding storage space in the physical medium as the file to be written, and the address of the target storage space is written into the corresponding target address in the physical medium as the file to be written.
[0012] Optionally, the merging the write request of the file to be written with the existing write request in the write sequence according to the target address of the existing write request in the write sequence and whether the target address of the existing write request has a logically adjacent relationship with the target address of the file to be written, comprises:
[0013] Querying whether there is a write request logically adjacent to the target address of the file to be written in the target address of the write request in the write sequence; wherein the logical adjacency includes that the target address corresponding to the file to be written is adjacent to the target address in the physical medium for writing another file;
[0014] If so, the write request for the file to be written is merged with the logically adjacent write request.
[0015] Optionally, sending the merged write request to a driver to write the file includes:
[0016] According to the sum of the storage spaces of all the write requests in the current write sequence, determining whether to send all the write requests in the write sequence to the driver for file writing;
[0017] Among them, all write requests include the merged write request.
[0018] Optionally, judging whether to send all the write requests in the write sequence to the driver for file writing according to the sum of the storage spaces of all the write requests in the current write sequence includes:
[0019] Determining whether the sum of the storage spaces of all write requests in the write sequence exceeds a preset threshold;
[0020] When the sum of the storage spaces of all write requests in the write sequence exceeds the preset threshold, all write requests in the current write sequence are retrieved in order and sent to the driver for file writing.
[0021] Optionally, sending the merged write request to a driver to write the file further includes:
[0022] Establishing a timing function with a preset execution interval period, and using the timing function to send all write requests in the write sequence to the driver for file writing;
[0023] Among them, all write requests include the merged write request, and the timing function sequentially retrieves all write requests in the current write sequence after the preset time has passed, and sends them to the driver.
[0024] Optionally, sending the merged write request to a driver to write the file further includes:
[0025] In response to a user instruction, the interface function is called to sequentially retrieve all write requests in the current write sequence and send them to the driver for file writing;
[0026] Among them, all write requests include the merged write request.
[0027] In a second aspect, the present application provides a microkernel file writing device, comprising:
[0028] A determination unit, configured to determine a target address and storage space corresponding to the physical medium in which the file to be written is written;
[0029] a processing unit, configured to establish a write request for the file to be written according to the target address and the storage space, and add the request to a write sequence;
[0030] a merging unit configured to merge the write request of the file to be written with the existing write request in the write sequence according to the target address of the existing write request in the write sequence and whether the target address of the existing write request has a logical adjacent relationship with the target address of the file to be written;
[0031] The sending unit is configured to send the merged write request to the driver to write the file.
[0032] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the file writing method of the microkernel described in the first aspect.
[0033] In a fourth aspect, the present application provides an electronic device, comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements the file writing method of the microkernel described in the first aspect when executing the computer program.
[0034] By means of the above technical scheme, the present application provides a microkernel file writing method, device, electronic device and storage medium, first determining the target address and storage space corresponding to the file to be written in the physical medium, and then establishing a write request for the file to be written according to the target address and storage space, and adding it to the write sequence. In the merging step, according to the target address of the existing write request in the write sequence, the write request of the file to be written is merged with the existing write request in the write sequence, and finally the merged write request is sent to the driver for file writing. Compared with the related art, the present application optimizes the process of writing files to physical media in the microkernel system, and can merge write requests according to the target addresses of different write requests, so that the driver can write the data corresponding to the merged write request to the physical medium together, thereby avoiding the situation where the driver interacts with the hardware multiple times during the writing process, solving the problem of low writing efficiency of the current data writing scheme, and at the same time can improve the service life of the hardware.
[0035] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0037] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0038] Figure 1 A schematic diagram showing a process flow of a file writing method of a microkernel provided in an embodiment of the present application;
[0039] Figure 2 A schematic diagram showing the logical location of a file in a file system provided by an embodiment of the present application;
[0040] Figure 3 A schematic diagram showing a physical address of file data in a medium provided by an embodiment of the present application;
[0041] Figure 4 A schematic diagram showing a flow chart of another microkernel file writing method provided in an embodiment of the present application;
[0042] Figure 5 A schematic structural diagram of a microkernel file writing device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0043] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the scheme of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.
[0044] In order to solve the problem of low writing efficiency of current data writing schemes and to improve the service life of hardware, this embodiment proposes a microkernel file writing method, which optimizes the process of writing files to physical media in the microkernel system, and can merge write requests according to the target addresses of different write requests, so that the driver can write the data corresponding to the merged write requests to the physical medium together, thereby avoiding multiple interactions between the driver and the hardware during the writing process, solving the problem of low writing efficiency of current data writing schemes and improving the service life of hardware.
[0045] like Figure 1 As shown, the method includes:
[0046] S101, determining a target address and storage space corresponding to a file to be written into a physical medium.
[0047] Among them, the file to be written refers to the file that needs to be stored and written to the physical medium. First, it is necessary to determine the target address and storage space corresponding to the file being written to the physical medium. In actual scenarios, this step can be specifically exemplified by using the file system process (usually also called the FS process) to convert the write address length of the file into the address length of the physical medium according to the data arrangement of the file in the current file system and the current free space in the physical medium. In this way, the target address and storage space corresponding to the file to be written in the physical medium are determined. For example, Figure 2 In the file system, the logical positions of files are arranged from 1-1 to 2-4 in order, that is, the data arrangement of files in the current file system is basically in a certain logical order, but when writing to the medium, it is stored according to whether there is free storage space in the physical address, which is easy to cause the order to be disrupted. The storage space here includes the size of the space occupied by the file stored in the physical medium. In the subsequent steps, whether to clear the write sequence will be determined based on the storage space.
[0048] S102, establishing a write request for a file to be written according to the target address and the storage space, and adding it to a write sequence.
[0049] According to the determined target address and storage space, a write request for the file to be written is established. It should be noted here that if the file to be written contains a lot of data or a large capacity, it may contain multiple data corresponding to multiple target addresses. Generally speaking, the number of write requests corresponds to the target address one by one, that is, the file to be written may be split into multiple target addresses for storage, but each target address will generate a corresponding write request so that the driver can identify and write to the target address.
[0050] S103, according to the target addresses of the existing write requests in the write sequence, and depending on whether the target addresses of the existing write requests and the target address of the file to be written have a logically adjacent relationship, merging the write request of the file to be written with the existing write requests in the write sequence.
[0051] After the write request of the file to be written is placed in the write sequence, there may already be write requests for other files in the write sequence. At this time, the write requests of the file to be written will be merged according to the target address of the write request.
[0052] S104, sending the combined write request to the driver to write the file.
[0053] This process is that the driver writes the data file corresponding to the write request to the physical address that needs to be stored according to the write request after the merge processing.
[0054] In this embodiment, the target address and storage space corresponding to the file to be written in the physical medium are first determined, and then a write request for the file to be written is established according to the target address and storage space, and added to the write sequence. In the merging step, the write request for the file to be written is merged with the existing write request in the write sequence according to the target address of the write request already in the write sequence, and finally the merged write request is sent to the driver for file writing. Compared with the related art, this embodiment optimizes the process of writing files to physical media in the microkernel system, and can merge write requests according to the target addresses of different write requests, so that the driver can write the data corresponding to the merged write request to the physical medium together, thereby avoiding the situation where the driver interacts with the hardware multiple times during the writing process, solving the problem of low writing efficiency of the current data writing scheme, and at the same time can improve the service life of the hardware.
[0055] Optionally, determining the target address and storage space corresponding to the file to be written in the physical medium includes: detecting the space status of each storage space in the current physical medium; when it is detected that the current space status is idle, writing the target storage space in the idle state as the file to be written into the corresponding storage space in the physical medium, and writing the address of the target storage space as the target address corresponding to the file to be written into the physical medium.
[0056] In this embodiment, the space status of each storage space in the physical medium is first detected. When free space is detected, the free target storage space is written as the file to be written into the storage space corresponding to the physical medium, and the address of the target storage space is written as the target address corresponding to the file to be written into the physical medium. Specifically, the file system process converts the write address length of the file into the address length of the physical medium according to the data arrangement of the file in the current file system and the current free space in the physical medium. In this way, the target address and storage space corresponding to the file to be written in the physical medium are determined. For example, the data arrangement logic of a certain file corresponds to Figure 2 1-1 to 1-4 in the figure will be converted accordingly according to the arrangement logic before writing to the medium to determine the target address and storage space for writing the file to be written to the physical medium.
[0057] Optionally, based on the target addresses of existing write requests in the write sequence and whether the target addresses of the existing write requests and the target address of the file to be written have a logically adjacent relationship, the write request for the file to be written and the existing write requests in the write sequence are merged, including: querying whether there is a write request that is logically adjacent to the target address of the file to be written among the target addresses of the existing write requests in the write sequence; wherein logical proximity includes that the file to be written is adjacent to the corresponding target addresses in the physical medium for writing another file; if so, merging the write request for the file to be written and the logically adjacent write requests.
[0058] In this embodiment, the process of merging write requests is described. After adding the write request of the file to be written to the write sequence, it is queried whether there is a write request logically adjacent to the target address of the file to be written in the target address of the write request already in the write sequence. If so, the write requests of the two are merged, thereby reducing the steps that the driver needs to perform multiple writes according to each write request, thereby improving the writing efficiency.
[0059] Optionally, sending the merged write request to the driver for file writing includes: judging whether to send all write requests in the write sequence to the driver for file writing based on the sum of the storage space of all write requests in the current write sequence; wherein all write requests include the merged write request.
[0060] In this embodiment, in addition to merging the write requests, the solution of this embodiment also provides a selection based on the interaction between the merged write requests and the driver. Specifically, it can include judging whether to send to the driver for file writing based on the sum of the storage space of all write requests in the current write sequence. The storage space of all write requests in the current write sequence is used as the basis for clearing the write sequence, that is, the judgment basis for interacting with the driver to write the file, so that the write requests in the write sequence can be cleared in time, thereby improving the writing efficiency.
[0061] Optionally, based on the sum of the storage space of all write requests in the current write sequence, it is determined whether to send all the write requests in the write sequence to the driver for file writing, including: determining whether the sum of the storage space of all write requests in the write sequence exceeds a preset threshold; if the sum of the storage space of all write requests in the write sequence exceeds the preset threshold, retrieving all the write requests in the current write sequence in order and sending them to the driver for file writing.
[0062] In this embodiment, the case of determining whether to send to the driver for file writing according to the storage space of all write requests in the current write sequence is further described. For example, the preset threshold can be set to 1MB, and when the sum of the storage space of all write requests in the write sequence exceeds the preset threshold, all write requests in the current write sequence are sequentially taken out and sent to the driver for file writing, thereby improving the writing efficiency.
[0063] Optionally, sending the merged write request to the driver program for file writing also includes: establishing a timing function with an execution interval period of a preset duration, and using the timing function to send all write requests in the write sequence to the driver program for file writing; wherein all write requests include the merged write request, and the timing function sequentially retrieves all write requests in the current write sequence after the preset duration has passed, and sends them to the driver program.
[0064] In this embodiment, another situation of interacting with the driver based on the merged write request is proposed. Through the timing function, the driver can be interacted with at every preset time interval to write the write request in the write sequence. The preset time can be set to 30 seconds, that is, the write request in the write sequence is interacted every 30 seconds, and the data therein is written to the physical medium, thereby improving the writing efficiency.
[0065] Optionally, sending the merged write request to the driver for file writing also includes: responding to user instructions, calling an interface function, sequentially retrieving all write requests in the current write sequence, and sending them to the driver for file writing; wherein all write requests include the merged write request.
[0066] In this embodiment, it is mentioned that the user can also manually call the interface function to take out all write requests in the current write sequence as needed and send them to the driver to write the file. In actual application scenarios, the FS process can provide an interface (application programming interface, API) for manually flushing the file write queue. After calling the API, the write requests under the write queue of the corresponding file will be taken out in sequence and sent to the driver, allowing the driver to write to the corresponding medium. This improves the writing efficiency.
[0067] Next, combine Figure 2 and Figure 3 The file writing method of the kernel proposed in this embodiment is described as an example. First, the overall technical background is introduced. Figure 2 As shown in the figure, the logical position of the file in the system is shown. The data of the same file is logically continuous, that is, 1-1 to 1-4 are all 4 data of file 1, and the same is true for file 2. However, when stored in the physical medium, it is allocated according to the free space of the physical medium at that time, which is basically out of order. This results in that even the data corresponding to the same file may be stored in different locations in the physical medium, such as Figure 3 As shown, after the target address is determined and stored in the corresponding medium, the storage positions of 1-1, 1-2, 1-3, and 1-4 are not continuous. Among them, "#" indicates that the address is occupied by other files.
[0068] against Figure 3 There are two additional points to note here. The first is that physical addresses are not always the same in practice. Figure 3 The grid shown, and there are also horizontally adjacent and vertically adjacent situations. Figure 3 It is only a schematic diagram of the physical address of the file data in the medium. In reality, there is no horizontal or vertical contiguous situation, but the target address is adjacent in the medium. The second point is that normally, the file data is written sequentially. For example, we write 1-1 and 1-2. Then after 1-1 is written, 1-2 should be written, but 2-1 is written in the position of 1-2. 1-2 can only be placed in other positions. The reason is that when writing 1-2, Figure 3 The position 2-1 was occupied by data at that time, and when data 2-1 was stored, the data originally stored in the position had been taken out, so the position was vacant, so 2-1 could be stored. This is also consistent with the data writing process mentioned above, which is written according to the idle situation of the physical medium.
[0069] Combined with the above background, according to the existing file data writing scheme, Figure 3There are 8 write requests before writing, corresponding to 1-1 to 2-4. After the write requests are merged by the file writing method of the microkernel mentioned in the above embodiment, there are 4 merged write requests, namely 1-2 and 2-1, 2-2 and 2-3 and 2-4, 1-2, 2-4 and 1-4. Among them, 1-2 and 2-1 are logically adjacent to the target addresses of two data stored in the physical medium. In this case, the driver only needs to interact with the hardware 4 times to write the file, thereby greatly improving the writing efficiency and increasing the service life of the hardware.
[0070] like Figure 4 FIG. 1 shows another microkernel file writing method provided by this embodiment, and introduces several situations of interacting with the driver based on the merged write request, including:
[0071] S401, determining a target address and storage space corresponding to a file to be written into a physical medium.
[0072] S402: Create a write request for the file to be written according to the target address and the storage space, and add it to the write sequence.
[0073] S403: Merge the write request for the file to be written with the existing write request in the write sequence according to the target address of the existing write request in the write sequence.
[0074] S4041: When the sum of the storage space exceeds a preset threshold, all write requests are retrieved in order and sent to the driver.
[0075] S4042, using the timing function, sending the merged write request to the driver.
[0076] The timing function sequentially retrieves all write requests in the current write sequence after a preset time has passed, and sends them to the driver.
[0077] S4043, calling the interface function in response to the user instruction, taking out all write requests in sequence, and sending them to the driver.
[0078] In this embodiment, several situations in which the merged write request interacts with the driver are described. Specifically, as in S4041, it can be determined whether the sum of the storage space of all write requests in the write sequence exceeds the preset threshold. If the sum of the storage space of all write requests in the write sequence exceeds the preset threshold, all write requests in the current write sequence are taken out in order and sent to the driver for file writing. S4042, the merged write request can be sent to the driver using a timing function. Among them, the timing function takes out all the write requests in the current write sequence in order after a preset time has passed, and sends them to the driver. S4043, the user can also manually call the interface function to take out all the write requests in the current write sequence as needed and send them to the driver for file writing. In actual application scenarios, the FS process can provide an interface for manually flushing the file write queue to take out the write requests under the write queue of the corresponding file in sequence and send them to the driver, so that the driver can write to the corresponding medium, thereby improving the writing efficiency.
[0079] Further, as Figures 1 to 4 The specific implementation of the method shown in the embodiment provides a file writing device of a micro-kernel, such as Figure 5 As shown, the device includes: a determining unit 501, a processing unit 502, a merging unit 503 and a sending unit 504.
[0080] The determination unit 501 is configured to determine a target address and storage space corresponding to the physical medium where the file to be written is to be written;
[0081] The processing unit 502 is configured to establish a write request for the file to be written according to the target address and the storage space, and add the request to a write sequence;
[0082] a merging unit 503 configured to merge the write request of the file to be written with the existing write request in the write sequence according to the target address of the existing write request in the write sequence and whether the target address of the existing write request has a logical adjacent relationship with the target address of the file to be written;
[0083] The sending unit 504 is configured to send the merged write request to the driver to write the file.
[0084] In a specific application scenario, the determination unit 501 is specifically configured to determine the data arrangement logic of the file to be written and the free space in the current physical medium when it is detected that there is file data to be written; wherein, determining the free space in the current physical medium includes: detecting the space status of each storage space in the current physical medium; when it is detected that the current space status is an idle state, writing the target storage space in the idle state as the storage space corresponding to the file to be written in the physical medium, and using the address of the target storage space as the target address corresponding to the file to be written in the physical medium.
[0085] In a specific application scenario, the merging unit 503 is further configured to query whether there is a write request logically adjacent to the target address of the file to be written in the target address of the existing write request in the write sequence; wherein the logical adjacency includes the file to be written being adjacent to the corresponding target address in the physical medium for writing another file; if so, the write request of the file to be written is merged with the logically adjacent write request.
[0086] In a specific application scenario, the sending unit 504 is also specifically configured to determine whether to send all write requests in the write sequence to the driver for file writing based on the sum of the storage space of all write requests in the current write sequence; wherein all write requests include the merged write request.
[0087] In a specific application scenario, the sending unit 504 is also specifically configured to determine whether the sum of the storage space of all write requests in the write sequence exceeds a preset threshold; when the sum of the storage space of all write requests in the write sequence exceeds the preset threshold, all write requests in the current write sequence are retrieved in order and sent to the driver for file writing.
[0088] In a specific application scenario, the sending unit 504 is further configured to establish a timing function with an execution interval period of a preset duration, and use the timing function to send all write requests in the write sequence to the driver for file writing; wherein all write requests include the merged write request, and the timing function takes out all write requests in the current write sequence in order after the preset duration has passed, and sends them to the driver.
[0089] In a specific application scenario, the sending unit 504 is further configured to respond to user instructions, call an interface function, sequentially retrieve all write requests in the current write sequence, and send them to the driver for file writing; wherein all write requests include the merged write request.
[0090] It should be noted that for other corresponding descriptions of the functional units involved in the micro-kernel file writing device provided in this embodiment, please refer to Figures 1 to 4 The corresponding description in will not be repeated here.
[0091] Based on the above Figures 1 to 4 The method shown in the embodiment also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned Figures 1 to 4 The method shown.
[0092] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of the present application.
[0093] Based on the above Figures 1 to 4 The method shown, and Figure 5 In order to achieve the above-mentioned purpose, the embodiment of the present application further provides an electronic device, which can be configured on a computer side or a vehicle side, etc. The device includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figures 1 to 4 The method shown.
[0094] Optionally, the above-mentioned physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.
[0095] Those skilled in the art will appreciate that the above-mentioned physical device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different arrangements of components.
[0096] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the above-mentioned physical device, and supports the operation of the information processing program and other software and / or programs. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.
[0097] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform, or by hardware. Compared with the related art, the present application optimizes the process of writing files to physical media in a microkernel system, and can merge write requests according to the target addresses of different write requests, so that the driver can write the data corresponding to the merged write requests to the physical medium together, thereby avoiding the situation where the driver interacts with the hardware multiple times during the writing process, solving the problem of low writing efficiency of the current data writing scheme, and at the same time can improve the service life of the hardware.
[0098] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprises" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0099] The above is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features applied for herein.
Claims
1. A file writing method of a microkernel, characterized in that: include: Determine the target address and storage space corresponding to the physical medium in which the file to be written is written; Establishing a write request for the file to be written according to the target address and the storage space, and adding the request to the write sequence; According to the target addresses of the existing write requests in the write sequence, and depending on whether the target addresses of the existing write requests and the target address of the file to be written have a logically adjacent relationship, merging the write request of the file to be written with the existing write requests in the write sequence; Send the merged write request to the driver to write the file.
2. The method according to claim 1, characterized in that The step of determining a target address and storage space corresponding to writing the file to be written into the physical medium includes: Detect the space status of each storage space in the current physical medium; When it is detected that the current space state is idle, the target storage space in the idle state is written into the corresponding storage space in the physical medium as the file to be written, and the address of the target storage space is written into the corresponding target address in the physical medium as the file to be written.
3. The method according to claim 1, characterized in that The step of merging the write request of the file to be written with the existing write request in the write sequence according to the target address of the existing write request in the write sequence and whether the target address of the existing write request has a logically adjacent relationship with the target address of the file to be written, comprises: Querying whether there is a write request logically adjacent to the target address of the file to be written in the target address of the write request in the write sequence; wherein the logical adjacency includes that the target address corresponding to the file to be written is adjacent to the target address in the physical medium for writing another file; If so, the write request for the file to be written is merged with the logically adjacent write request.
4. The method according to claim 1, characterized in that: The step of sending the merged write request to the driver for writing the file includes: According to the sum of the storage spaces of all the write requests in the current write sequence, determining whether to send all the write requests in the write sequence to the driver for file writing; Among them, all write requests include the merged write request.
5. The method according to claim 4, characterized in that The step of determining whether to send all the write requests in the write sequence to the driver for file writing according to the sum of the storage spaces of all the write requests in the current write sequence comprises: Determining whether the sum of the storage spaces of all write requests in the write sequence exceeds a preset threshold; When the sum of the storage spaces of all write requests in the write sequence exceeds the preset threshold, all write requests in the current write sequence are retrieved in order and sent to the driver for file writing.
6. The method according to claim 1, characterized in that The step of sending the merged write request to the driver for writing the file includes: Establishing a timing function with a preset execution interval period, and using the timing function to send all write requests in the write sequence to the driver for file writing; Among them, all write requests include the merged write request, and the timing function sequentially retrieves all write requests in the current write sequence after the preset time has passed, and sends them to the driver.
7. The method according to claim 1, characterized in that The step of sending the merged write request to the driver for writing the file includes: In response to a user instruction, the interface function is called to sequentially retrieve all write requests in the current write sequence and send them to the driver for file writing; Among them, all write requests include the merged write request.
8. A file writing device of a microkernel, characterized in that: include: A determination unit, configured to determine a target address and storage space corresponding to the physical medium in which the file to be written is written; a processing unit, configured to establish a write request for the file to be written according to the target address and the storage space, and add the request to a write sequence; a merging unit configured to merge the write request of the file to be written with the existing write request in the write sequence according to the target address of the existing write request in the write sequence and whether the target address of the existing write request has a logical adjacent relationship with the target address of the file to be written; The sending unit is configured to send the merged write request to the driver to write the file.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. An electronic device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Method and system for reading and writing user data under virtual environment and physical machine
CN103902348A
Block equipment write IO shaping and multi-controller synchronization system and method
CN106886368A
Access method and device for full-flash memory storage system
CN110209340A