Operation system data copying method and device based on multiple cache regions, equipment, medium and product

The multi-cache solution solves the performance problems during operating system data replication, realizes efficient data copying, avoids performance degradation and accidents caused by locks or interrupts, facilitates system evaluation and diagnosis, and supports customized cache configuration.

CN120371560APending Publication Date: 2025-07-25谢文韬
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410176346.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-02-08
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

When existing operating systems copy data from the kernel to the user state, long-term lock or shutdown interrupts lead to performance degradation and may even cause accidents. The existing tuning tools have problems such as performance impact and overhead and limited data format.

Method used

Using a multi-cache area scheme, the data cache area of the operating system is defined as including N-1 first cache area and a second cache area, and memory space is allocated for each cache area. The cached data is stored in the first cache area. After protecting data consistency when receiving a user access request, it is moved to the second cache area. Finally, it is cancelled and copied to the user cache area, and the memory read and write speed difference is used to avoid locks or interrupts.

Benefits of technology

Through internal and external read and write separation, lock holding time and interrupt delay are reduced, performance degradation and accidents are avoided, and normalized evaluation and diagnosis are suitable for users to customize the number of cache areas and memory space size, which is convenient for practical applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371560A_ABST
    Figure CN120371560A_ABST
Patent Text Reader

Abstract

The invention discloses an operating system data copying method, device and equipment based on multiple cache regions, a medium and a product, and relates to the technical field of operating systems. The method comprises the following steps of: defining a data cache region of the operating system as a multi-cache region comprising N-1 first cache regions and a second cache region, distributing corresponding memory spaces for the cache regions, and storing to-be-cached data of the operating system into the N-1 first cache regions, and when a user access request for the cache data is received, firstly protecting the consistency of the cache data, then moving the cache data to the second cache region, finally canceling protection, and copying the data in the second cache region to the user cache region, so that the data can be copied to the user cache region by utilizing the characteristic that the read-write speed of the memory is far higher than the external copying speed. Through internal and external read-write separation, the use of locking or closing interruption is avoided when the data of the second cache region is accessed externally, and the locking time or interruption delay of the first cache region is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of operating systems, and particularly relates to an operating system data copying method, device, equipment, medium and product based on multiple buffer areas. Background Art

[0002] An operating system (English: Operating System, abbreviation: OS) is a built-in program used to coordinate various hardware components of a computer for interaction with users; common ones include the Windows operating system, the macOS operating system, and the open-source Linux operating system. Since the operating system is the infrastructure for all upper-layer applications, it is widely used in fields such as cloud computing. However, the operating system may also have performance and stability issues, and solving related problems has always been a major challenge in the industry.

[0003] Currently, the performance tuning and diagnostic means of operating systems provide some debugging tools, but these tools have the following problems: (1) When copying data from the operating system kernel to the user state, methods such as locking or disabling interrupts are required to protect data consistency. However, if the data volume is too large, it will cause the lock to be held for a long time or the interrupt to be disabled, resulting in a decline in the performance of the operating system and even life-threatening accidents; (2) There is an impact on the performance of the system itself; (3) There is a problem of high overhead, which is not suitable for regularly evaluating and diagnosing the system; (4) The collected data is limited by the tool data format and the collected data content, and users cannot customize the data format. Summary of the Invention

[0004] The purpose of the present invention is to provide an operating system data copying method, device, computer equipment, computer-readable storage medium and computer program product based on multiple buffer areas, so as to solve the problem that when copying data from the operating system kernel to the user state, it will cause the lock to be held for a long time or the interrupt to be disabled, resulting in a decline in the performance of the operating system and even life-threatening accidents.

[0005] To achieve the above purpose, the present invention adopts the following technical solutions:

[0006] In a first aspect, an operating system data copying method based on multiple buffer areas is provided, which is executed by a computer device running based on an operating system, and includes:

[0007] Define the data buffer area of the operating system as a multiple buffer area, and allocate corresponding memory spaces for each buffer area in the multiple buffer area, where the multiple buffer area includes N - 1 first buffer areas and one second buffer area, N represents the total number of buffer areas in the multiple buffer area and is a positive integer greater than or equal to 3, and the memory space size of the second buffer area is greater than or equal to the sum of the memory space sizes of the N - 1 first buffer areas;

[0008] Store the data to be cached of the operating system in the N - 1 first buffer areas;

[0009] When a user access request for the cached data of the operating system is received, first protect the consistency of the data stored in the N - 1 first buffer areas, then move the data stored in the N - 1 first buffer areas to the second buffer area, and finally cancel the data consistency protection and copy the data in the second buffer area to the user buffer area.

[0010] Based on the above - mentioned inventive concept, a new scheme for copying operating system data based on multiple buffer areas is provided. That is, first define the data buffer area of the operating system as a multiple buffer area including N - 1 first buffer areas and one second buffer area, and allocate corresponding memory spaces for each buffer area. Then store the data to be cached of the operating system in the N - 1 first buffer areas. Then, when a user access request for the cached data is received, first protect the consistency of the cached data, then move the cached data to the second buffer area, and finally cancel the data consistency protection and copy the data in the second buffer area to the user buffer area. In this way, taking advantage of the fact that the memory read - write speed is much higher than the external copy speed, through internal and external read - write separation, the use of locks or disabling interrupts can be avoided when accessing the data in the second buffer area externally, and the lock - holding time or interrupt latency for the first buffer area can be reduced. Furthermore, the performance degradation of the operating system can be avoided, and life - threatening accidents can be avoided, which is convenient for practical application and promotion.

[0011] In a possible design, defining the data buffer area of the operating system as a multiple buffer area and allocating corresponding memory spaces for each buffer area in the multiple buffer area includes:

[0012] According to the user's custom result, define the data buffer area of the operating system as a multiple buffer area and allocate corresponding memory spaces for each buffer area in the multiple buffer area, where the multiple buffer area includes N - 1 first buffer areas and one second buffer area, N represents the total number of buffer areas in the multiple buffer area and is determined as a positive integer greater than or equal to 3 according to the custom result, the memory space size and data storage type of the first buffer area are determined according to the custom result, and the memory space size of the second buffer area is greater than or equal to the sum of the memory space sizes of the N - 1 first buffer areas and is determined according to the custom result.

[0013] In a possible design, storing the data to be cached of the operating system in the N - 1 first buffer areas includes:

[0014] After obtaining a piece of data to be cached in the operating system, determine the required memory space size of the piece of data to be cached according to the data size of the piece of data to be cached. Wherein, the required memory space size is equal to the sum of the data size of the data header information and the data size of the piece of data to be cached. The data header information includes a protocol header field and a data size field, and the data size field is used to record the data size of the piece of data to be cached;

[0015] Traverse the N - 1 first buffer areas in sequence: First, determine whether the status bit of the currently traversed first buffer area is in the full data storage state. If so, traverse the next first buffer area. Otherwise, further determine whether the remaining memory space size of the currently traversed first buffer area is greater than or equal to the required memory space size of the piece of data to be cached. If it is determined that the remaining memory space size of the currently traversed first buffer area is greater than or equal to the required memory space size of the piece of data to be cached, then bind and store the data header information and the piece of data to be cached in the currently traversed first buffer area. And if it is determined that the remaining memory space size of the currently traversed first buffer area is less than the required memory space size of the piece of data to be cached, then mark the status bit of the currently traversed first buffer area as the full data storage state, and then traverse the next first buffer area. Wherein, the status bits of the N - 1 first buffer areas are initialized to the non-full data storage state after the memory space is allocated and / or after the data is moved to the second buffer area.

[0016] In a possible design, after traversing the N - 1 first buffer areas in sequence, if the status bits of the N - 1 first buffer areas are all in the full data storage state, then storing the data to be cached in the operating system in the N - 1 first buffer areas further includes the following steps S231 to S234:

[0017] S231. Delete a piece of historical data that has been stored in the N - 1 first buffer areas for the longest time, and mark the status bit of the first buffer area that once stored the piece of historical data as the non-full data storage state, and then execute step S232;

[0018] S232. Determine whether the remaining memory space size of the first buffer area that once stored the piece of historical data is less than the required memory space size of the piece of data to be cached. If so, execute step S233, otherwise execute step S234;

[0019] S233. Mark the status bit of the first buffer area that once stored the piece of historical data as the full data storage state, and then return to execute step S231;

[0020] S234. Bind the data header information and the certain data to be cached and store them in the first buffer area that once stored the certain historical data.

[0021] In a possible design, protecting the consistency of the data stored in the N - 1 first buffer areas includes:

[0022] Protect the consistency of the data stored in the N - 1 first buffer areas through a locking method or a method of disabling interrupts.

[0023] In a possible design, when the operating system is a Linux operating system, copying the data in the second buffer area to the user buffer area includes:

[0024] Pass the storage address of the user buffer area through the ioctl interface;

[0025] According to the storage address, copy the data in the second buffer area to the user buffer area through the copy_to_user data program and set the actual data size of the copied data in the user buffer area.

[0026] In a second aspect, a multi - buffer - based operating system data copying device is provided, which is arranged in a computer device operating based on an operating system and includes a memory management module, a data caching module, and an access response module that are communicatively connected in sequence;

[0027] The memory management module is used to define the data buffer area of the operating system as a multi - buffer area and allocate corresponding memory spaces for each buffer area in the multi - buffer area. Among them, the multi - buffer area includes N - 1 first buffer areas and one second buffer area, where N represents the total number of buffer areas in the multi - buffer area and is a positive integer greater than or equal to 3, and the memory space size of the second buffer area is greater than or equal to the sum of the memory space sizes of the N - 1 first buffer areas;

[0028] The data caching module is used to store the data to be cached by the operating system in the N - 1 first buffer areas;

[0029] The access response module is used to, when receiving a user access request for the cached data of the operating system, first protect the consistency of the data stored in the N - 1 first buffer areas, then move the data stored in the N - 1 first buffer areas to the second buffer area, finally cancel the data consistency protection, and copy the data in the second buffer area to the user buffer area.

[0030] In a third aspect, the present invention provides a computer device, including a memory, a processor, and a transceiver that are communicatively connected in sequence. Among them, the memory is used to store computer programs, the transceiver is used to send and receive messages, and the processor is used to read the computer programs and execute the operating system data copy method as described in the first aspect or any possible design in the first aspect.

[0031] In a fourth aspect, the present invention provides a computer-readable storage medium, on which instructions are stored. When the instructions are run on a computer, they execute the operating system data copy method as described in the first aspect or any possible design in the first aspect.

[0032] In a fifth aspect, the present invention provides a computer program product, including a computer program or instructions. When the computer program or the instructions are executed by a computer, they implement the operating system data copy method as described in the first aspect or any possible design in the first aspect.

[0033] Beneficial effects of the above solutions:

[0034] (1) The present invention creatively provides a new solution for copying operating system data based on multiple buffer areas. That is, first define the data buffer area of the operating system as a multiple buffer area including N - 1 first buffer areas and one second buffer area, and allocate corresponding memory spaces for each buffer area. Then store the data to be cached in the operating system in the N - 1 first buffer areas. Then, when receiving a user access request for the cached data, first protect the consistency of the cached data, then move the cached data to the second buffer area, and finally cancel the data consistency protection and copy the data in the second buffer area to the user buffer area. In this way, by taking advantage of the fact that the memory read and write speed is much higher than the external copy speed, through internal and external read and write separation, the use of locks or disabling interrupts can be avoided when accessing the data in the second buffer area externally, and the lock holding time or interrupt delay for the first buffer area can be reduced, thereby avoiding the degradation of the operating system performance and avoiding life-threatening accidents.

[0035] (2) It can also avoid affecting the performance of the system itself and reduce overhead. It is especially suitable for regularly evaluating and diagnosing the system, and can also achieve the purpose of user-defined number of buffer areas, memory space size, and data storage type, etc., which is convenient for practical application and promotion. Description of the Drawings

[0036] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the accompanying drawings required for the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.

[0037] Figure 1 It is a schematic flowchart of the operating system data copying method based on multiple buffer areas provided by an embodiment of the present application.

[0038] Figure 2 It is a schematic structural diagram of the operating system data copying device based on multiple buffer areas provided by an embodiment of the present application.

[0039] Figure 3 It is a schematic structural diagram of a computer device provided by an embodiment of the present application. Detailed implementation manners

[0040] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the present invention in combination with the accompanying drawings and the description of the embodiments or the prior art. Obviously, the following description of the accompanying drawing structures is only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings. It should be noted here that the description of these embodiment modes is used to help understand the present invention, but does not constitute a limitation to the present invention.

[0041] It should be understood that although terms such as first and second may be used herein to describe various objects, these objects should not be limited by these terms. These terms are only used to distinguish one object from another. For example, the first object can be called the second object, and similarly, the second object can be called the first object, without departing from the scope of the exemplary embodiments of the present invention.

[0042] It should be understood that for the term "and / or" that may appear in this article, it is only a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, B exists alone, or A and B exist simultaneously, etc. three situations; again, for example, A, B, and / or C can represent any one of A, B, and C or any combination of them; for the term " / and" that may appear in this article, it is a description of another association object relationship, indicating that two relationships may exist. For example, A / and B can represent: A exists alone or A and B exist simultaneously, etc. two situations; in addition, for the character " / " that may appear in this article, generally, the front and back associated objects represent an "or" relationship.

[0043] Embodiment:

[0044] As Figure 1 shown, the operating system data copying method provided in the first aspect of this embodiment and based on multiple buffer areas can be, but is not limited to, executed by a computer device with certain computing resources and running based on an operating system. For example, it can be executed by an electronic device such as a platform server, a personal computer (Personal Computer, PC, referring to a multi-purpose computer suitable for personal use in terms of size, price, and performance; desktop computers, laptops, small laptops, tablet computers, and ultrabooks, etc. all belong to personal computers), a smart phone, a personal digital assistant (Personal Digital Assistant, PDA), or a wearable device. As Figure 1 shown, the operating system data copying method can, but is not limited to, include the following steps S1 to S3.

[0045] S1. Define the data buffer area of the operating system as a multiple buffer area, and allocate corresponding memory spaces for each buffer area in the multiple buffer area. Among them, the multiple buffer area includes N - 1 first buffer areas and one second buffer area, where N represents the total number of buffer areas in the multiple buffer area and is a positive integer greater than or equal to 3, and the memory space size of the second buffer area is greater than or equal to the sum of the memory space sizes of the N - 1 first buffer areas.

[0046] In the step S1, the operating system may be, but is not limited to, Windows operating system, macOS operating system or open-source Linux operating system. The memory space size of the first buffer needs to be large enough to store multiple copies of operating system data obtained at different times. To achieve the purpose of user-defined number of buffers, memory space size, data storage type, etc., preferably, the data buffer of the operating system is defined as a multi-buffer, and corresponding memory spaces are allocated to each buffer in the multi-buffer, including but not limited to: according to the user-defined result, the data buffer of the operating system is defined as a multi-buffer, and corresponding memory spaces are allocated to each buffer in the multi-buffer, where the multi-buffer includes N - 1 first buffers and one second buffer, N represents the total number of buffers in the multi-buffer and is determined as a positive integer greater than or equal to 3 according to the user-defined result, the memory space size and data storage type of the first buffer are determined according to the user-defined result, and the memory space size of the second buffer is greater than or equal to the sum of the memory space sizes of the N - 1 first buffers and is determined according to the user-defined result. For example, the user can define 11 buffers: 10 first buffers and 1 second buffer, and the user can also define the memory space size of the first buffer as 25MB, and the user can also define the memory space size of the second buffer as 300MB, and the user can also define the data storage type as Json format, etc. In addition, the memory space sizes of the N - 1 first buffers are preferably the same size (for example, all 25MB), and the corresponding memory spaces are allocated to each buffer through the existing allocation function of the operating system, and a corresponding unique identifier is assigned to each buffer and the status bit of the corresponding buffer is initialized to the data storage not full state.

[0047] S2. Store the data to be cached of the operating system into the N - 1 first buffers.

[0048] In the step S2, the data to be cached may be, but is not limited to, newly generated operating system log data. Whenever a new piece of operating system log data is generated, it is stored in the N - 1 first buffers in real time. To achieve the purpose of orderly storage of operating system data, preferably, storing the data to be cached of the operating system into the N - 1 first buffers includes but is not limited to the following steps S21 to S22.

[0049] S21. After obtaining a piece of data to be cached of the operating system, determine the required memory space size of the piece of data to be cached according to the data size of the piece of data to be cached, where the required memory space size is equal to the sum of the data size of the data header information and the data size of the piece of data to be cached, the data header information includes a protocol header field and a data size field, and the data size field is used to record the data size of the piece of data to be cached.

[0050] In the step S21, the piece of data to be cached can be, for example, a new operating system log data. The protocol header field is used to fill in the protocol header information (Protocol Header, which refers to the header information used to specify the transport protocol when using network communication. It is usually located at the front of the data packet and contains information on how the data packet is to be processed, such as file type, priority, source address, and destination address, etc.). Its field length is generally a fixed value; and the field length of the data size field is also generally a fixed value, so that the data size of the data header information can be known, and thus the required memory space size can be easily calculated.

[0051] S22. Traverse the N - 1 first buffer areas in sequence: first, determine whether the status bit of the currently traversed first buffer area is in the full state of data storage. If so, traverse the next first buffer area. Otherwise, further determine whether the remaining memory space size of the currently traversed first buffer area is greater than or equal to the required memory space size of the piece of data to be cached. If it is determined that the remaining memory space size of the currently traversed first buffer area is greater than or equal to the required memory space size of the piece of data to be cached, then bind and store the data header information and the piece of data to be cached in the currently traversed first buffer area. If it is determined that the remaining memory space size of the currently traversed first buffer area is less than the required memory space size of the piece of data to be cached, then mark the status bit of the currently traversed first buffer area as the full state of data storage, and then traverse the next first buffer area, where the status bits of the N - 1 first buffer areas are initialized to the non-full state of data storage after memory space allocation and / or after data is moved to the second buffer area.

[0052] In step S22, for example, if the required memory space size is 3MB, the status bit of the first one of the N - 1 first buffer areas is in the full data storage state, and the status bits of the 2nd to N - 1th of the N - 1 first buffer areas are all in the non - full data storage state, then when traversing the first one of the first buffer areas, it will directly traverse the second one of the first buffer areas because the status bit is in the full data storage state. Then, if the remaining memory space size of the second one of the first buffer areas is only 1MB, the status bit of the second one of the first buffer areas will be marked as the full data storage state, and then the third one of the first buffer areas will be traversed, and so on until the N - 1th of the first buffer areas is traversed. Considering the situation where a large amount of data has been stored in the N - 1 first buffer areas so that the status bits of the N - 1 first buffer areas are all in the full data storage state, in order to achieve the purpose of orderly covering and storing the operating system data, further preferably, after sequentially traversing the N - 1 first buffer areas, if the status bits of the N - 1 first buffer areas are all in the full data storage state, the data to be cached of the operating system is stored in the N - 1 first buffer areas, and it further includes but is not limited to the following steps S231 to S234.

[0053] S231. Delete a certain piece of historical data that has been stored for the longest time in the N - 1 first buffer areas, mark the status bit of the first buffer area that once stored the certain piece of historical data as the non - full data storage state, and then execute step S232.

[0054] In step S231, the certain piece of historical data may, for example, include a certain piece of operating system historical log data and the data header information bound and stored with the certain piece of operating system historical log data.

[0055] S232. Judge whether the remaining memory space size of the first buffer area that once stored the certain piece of historical data is less than the required memory space size of the certain piece of data to be cached. If so, execute step S233; otherwise, execute step S234.

[0056] S233. Mark the status bit of the first buffer area that once stored the certain piece of historical data as the full data storage state, and then return to execute step S231.

[0057] S234. Bind and store the data header information and the certain piece of data to be cached in the first buffer area that once stored the certain piece of historical data.

[0058] S3. When a user access request for cache data of the operating system is received, the consistency of the data stored in the N-1 first cache areas is first protected, and then the data stored in the N-1 first cache areas is moved to the second cache area. Finally, the data consistency protection is canceled, and the data in the second cache area is copied to the user cache area.

[0059] In the step S3, specifically, protecting the consistency of the data stored in the N-1 first cache areas includes but is not limited to: protecting the consistency of the data stored in the N-1 first cache areas by means of a lock method or a shutdown interrupt method. The aforementioned lock method or shutdown interrupt method are both existing data consistency protection methods, so that the aforementioned specific method of canceling data consistency protection is also an existing method, such as a method of releasing the lock. In order to enable the cache data to be efficiently interacted with the user state, preferably, when the operating system is a Linux operating system, the data in the second cache area is copied to the user cache area, including but not limited to: first passing the storage address of the user cache area through the ioctl interface; then according to the storage address, the data in the second cache area is copied to the user cache area through the copy_to_user data program, and the actual data size of the copied data in the user cache area is set. The aforementioned ioctl interface and copy_to_user data program are both existing technical means. In addition, since the data stored in the N-1 first cache areas are moved to the second cache area, the N-1 first cache areas will be empty, so it is necessary to reinitialize the status bits of the N-1 first cache areas to a state where data is not full after the data is moved to the second cache area.

[0060] Therefore, based on the operating system data copy method described in the aforementioned steps S1 to S3, a new scheme for operating system data copy based on multiple cache areas is provided, that is, the data cache area of the operating system is first defined as a multiple cache area including N-1 first cache areas and one second cache area, and corresponding memory space is allocated to each cache area, and then the data to be cached of the operating system is stored in the N-1 first cache areas, and then when a user access request for the cached data is received, the consistency of the cached data is first protected, and then the cached data is moved to the second cache area, and finally the data consistency protection is canceled, and the data in the second cache area is copied to the user cache area. In this way, the characteristic that the memory read and write speed is much higher than the external copy speed can be utilized. By separating internal and external read and write, the use of locks or interrupts can be avoided when accessing the data in the second cache area externally, and the lock holding time or interrupt delay of the first cache area can be reduced, thereby avoiding the degradation of operating system performance and the occurrence of life-threatening accidents, which is convenient for practical application and promotion.

[0061] likeFigure 2 As shown in Figure 2 , in the second aspect of this embodiment, a virtual device for implementing the operating system data copying method described in the first aspect is provided, which is arranged in a computer device operating based on an operating system, and includes a memory management module, a data cache module, and an access response module that are communicatively connected in sequence;

[0062] The memory management module is configured to define the data buffer area of the operating system as a multi-buffer area, and allocate corresponding memory spaces for each buffer area in the multi-buffer area. Among them, the multi-buffer area includes N - 1 first buffer areas and one second buffer area, where N represents the total number of buffer areas in the multi-buffer area and is a positive integer greater than or equal to 3, and the memory space size of the second buffer area is greater than or equal to the sum of the memory space sizes of the N - 1 first buffer areas;

[0063] The data cache module is configured to store the data to be cached of the operating system in the N - 1 first buffer areas;

[0064] The access response module is configured to, when receiving a user access request for the cached data of the operating system, first protect the consistency of the data stored in the N - 1 first buffer areas, then move the data stored in the N - 1 first buffer areas to the second buffer area, and finally cancel the data consistency protection and copy the data in the second buffer area to the user buffer area.

[0065] For the working process, working details, and technical effects of the foregoing device provided in the second aspect of this embodiment, reference can be made to the operating system data copying method described in the first aspect, which will not be elaborated herein.

[0066] Such as Figure 3As shown in the figure, the third aspect of this embodiment provides a computer device that executes the operating system data copying method described in the first aspect, including a memory, a processor, and a transceiver that are communicatively connected in sequence. Among them, the memory is used to store computer programs, the transceiver is used to send and receive messages, and the processor is used to read the computer programs and execute the operating system data copying method described in the first aspect. Specifically, for example, the memory may include, but is not limited to, random access memory (RAM), read-only memory (ROM), flash memory, first input first output (FIFO), and / or first input last output (FILO), etc.; the processor may be, but is not limited to, a microprocessor of the STM32F105 series. In addition, the computer device may also include, but is not limited to, a power module, a display screen, and other necessary components.

[0067] For the working process, working details, and technical effects of the aforementioned computer device provided in the third aspect of this embodiment, reference may be made to the operating system data copying method described in the first aspect, which will not be elaborated here.

[0068] The fourth aspect of this embodiment provides a computer-readable storage medium storing instructions including the operating system data copying method described in the first aspect, that is, instructions are stored on the computer-readable storage medium, and when the instructions run on a computer, the operating system data copying method described in the first aspect is executed. Among them, the computer-readable storage medium refers to a carrier for storing data, which may include, but is not limited to, computer-readable storage media such as floppy disks, optical discs, hard disks, flash memories, USB flash drives, and / or memory sticks. The computer may be a general-purpose computer, a dedicated computer, a computer network, or other programmable devices.

[0069] For the working process, working details, and technical effects of the aforementioned computer-readable storage medium provided in the fourth aspect of this embodiment, reference may be made to the operating system data copying method described in the first aspect, which will not be elaborated here.

[0070] The fifth aspect of this embodiment provides a computer program product, including a computer program or instructions, and when the computer program or the instructions are executed by a computer, the operating system data copying method described in the first aspect is implemented. Among them, the computer may be a general-purpose computer, a dedicated computer, a computer network, or other programmable devices.

[0071] Finally, it should be noted that the above are only preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. A method for copying operating system data based on multiple buffer areas, characterized in that, Executed by a computer device operating based on an operating system, including: Defining the data buffer of the operating system as a multi-buffer, and allocating corresponding memory spaces for each buffer in the multi-buffer, where the multi-buffer includes N - 1 first buffers and one second buffer, N represents the total number of buffers in the multi-buffer and is a positive integer greater than or equal to 3, and the memory space size of the second buffer is greater than or equal to the sum of the memory space sizes of the N - 1 first buffers; Storing the data to be cached of the operating system into the N - 1 first buffers; When receiving a user access request for the cached data of the operating system, first protect the consistency of the data stored in the N - 1 first buffers, then move the data stored in the N - 1 first buffers to the second buffer, and finally cancel the data consistency protection and copy the data in the second buffer to the user buffer.

2. The operating system data copying method according to claim 1, characterized in that, Defining the data buffer of the operating system as a multi-buffer, and allocating corresponding memory spaces for each buffer in the multi-buffer, including: According to the user's custom result, defining the data buffer of the operating system as a multi-buffer, and allocating corresponding memory spaces for each buffer in the multi-buffer, where the multi-buffer includes N - 1 first buffers and one second buffer, N represents the total number of buffers in the multi-buffer and is determined to be a positive integer greater than or equal to 3 according to the custom result, the memory space size and data storage type of the first buffer are determined according to the custom result, and the memory space size of the second buffer is greater than or equal to the sum of the memory space sizes of the N - 1 first buffers and is determined according to the custom result.

3. The operating system data copying method according to claim 1, wherein Storing the data to be cached of the operating system into the N - 1 first buffers, including: After obtaining a certain piece of data to be cached of the operating system, determining the required memory space size of the certain piece of data to be cached according to the data size of the certain piece of data to be cached, where the required memory space size is equal to the sum of the data size of the data header information and the data size of the certain piece of data to be cached, the data header information includes a protocol header field and a data size field, and the data size field is used to record the data size of the certain piece of data to be cached; Traverse the N - 1 first buffer areas in sequence: First, determine whether the status bit of the currently traversed first buffer area is in the full data storage state. If so, traverse the next first buffer area. Otherwise, further determine whether the remaining memory space size of the currently traversed first buffer area is greater than or equal to the required memory space size of a certain piece of data to be cached. If it is determined that the remaining memory space size of the currently traversed first buffer area is greater than or equal to the required memory space size of a certain piece of data to be cached, then bind and store the data header information and the certain piece of data to be cached in the currently traversed first buffer area. If it is determined that the remaining memory space size of the currently traversed first buffer area is less than the required memory space size of a certain piece of data to be cached, then mark the status bit of the currently traversed first buffer area as the full data storage state, and then traverse the next first buffer area. Among them, the status bits of the N - 1 first buffer areas are initialized to the not - full data storage state after memory space allocation and / or after data is moved to the second buffer area.

4. The operating system data copying method according to claim 3, wherein After traversing the N - 1 first buffer areas in sequence, if the status bits of the N - 1 first buffer areas are all in the full data storage state, then store the data to be cached by the operating system in the N - 1 first buffer areas, and further include the following steps S231~S234: S231. Delete a certain piece of historical data that has been stored in the N - 1 first buffer areas for the longest time, and mark the status bit of the first buffer area that once stored the certain piece of historical data as the not - full data storage state, and then execute step S232; S232. Determine whether the remaining memory space size of the first buffer area that once stored the certain piece of historical data is less than the required memory space size of the certain piece of data to be cached. If so, execute step S233, otherwise execute step S234; S233. Mark the status bit of the first buffer area that once stored the certain piece of historical data as the full data storage state, and then return to execute step S231; S234. Bind and store the data header information and the certain piece of data to be cached in the first buffer area that once stored the certain piece of historical data.

5. The method for copying operating system data according to claim 1, wherein Protect the consistency of the data stored in the N - 1 first buffer areas, including: Protect the consistency of the data stored in the N - 1 first buffer areas by means of locks or disabling interrupts.

6. The method for copying operating system data according to claim 1, wherein When the operating system is the Linux operating system, copy the data in the second buffer area to the user buffer area, including: Pass the storage address of the user buffer area through the ioctl interface; According to the storage address, copy the data in the second buffer area to the user buffer area through the copy_to_user data program, and set the true data size of the copied data in the user buffer area.

7. An operating system data copying device based on multiple buffer areas, characterized in that, Arranged in a computer device running based on an operating system, including a memory management module, a data caching module, and an access response module that are communicatively connected in sequence; The memory management module is used to define the data buffer of the operating system as a multi-buffer, and allocate corresponding memory spaces for each buffer in the multi-buffer. Among them, the multi-buffer includes N-1 first buffers and one second buffer, where N represents the total number of buffers in the multi-buffer and is a positive integer greater than or equal to 3. The memory space size of the second buffer is greater than or equal to the sum of the memory space sizes of the N-1 first buffers; The data caching module is used to store the data to be cached of the operating system in the N-1 first buffers; The access response module is used to, when receiving a user access request for the cached data of the operating system, first protect the consistency of the data stored in the N-1 first buffers, then move the data stored in the N-1 first buffers to the second buffer, and finally cancel the data consistency protection and copy the data in the second buffer to the user buffer.

8. A computer device, characterized in that, It includes a memory, a processor, and a transceiver that are communicatively connected in sequence. Among them, the memory is used to store computer programs, the transceiver is used to send and receive messages, and the processor is used to read the computer programs and execute the operating system data copying method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that , An instruction is stored on the computer-readable storage medium, and when the instruction runs on the computer, it executes the operating system data copying method according to any one of claims 1 to 6.

10. A computer program product comprising a computer program or instructions, characterized in that, The computer program or the instruction, when executed by the computer, implements the operating system data copying method according to any one of claims 1 to 6.