Garbage collection operation method and device, computer equipment and readable storage medium
By decomposing the garbage collection operation into multiple sub-operations and releasing the storage unit occupation after each completion, the problem of long-term waiting of the processing unit caused by traditional garbage collection is solved, and the real-time performance of the system is improved.
Patent Information
- Application Number
- CN202510246996.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-04
- Publication Date
- 2025-07-08
AI Technical Summary
In systems with a single Flash device, traditional garbage collection operations cause processing units to fail to access storage devices for a long time, seriously reducing real-time performance.
The garbage collection operation is decomposed into multiple garbage collection sub-operations, and after each sub-operation is completed, the control unit actively sends an interrupt signal to release the occupancy of the storage unit, allowing the processing unit to obtain access rights in time for preset operations.
By decomposing and collecting operations, the processing unit is avoided for a long time and the real-time performance of the processing unit is improved.
Smart Images

Figure CN120277007A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of electronic devices, and particularly to a garbage collection operation method, apparatus, computer device, computer-readable storage medium, and computer program product. Background Art
[0002] With the development of electronic devices, non-volatile storage technology plays an important role in data persistent storage. Among many non-volatile storage solutions, due to the advantages of large capacity and low cost of Flash (flash memory), the technical solution of using Flash to simulate EEPROM (electrically erasable programmable read-only memory) has been widely applied. During the process of Flash simulating EEPROM, multiple data writes will cause the Flash rotation area to be filled up. After the corresponding area is filled up, garbage collection operation needs to be performed. Therefore, how to perform garbage collection operation on Flash simulating EEPROM has become an important research direction.
[0003] Traditional technologies usually perform garbage collection operations in a continuous execution manner; however, in a system with only a single Flash device, performing garbage collection operations in this way will cause the processing unit to be unable to access the Flash device for a long time, seriously reducing the real-time performance of the processing unit. Summary of the Invention
[0004] Based on this, it is necessary to provide a garbage collection operation method, apparatus, computer device, computer-readable storage medium, and computer program product that can improve the real-time performance of the processing unit for the above technical problems.
[0005] In a first aspect, the present application provides a garbage collection operation method, which is applied to a control unit. The method includes:
[0006] When it is detected that garbage collection operation needs to be performed on a storage unit, send an interrupt signal of the control unit to the processing unit, and stop occupying the storage unit; the processing unit is used to respond to the interrupt signal, obtain access authority to the storage unit, perform a preset operation on the storage unit, and send a control signal to the control unit after completing the preset operation; the garbage collection operation includes multiple garbage collection sub-operations;
[0007] Respond to the control signal and perform the garbage collection operation on the storage unit;
[0008] After completing one garbage collection sub-operation, jump to the step of sending the interrupt signal of the control unit to the processing unit and stopping occupying the storage unit until the garbage collection operation is completed.
[0009] In one embodiment, the multiple garbage collection sub-operations include a data copy operation and multiple data erasure operations;
[0010] Performing the garbage collection operation on the storage unit in response to the control signal includes:
[0011] Performing the data copy operation on the storage unit in response to the control signal;
[0012] After completing one garbage collection sub-operation, jumping to the step of sending an interrupt signal of the control unit to the processing unit and stopping occupying the storage unit until the garbage collection operation is completed, includes:
[0013] After completing the data copy operation, sending a new round of interrupt signals of the control unit to the processing unit and stopping occupying the storage unit; the processing unit is configured to obtain access rights to the storage unit in response to the new round of interrupt signals of the control unit, perform a new round of preset operations on the storage unit, and send a new round of control signals to the control unit after completing the new round of preset operations;
[0014] Performing one data erasure operation on the storage unit in response to the new round of control signals;
[0015] After completing one data erasure operation, jumping to the step of sending a new round of interrupt signals of the control unit to the processing unit and stopping occupying the storage unit until the multiple data erasure operations are completed.
[0016] In one embodiment, performing the data copy operation on the storage unit in response to the control signal includes:
[0017] Maintaining a waiting state when the control signal is not received;
[0018] When the control signal is received, obtaining access rights to the storage unit in response to the control signal and performing the data copy operation on the storage unit;
[0019] Performing one data erasure operation on the storage unit in response to the new round of control signals includes:
[0020] Maintaining a waiting state when the new round of control signal is not received;
[0021] When the new round of control signal is received, obtaining access rights to the storage unit in response to the new round of control signal and performing one data erasure operation on the storage unit.
[0022] In one embodiment, after one data erasure operation is completed, it jumps to the step of sending a new round of interrupt signals from the control unit to the processing unit and stopping occupying the storage unit until multiple data erasure operations are completed, including:
[0023] After one data erasure operation is completed, determine whether the current storage block in the storage unit has been erased completely;
[0024] In the case where the current storage block has not been erased completely, jump to the step of sending a new round of interrupt signals from the control unit to the processing unit and stopping occupying the storage unit until multiple data erasure operations are completed.
[0025] In one embodiment, before jumping to the step of sending a new round of interrupt signals from the control unit to the processing unit and stopping occupying the storage unit until multiple data erasure operations are completed in the case where the current storage block has not been erased completely, it further includes:
[0026] In the case where not all storage sectors in the current storage block have been erased completely, confirm that the current storage block has not been erased completely;
[0027] In the case where all storage sectors in the current storage block have been erased completely, confirm that the current storage block has been erased completely.
[0028] In one embodiment, the method further includes:
[0029] During the garbage collection operation on the storage unit, when an emergency event signal is received, in response to the emergency event signal, stop the garbage collection operation and send an interrupt signal corresponding to the emergency event signal to the processing unit; the emergency event signal includes an emergency interrupt event signal sent by the interrupt control unit or a wait request signal of the control unit sent by the processing unit.
[0030] In one embodiment, the process of the garbage collection operation is the process of the data copy operation;
[0031] After stopping the garbage collection operation and sending an interrupt signal corresponding to the emergency event signal to the processing unit when an emergency event signal is received during the garbage collection operation on the storage unit, it further includes:
[0032] When the control signal sent by the processing unit is received, in response to the control signal, continue to execute the data copy operation from the operation interruption position of the storage unit.
[0033] In one embodiment, the process of the garbage collection operation is the process of the data erasure operation;
[0034] During the process of performing the garbage collection operation on the storage unit, when an emergency event signal is received, in response to the emergency event signal, after stopping the garbage collection operation and sending an interrupt signal corresponding to the emergency event signal to the processing unit, the following further includes:
[0035] When receiving the new round of control signal sent by the processing unit, in response to the new round of control signal, continue to perform the data erasure operation from the operation interruption position of the storage unit.
[0036] In a second aspect, the present application further provides a garbage collection operation device applied to a control unit. The device includes:
[0037] A signal sending module, configured to send an interrupt signal of the control unit to a processing unit and stop occupying the storage unit when detecting that a garbage collection operation needs to be performed on the storage unit; the processing unit is configured to obtain an access right to the storage unit in response to the interrupt signal, perform a preset operation on the storage unit, and send a control signal to the control unit after completing the preset operation; the garbage collection operation includes multiple garbage collection sub-operations;
[0038] A signal response module, configured to perform the garbage collection operation on the storage unit in response to the control signal;
[0039] An operation completion module, configured to, after completing one garbage collection sub-operation, jump to the step of sending the interrupt signal of the control unit to the processing unit and stop occupying the storage unit until the garbage collection operation is completed.
[0040] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0041] When detecting that a garbage collection operation needs to be performed on the storage unit, send an interrupt signal of the control unit to the processing unit and stop occupying the storage unit; the processing unit is configured to obtain an access right to the storage unit in response to the interrupt signal, perform a preset operation on the storage unit, and send a control signal to the control unit after completing the preset operation; the garbage collection operation includes multiple garbage collection sub-operations;
[0042] In response to the control signal, perform the garbage collection operation on the storage unit;
[0043] After completing one garbage collection sub - operation, jump to the step of sending an interrupt signal of the control unit to the processing unit and stop occupying the storage unit until the garbage collection operation is completed.
[0044] In a fourth aspect, the present application also provides a computer - readable storage medium. On the computer - readable storage medium, there is a computer program stored, and when the computer program is executed by a processor, the following steps are implemented:
[0045] When it is detected that a garbage collection operation needs to be performed on the storage unit, send an interrupt signal of the control unit to the processing unit and stop occupying the storage unit; the processing unit is configured to, in response to the interrupt signal, obtain access rights to the storage unit, perform a preset operation on the storage unit, and send a control signal to the control unit after completing the preset operation; the garbage collection operation includes multiple garbage collection sub - operations;
[0046] In response to the control signal, perform the garbage collection operation on the storage unit;
[0047] After completing one garbage collection sub - operation, jump to the step of sending an interrupt signal of the control unit to the processing unit and stop occupying the storage unit until the garbage collection operation is completed.
[0048] In a fifth aspect, the present application also provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0049] When it is detected that a garbage collection operation needs to be performed on the storage unit, send an interrupt signal of the control unit to the processing unit and stop occupying the storage unit; the processing unit is configured to, in response to the interrupt signal, obtain access rights to the storage unit, perform a preset operation on the storage unit, and send a control signal to the control unit after completing the preset operation; the garbage collection operation includes multiple garbage collection sub - operations;
[0050] In response to the control signal, perform the garbage collection operation on the storage unit;
[0051] After completing one garbage collection sub - operation, jump to the step of sending an interrupt signal of the control unit to the processing unit and stop occupying the storage unit until the garbage collection operation is completed.
[0052] The above garbage collection operation method, device, computer device, computer-readable storage medium, and computer program product, when detecting that a garbage collection operation needs to be performed on a storage unit, send an interrupt signal of the control unit to the processing unit and stop occupying the storage unit; the processing unit is configured to, in response to the interrupt signal, obtain access rights to the storage unit, perform a preset operation on the storage unit, and send a control signal to the control unit after completing the preset operation; the garbage collection operation includes multiple garbage collection sub-operations; in response to the control signal, perform the garbage collection operation on the storage unit; after completing one garbage collection sub-operation, jump to the step of sending the interrupt signal of the control unit to the processing unit and stop occupying the storage unit, until the garbage collection operation is completed. This solution decomposes the garbage collection operation into multiple garbage collection sub-operations, and after each garbage collection sub-operation is completed, the control unit actively sends an interrupt signal and releases the occupation of the storage unit, enabling the processing unit to timely obtain access rights to the storage unit to perform preset operations, which helps to avoid the problem that the processing unit cannot access the storage unit for a long time due to waiting for a complete garbage collection operation, thereby helping to improve the real-time performance of the processing unit. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the following will briefly introduce the drawings required for use in the description of the embodiments or the related art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0054] Figure 1 It is a first flowchart of the garbage collection operation method in an embodiment;
[0055] Figure 2 It is a schematic diagram of the storage structure of a Flash device in an embodiment;
[0056] Figure 3 It is a first schematic diagram of the structure of the garbage collection operation method in an embodiment;
[0057] Figure 4 It is a flowchart of the write operation process in an embodiment;
[0058] Figure 5 It is a first schematic diagram of the storage structure of a block in an embodiment;
[0059] Figure 6 It is a second schematic diagram of the storage structure of a block in an embodiment;
[0060] Figure 7The third schematic diagram of the storage structure of a block in an embodiment;
[0061] Figure 8 The fourth schematic diagram of the storage structure of a block in an embodiment;
[0062] Figure 9 The fifth schematic diagram of the storage structure of a block in an embodiment;
[0063] Figure 10 The sixth schematic diagram of the storage structure of a block in an embodiment;
[0064] Figure 11 The flowchart of the steps for erasing a block in an embodiment;
[0065] Figure 12 The second structural schematic diagram of the garbage collection operation method in an embodiment;
[0066] Figure 13 The third structural schematic diagram of the garbage collection operation method in an embodiment;
[0067] Figure 14 The second flowchart of the garbage collection operation method in an embodiment;
[0068] Figure 15 The fourth structural schematic diagram of the garbage collection operation method in an embodiment;
[0069] Figure 16 The third flowchart of the garbage collection operation method in an embodiment;
[0070] Figure 17 The structural block diagram of the garbage collection operation device in an embodiment;
[0071] Figure 18 The internal structure diagram of a computer device in an embodiment. Detailed implementation manners
[0072] In order to make the objectives, technical solutions and advantages of the present application more clear and understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0073] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data that have been authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with relevant regulations.
[0074] In an exemplary embodiment, as Figure 1 shown, a garbage collection operation method is provided. In this embodiment, the method is exemplified by being applied to a control unit. It can be understood that the method can also be applied to a terminal or a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. Among them, the terminal can be, but is not limited to, various personal computers, laptop computers, smart phones, tablet computers, etc.; the server can be an independent physical server, can also be a server cluster or a distributed system composed of multiple physical servers, and can also be a cloud server providing cloud computing services. In this embodiment, the method includes the following steps:
[0075] Step S101, when it is detected that a garbage collection operation needs to be performed on the storage unit, send an interrupt signal of the control unit to the processing unit and stop occupying the storage unit; the processing unit is used to respond to the interrupt signal, obtain the access right of the storage unit, perform a preset operation on the storage unit, and send a control signal to the control unit after completing the preset operation; the garbage collection operation includes multiple garbage collection sub-operations.
[0076] Step S102, in response to the control signal, perform a garbage collection operation on the storage unit.
[0077] Step S103, after completing a garbage collection sub-operation, jump to the step of sending an interrupt signal of the control unit to the processing unit and stopping occupying the storage unit until the garbage collection operation is completed.
[0078] Among them, the control unit can be a hardware module for performing data management of the storage unit. For example, the control unit can be an EEE (EEPROM Emulation) control module. Among them, EEE can be called an analog EEPROM. In the hardware implementation method introduced in this embodiment, EEE can be called a hardware analog EEPROM. EEE can be understood as a specific functional module, and the function it implements is to use Flash to implement the function of EEPROM.
[0079] Among them, the garbage collection operation can be an operation of copying valid data in the storage unit from one storage block to another and erasing the original storage block. For example, it can be an operation of copying valid data in the Flash memory from one block to another and erasing the original block.
[0080] Among them, the garbage collection sub-operation can be a single data copy or erase operation during the garbage collection operation. For example, the erase operation can be an erase operation on a sector.
[0081] Among them, the storage unit can be a hardware device for storing data, such as a Flash (Flash, flash memory) device (Flash memory).
[0082] Among them, the interrupt signal can be a pause request signal sent by the control unit to the processing unit, such as an eee_pend_intr (EEE pause interrupt) signal.
[0083] Among them, the processing unit can be a processor that executes program instructions, such as a CPU (central processing unit).
[0084] Among them, the access permission can be a control permission for reading and writing operations on the storage unit, such as an access control permission for a Flash (flash memory) device.
[0085] Among them, the preset operation can be a preset task that the processing unit needs to execute, such as program code that the CPU (central processing unit) needs to execute.
[0086] Among them, the control signal can be a continue execution signal sent by the processing unit to the control unit, such as an eee_continue_go (EEE continue execution) signal.
[0087] Optionally, when the control unit detects that the current valid block in the storage unit is full, it determines that garbage collection operation needs to be performed on the storage unit. The control unit sends an eee_pend_intr (EEE pause interrupt) interrupt signal to the processing unit and actively releases the occupancy of the storage unit. After receiving the eee_pend_intr (EEE pause interrupt) interrupt signal, the processing unit obtains the access permission to the storage unit, executes the preset program code, clears the eee_pend_intr (EEE pause interrupt) interrupt signal after completion, and sends an eee_continue_go (EEE continue execution) control signal to the control unit. After receiving the eee_continue_go (EEE continue execution) control signal, the control unit re-obtains the access permission to the storage unit and continues to perform the garbage collection operation, which includes copying the valid data in the current valid block to a new valid block and multiple garbage collection sub-operations of sector erasing the current valid block; after completing one garbage collection sub-operation, it jumps to the step of sending an interrupt signal from the control unit to the processing unit and stopping occupying the storage unit until the garbage collection operation is completed.
[0088] For example, when the control unit performs a garbage collection operation, it first copies the valid data in the current valid block (such as block1) to a new valid block (such as block2), and then erases the sectors in the current valid block (such as block1). After each sector erasure operation is completed, the control unit sends an eee_pend_intr (EEE pause interrupt) interrupt signal to the processing unit and releases the occupancy right of the storage unit. The processing unit obtains the access right of the storage unit to execute the preset program code, and after the execution is completed, sends an eee_continue_go (EEE continue execution) control signal to the control unit. After receiving the eee_continue_go (EEE continue execution) control signal, the control unit continues to perform the erasure operation of the next sector, and so on until all sectors of the current valid block (such as block1) are erased, thus completing the entire garbage collection operation.
[0089] In the above garbage collection operation method, when it is detected that a garbage collection operation needs to be performed on the storage unit, an interrupt signal of the control unit is sent to the processing unit, and the occupancy of the storage unit is stopped; the processing unit is used to respond to the interrupt signal, obtain the access right of the storage unit, perform a preset operation on the storage unit, and after the preset operation is completed, send a control signal to the control unit; the garbage collection operation includes multiple garbage collection sub-operations; in response to the control signal, a garbage collection operation is performed on the storage unit; after a garbage collection sub-operation is completed, it jumps to the step of sending an interrupt signal of the control unit to the processing unit and stopping the occupancy of the storage unit until the garbage collection operation is completed. This solution decomposes the garbage collection operation into multiple garbage collection sub-operations, and after each garbage collection sub-operation is completed, the control unit actively sends an interrupt signal and releases the occupancy of the storage unit, enabling the processing unit to timely obtain the access right of the storage unit to execute the preset operation, which is beneficial to avoiding the problem that the processing unit cannot access the storage unit for a long time due to waiting for the complete garbage collection operation, thus being beneficial to improving the real-time performance of the processing unit.
[0090] In an exemplary embodiment, multiple garbage collection sub-operations include data copy operations and multiple data erase operations; in response to a control signal, a garbage collection operation is performed on a storage unit, which specifically includes the following: in response to the control signal, a data copy operation is performed on the storage unit; after completing one garbage collection sub-operation, it jumps to the step of sending an interrupt signal from the control unit to the processing unit and stopping occupying the storage unit until the garbage collection operation is completed, which specifically includes the following: after completing the data copy operation, a new round of interrupt signal from the control unit is sent to the processing unit and the storage unit is stopped from being occupied; the processing unit is used to obtain the access right of the storage unit in response to the new round of interrupt signal from the control unit, perform a new round of preset operations on the storage unit, and send a new round of control signals to the control unit after completing the new round of preset operations; in response to the new round of control signals, a data erase operation is performed on the storage unit; after completing one data erase operation, it jumps to the step of sending a new round of interrupt signal from the control unit to the processing unit and stopping occupying the storage unit until multiple data erase operations are completed.
[0091] Among them, the data copy operation can be an operation of copying valid data in the current storage block to a new storage block. For example, it can be an operation of copying the valid data in block1 (block 1) to block2 (block 2).
[0092] Among them, the data erase operation can be an operation of erasing sectors in the storage block. For example, it can be an operation of erasing one sector in block1.
[0093] Among them, the new round of interrupt signal can be an interrupt request signal sent by the control unit to the processing unit after completing the data copy operation. For example, it can be the eee_pend_intr (EEE pause interrupt) signal sent by the EEE (EEPROM emulation) control module after completing the data copy.
[0094] Among them, the new round of preset operations can be pre-set tasks that the processing unit needs to execute after receiving the new round of interrupt signal. For example, it can be the program code that the CPU (central processing unit) needs to execute after receiving the new round of eee_pend_intr (EEE pause interrupt) signal.
[0095] Among them, the new round of control signals can be a continue execution signal sent by the processing unit to the control unit after completing the new round of preset operations. For example, it can be the eee_continue_go (EEE continue execution) signal sent by the CPU (central processing unit) to the EEE (EEPROM emulation) control module.
[0096] Optionally, when the control unit detects that the current valid block in the storage unit is full, it starts to perform a garbage collection operation in response to a control signal. The control unit first performs a data copy operation to copy the valid data in the current valid block to a new valid block. After completing the data copy operation, it sends an eee_pend_intr (EEE pause interrupt) signal to the processing unit and releases the access right to the storage unit. After the processing unit completes the preset operation, it sends an eee_continue_go (EEE continue execution) control signal. Subsequently, the control unit starts to perform multiple data erasure operations. After each sector erasure operation is completed, it sends an eee_pend_intr (EEE pause interrupt) signal to the processing unit and releases the access right to the storage unit, waiting for the processing unit to complete the preset operation and send an eee_continue_go (EEE continue execution) control signal before continuing with the next sector erasure operation until all sectors are erased.
[0097] The technical solution provided in this embodiment decomposes the garbage collection operation into a data copy operation and multiple data erasure operations. After completing the data copy operation and after each data erasure operation is completed, the control unit actively sends a new round of interrupt signals and releases the occupancy of the storage unit, which helps to avoid the problem that the processing unit cannot access the storage unit for a long time due to waiting for a complete data erasure operation, thus helping to improve the real-time response ability of the processing unit.
[0098] In an exemplary embodiment, in response to a control signal, a data copy operation is performed on the storage unit, which specifically includes the following: in the case of not receiving the control signal, it remains in a waiting state; in the case of receiving the control signal, in response to the control signal, it obtains the access right to the storage unit and performs a data copy operation on the storage unit; in response to a new round of control signals, a data erasure operation is performed on the storage unit, which specifically includes the following: in the case of not receiving the new round of control signals, it remains in a waiting state; in the case of receiving the new round of control signals, in response to the new round of control signals, it obtains the access right to the storage unit and performs a data erasure operation on the storage unit.
[0099] Among them, the waiting state can be a state where the control unit temporarily stops operating on the storage unit and waits for a signal. For example, it can be the waiting state of the EEE (EEPROM emulation) control module before receiving the eee_continue_go (EEE continue execution) control signal.
[0100] Optionally, when the control unit performs a garbage collection operation, it first waits for the processing unit to send the eee_continue_go (EEE continue execution) control signal. After receiving the eee_continue_go (EEE continue execution) control signal, the control unit acquires the access right to the storage unit and starts to perform a data copy operation, copying the valid data in the current valid block to a new valid block. After completing the data copy operation, the control unit enters the waiting state again until it receives a new round of eee_continue_go (EEE continue execution) control signal sent by the processing unit. Then the control unit acquires the access right to the storage unit again and starts to perform a data erasure operation to erase the sectors in the current valid block.
[0101] The technical solution provided in this embodiment, by respectively setting a waiting state before performing the data copy operation and the data erasure operation, and only acquiring the access right to the storage unit to perform the corresponding operation after receiving the corresponding control signal, is conducive to ensuring that there is no conflict in the access of the control unit and the processing unit to the storage unit, thus being conducive to improving the success rate of accessing the storage unit.
[0102] In an exemplary embodiment, after completing one data erasure operation, it jumps to the step of sending a new round of interrupt signals from the control unit to the processing unit and stopping occupying the storage unit until multiple data erasure operations are completed. The specific content is as follows: after completing one data erasure operation, it is judged whether the current storage block in the storage unit has been erased completely; in the case where the current storage block has not been erased completely, it jumps to the step of sending a new round of interrupt signals from the control unit to the processing unit and stopping occupying the storage unit until multiple data erasure operations are completed.
[0103] Among them, the current storage block can be the storage block undergoing the garbage collection operation. For example, it can be block1 undergoing the sector erasure operation, and can also be called the current valid block or the active block.
[0104] Among them, being erased completely can mean that all sectors in the current storage block have completed the erasure operation. For example, it can mean that all sectors in block1 have completed the erasure operation.
[0105] Optionally, after completing a data erasure operation, the control unit determines whether the current storage block has completed the erasure operation of all sectors by reading the count value of the erased sectors and comparing it with the total number of sectors in the current storage block. If the current storage block has not completed the erasure operation of all sectors, the control unit sends an eee_pend_intr (EEE pause interrupt) interrupt signal to the processing unit and releases the occupation of the storage unit. After waiting for the processing unit to complete the preset operation and send an eee_continue_go (EEE continue execution) control signal, the control unit reacquires the access right of the storage unit and continues to execute the erasure operation of the next sector until the erasure operation of all sectors in the current storage block is completed.
[0106] The technical solution provided in this embodiment determines whether the current storage block is erased completely after each data erasure operation, and sends an interrupt signal and releases the access right of the storage unit when the erasure is not completed, which is conducive to decomposing the continuous erasure operation of the entire storage block into multiple independent single erasure operations, thus helping to solve the problem that the control unit occupies the storage unit for a long time and causes the processing unit to be unable to access the storage unit.
[0107] In an exemplary embodiment, when the current storage block is not erased completely, it jumps to the step of sending a new round of interrupt signals from the control unit to the processing unit and stopping occupying the storage unit. Until before multiple data erasure operations are completed, the following content is also included: when the storage sectors in the current storage block are not all erased completely, it is confirmed that the current storage block is not erased completely; when the storage sectors in the current storage block are all erased completely, it is confirmed that the current storage block is erased completely.
[0108] Among them, the storage sector can be the smallest erasure unit in the storage unit for storing data. For example, it can be a sector with a size of 1KB in a Flash device.
[0109] Optionally, during the execution of the data erasure operation, the control unit determines the erasure status of the current storage block by recording the count value of the erased sectors. When the control unit completes a data erasure operation, the control unit compares the count value of the erased sectors with the total number of sectors in the current storage block. If the count value of the erased sectors is less than the total number of sectors in the current storage block, the control unit confirms that the current storage block is not erased completely and sends an eee_pend_intr (EEE pause interrupt) interrupt signal to the processing unit; if the count value of the erased sectors is equal to the total number of sectors in the current storage block, the control unit confirms that the current storage block is erased completely.
[0110] The technical solution provided in this embodiment establishes a corresponding relationship between the erasure state of the storage block and the erasure states of all internal storage sectors, which is conducive to accurately judging the erasure state of the storage block, thereby facilitating the accurate control of the execution process of the data erasure operation and effectively avoiding the problem of abnormal data erasure caused by misjudgment.
[0111] In an exemplary embodiment, the following is further included: during the garbage collection operation on the storage unit, when an emergency event signal is received, in response to the emergency event signal, the garbage collection operation is stopped, and an interrupt signal corresponding to the emergency event signal is sent to the processing unit; the emergency event signal includes an emergency interrupt event signal sent by the interrupt control unit or a wait request signal of the control unit sent by the processing unit.
[0112] Among them, the emergency event signal can be a control signal that needs to immediately pause the garbage collection operation. For example, it can be an emergency interrupt event signal sent by the interrupt control unit or an eee_pend_req (EEE pause request) signal sent by the processing unit.
[0113] Among them, the interrupt control unit can be a hardware module for managing and controlling system interrupt signals. For example, it can be an interrupt controller responsible for issuing emergency interrupt events.
[0114] Among them, the emergency interrupt event signal can be an interrupt signal that needs to be immediately responded to sent by the interrupt control unit. For example, it can be an emergency interrupt signal that requires the control unit to immediately stop the current garbage collection operation.
[0115] Among them, the wait request signal can be a pause request signal sent by the processing unit to the control unit. For example, an eee_pend_req (EEE pause request) signal.
[0116] Optionally, during the execution of the garbage collection operation by the control unit, when an emergency interrupt event signal sent by the interrupt control unit or an eee_pend_req (EEE pause request) signal sent by the processing unit is received, the control unit immediately stops the current garbage collection operation, sends an eee_pend_intr (EEE pause interrupt) interrupt signal to the processing unit, and at the same time releases the occupation of the storage unit. After the processing unit completes the emergency task and sends an eee_continue_go (EEE continue execution) control signal, the control unit re-acquires the access right of the storage unit and continues to execute the garbage collection operation.
[0117] The technical solution provided in this embodiment realizes the timely stop of the garbage collection operation by receiving and responding to the emergency event signal during the garbage collection operation, which is conducive to quickly releasing the access right of the storage unit in case of emergency, thereby facilitating improving the response speed of the system to emergency events.
[0118] In an exemplary embodiment, the process of the garbage collection operation is the process of data copy operation; during the garbage collection operation on the storage unit, when an emergency event signal is received, in response to the emergency event signal, the garbage collection operation is stopped, and after sending an interrupt signal corresponding to the emergency event signal to the processing unit, the following is further included: when a control signal sent by the processing unit is received, in response to the control signal, the data copy operation is continued from the operation interruption position of the storage unit.
[0119] Among them, the operation interruption position can be the position where the operation is paused due to receiving an emergency event signal during the execution of the data copy operation.
[0120] Optionally, when the control unit performs the data copy operation during the garbage collection operation, when receiving an emergency interrupt event signal sent by the interrupt control unit or an eee_pend_req (EEE pause request) signal sent by the processing unit, the control unit immediately stops the current data copy operation, sends an eee_pend_intr (EEE pause interrupt) interrupt signal to the processing unit, records the interruption position of the current data copy operation at the same time, and releases the occupation of the storage unit. After the processing unit completes the emergency task and sends an eee_continue_go (EEE continue execution) control signal, the control unit re - obtains the access right of the storage unit and continues to execute the data copy operation from the previously recorded interruption position.
[0121] The technical solution provided in this embodiment records the operation interruption position during the data copy operation in the garbage collection process, and continues to execute the data copy operation from this interruption position after receiving the control signal, which is beneficial to realizing the flexible interruption and accurate recovery of the data copy operation, and thus is beneficial to improving the system's response ability to emergency events while ensuring the integrity of the data copy operation.
[0122] In an exemplary embodiment, the process of the garbage collection operation is the process of data erasure operation; during the garbage collection operation on the storage unit, when an emergency event signal is received, in response to the emergency event signal, the garbage collection operation is stopped, and after sending an interrupt signal corresponding to the emergency event signal to the processing unit, the following is further included: when a new round of control signal sent by the processing unit is received, in response to the new round of control signal, the data erasure operation is continued from the operation interruption position of the storage unit.
[0123] Optionally, when the control unit performs a data erasure operation during a garbage collection operation, upon receiving an emergency interrupt event signal sent by the interrupt control unit or an eee_pend_req (EEE pause request) signal sent by the processing unit, the control unit immediately stops the current data erasure operation, sends an eee_pend_intr (EEE pause interrupt) signal to the processing unit, records the interrupt position of the current data erasure operation, and releases the occupancy of the storage unit. After the processing unit completes the emergency task and sends an eee_continue_go (EEE continue execution) control signal, the control unit reacquires the access right to the storage unit and performs a complete data erasure operation on the storage sector where the interrupt position is located again.
[0124] The technical solution provided in this embodiment realizes the timely interruption of the data erasure operation by receiving and responding to the emergency event signal during the data erasure operation, which is beneficial to quickly releasing the access right to the storage unit in an emergency; by continuing to execute the data erasure operation from the operation interruption position after receiving a new round of control signals, it is beneficial to ensure the continuity and integrity of the data erasure operation.
[0125] The following uses an application example to illustrate the garbage collection operation method provided in this application. This application example takes the application of this method to the control unit as an example for illustration.
[0126] 1. Background introduction:
[0127] In an electronic device, non-volatile data is generally stored in an EEPROM and a Flash Memory. After the chip is powered off and then powered on again, the data in the chip remains unchanged.
[0128] Both the EEPROM and the Flash are non-volatile memories, which means that they retain their data after power-off. They are both composed of a group of memory cells, and each memory cell can store one or more bits of information.
[0129] The EEPROM is usually written and erased in units of a Byte or a Word, that is, the writing and erasing are bounded by a Byte or a Word, which makes the EEPROM writing and erasing relatively independent and free and will not affect other data. In addition, the writing and erasing life (PE cycles, programming and erasing cycles) of the EEPROM is relatively high, up to one million times. However, the EEPROM belongs to an external storage device of the chip.
[0130] Flash typically uses a Word (single word) or Double-Word (double word) as the write unit, but erases in units of sectors, and the size of these sectors is usually measured in KB. These characteristics are related to semiconductor manufacturing processes and design features, making Flash have a very large capacity but a relatively short erase / write lifespan (usually only 100,000 PE cycles). Flash can be integrated with chip logic on the same chip.
[0131] The following uses a Flash with a capacity of 128KB and a total of 128 1KB sectors as an example to illustrate its storage structure. Refer to Figure 2 , the storage structure of this 128KB Flash device includes a continuous sequence of sectors starting from sector 0, sector 1, sector 2, sector 3, and ending at sector 125, sector 126, sector 127, with a total of 128 sectors of 1KB size.
[0132] 2. Advantages of Flash simulating EEPROM:
[0133] Flash simulating EEPROM can provide non-volatile storage functionality, enabling data to be retained even after power loss.
[0134] Using internal Flash to simulate EEPROM can save the pins and space required for external EEPROM, reducing system costs.
[0135] By simulating EEPROM, the ability to perform single-byte erase similar to EEPROM can be achieved, improving the flexibility of data storage, because EEPROM can erase and write individual bytes multiple times, while Flash needs to be erased by region.
[0136] Through the special mechanism of simulating EEPROM, the durability of Flash can be improved and its lifespan extended, which is of great significance for the problem of limited Flash erase / write times (usually 10,000 times, much lower than EEPROM).
[0137] Flash simulating EEPROM can simplify the operations of reading and writing data, enabling writes and erasures in units of Byte or Word, making the operations more intuitive and convenient.
[0138] In summary, the role of Flash simulating EEPROM is to provide non-volatile storage, save costs and space, improve durability and data storage efficiency, and simplify software operations.
[0139] 3. Implementation method of simulated EEPROM:
[0140] To extend the service life of Flash, simulated EEPROM usually uses multiple Flash blocks to alternately store data. A block can include multiple sectors. When a block is fully written, it is erased. Through hardware EEE, the original erase and write operations for a single sector can be distributed to multiple sectors, thus increasing the overall erasable and writable times of Flash.
[0141] A group of Flash blocks is set as the EEPROM emulation block. From this group of blocks, one block is selected as the active block. When the active block is full, the system copies all the valid data in the active block to other EEPROM emulation blocks. This new block becomes the active block, and then the previous active block is erased. This process is called garbage collection (GC).
[0142] The hardware-simulated EEPROM presents an SRAM (static random access memory) externally, which is called EERAM. The hardware EEE automatically backs up the data written by the user to the EERAM to the Flash EEE backup area; the user can obtain the data in the EEE backup area by reading the EERAM. The hardware-simulated EEPROM completes the mapping from EERAM to Flash through hardware circuits, without additional code, and does not need to call the EEE API (application programming interface) during the write operation, featuring convenient use and high access efficiency.
[0143] Reference Figure 3 , including a bus, a bus interface parser, an SRAM (static random access memory) read / write module, an EEE (EEPROM emulation) control module, a Flash (flash memory) device, and an EERAM (SRAM for simulated EEPROM) module, and a Flash read / write module. Among them, the SRAM read / write module can read and write EERAM control signals, SRAM interface signals, and send EEE write control signals to the EEE control module; the EEE control module can send Flash interface signals to the Flash device; the Flash read / write module can read and write Flash control signals and Flash interface signals.
[0144] Special Note: In cost-sensitive application scenarios, there is usually only one Flash device in the chip, which is used as both program Flash and data Flash at the same time.
[0145] 3.1. Operation Process of Hardware Emulated EEPROM (Electrically Erasable Programmable Read-Only Memory):
[0146] The operation process of hardware emulated EEPROM is as follows.
[0147] Reference Figure 4 , the process of the EEE (EEPROM Emulation) write operation is: First, BLK1 (Block 1) is the current active block, and the system writes data to BLK1. Then, it is judged whether BLK1 is full. If it is not full, data continues to be written to BLK1. If BLK1 is full, the valid data in BLK1 is copied to BLK2 (Block 2), then BLK2 is marked as the active block, BLK1 is erased, and BLK1 is marked as the inactive block, completing the GC (Garbage Collection) process from BLK1 to BLK2.
[0148] This section details the schematic of the operation data stream of hardware emulated EEPROM, taking two blocks as an example for illustration.
[0149] 3.1.1. Initial State:
[0150] Both of the two blocks are in the erased state, and the data in them is invalid data.
[0151] Reference Figure 5 , this figure shows the storage structure in the initial state, including two blocks with a size of 16KB: block1 (Block 1) and block2 (Block 2). The Flash address starts from 0x0 and goes through 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8... 0x7FF, then 0x800, 0x801, 0x802, 0x803, 0x804, 0x805, 0x806, 0x807, 0x808, and finally reaches 0xFFF. The data sequence "0, 1... 61, 62, 63" is shown in the current data area. The data can be the current data, in the erased state, or old invalid data. Currently, these data are in the erased state.
[0152] 3.1.2. Execute the EEE (EEPROM Emulation Engine) Write Operation:
[0153] block1 is the active block, and the EEE write operation starts to be executed.
[0154] Reference Figure 6 This figure shows the storage structure under EEE write operations, including two blocks of 16KB each: block1 and block2. The Flash address starts from 0x0, passing through 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8... 0x7FF in sequence, then 0x800, 0x801, 0x802, 0x803, 0x804, 0x805, 0x806, 0x807, 0x808, and finally reaching 0xFFF. The data sequence "0, 1... 61, 62, 63" is shown in the current data area. The data can be current data, in the erased state, or old invalid data. Currently, the data at 0x0 (recording 0x15) is in the state of current data.
[0155] 3.1.3. Multiple EEE write and erase operations:
[0156] Execute EEE write operations continuously, including writing to the same address multiple times.
[0157] Reference Figure 7 This figure shows the storage structure under multiple EEE write and erase operations, including two blocks of 16KB each: block1 and block2. The Flash address starts from 0x0 (recording 0x15), passing through 0x1 (recording 0x23), 0x2 (recording 0x37), 0x3 (recording 0x37), 0x4 (recording 0x37), 0x5 (recording 0x37), 0x6 (recording 0x10), 0x7 (recording 0x37), 0x8... 0x7FF in sequence, then 0x800, 0x801, 0x802, 0x803, 0x804, 0x805, 0x806, 0x807, 0x808, and finally reaching 0xFFF. The data sequence "0, 1... 61, 62, 63" is shown in the current data area. The data can be current data, in the erased state, or old invalid data.
[0158] 3.1.4. The current block is full:
[0159] For EEE write operations, block1 is full.
[0160] Reference Figure 8, This figure shows the storage structure when the current block is full, including two blocks of 16KB size: block1 and block2. Among them, the Flash address starts from 0x0 (recording 0x15), and successively passes through 0x1 (recording 0x23), 0x2 (recording 0x37), 0x3 (recording 0x37), 0x4 (recording 0x37), 0x5 (recording 0x37), 0x6 (recording 0x10), 0x7 (recording 0x37), 0x8 (recording 0x37) …… 0x7FF (recording 0x37), then 0x800, 0x801, 0x802, 0x803, 0x804, 0x805, 0x806, 0x807, 0x808, and finally reaches 0xFFF. The data sequence "0, 1 …… 61, 62, 63" is shown in the current data area, and the data can be current data, in the erased state, or old invalid data.
[0161] 3.1.5, Data Copying during GC (Garbage Collection):
[0162] The valid data in block1 is copied to block2, and block2 becomes the valid block area (belonging to the GC operation process).
[0163] Reference Figure 9 , This figure shows the storage structure during data copying in the GC process, including two blocks of 16KB size: block1 and block2. Among them, the Flash address starts from 0x0 (recording 0x15), and successively passes through 0x1 (recording 0x23), 0x2 (recording 0x37), 0x3 (recording 0x37), 0x4 (recording 0x37), 0x5 (recording 0x37), 0x6 (recording 0x10), 0x7 (recording 0x37), 0x8 (recording 0x37) …… 0x7FF (recording 0x37), then 0x800 (recording 0x15), 0x801 (recording 0x23), 0x802 (recording 0x10), 0x803 (recording 0x37), 0x804, 0x805, 0x806, 0x807, 0x808, and finally reaches 0xFFF. The data sequence "0, 1 …… 61, 62, 63" is shown in the current data area, and the data can be current data, in the erased state, or old invalid data.
[0164] 3.1.6, Switching the active block:
[0165] Erase block1, and block1 becomes an invalid block area (belonging to the GC operation process).
[0166] Reference Figure 10 , this figure shows the storage structure under the switched active block, including two blocks of 16KB size: block1 and block2. The Flash address starts from 0x0, and successively passes through 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8... 0x7FF, and then is 0x800 (recording 0x15), 0x801 (recording 0x23), 0x802 (recording 0x10), 0x803 (recording 0x37), 0x804, 0x805, 0x806, 0x807, 0x808, and finally reaches 0xFFF. The data sequence "0, 1... 61, 62, 63" is shown in the current data area, and the data can be the current data, in the erased state, or old invalid data.
[0167] It can be seen from the data flow diagram in the EEE operation process that if the space of a block is small, it is easy to fill the block, and it is easier to occur the intermediate data transfer process. The intermediate data is transferred as the final valid data, which will occupy the space of the next block, resulting in waste of Flash valid space and loss of Flash erase / write times.
[0168] Therefore, the block generally has a relatively large capacity (such as 16KB, 32KB, 64KB), and usually adopts the two-half structure to implement EEE, so that the operation of invalid intermediate data can be avoided as much as possible when data copying occurs.
[0169] 3.2. The refined process of the erase block operation in the GC process:
[0170] The refined process of the erase block operation in the GC process is as follows.
[0171] Reference Figure 11, This figure shows the complete process of refining the erase block operation during the GC process: First, BLK1 (Block 1) is the current valid block, and the system writes data to BLK1. Then, it is judged whether BLK1 is full. If it is not full, data is continuously written to BLK1. If BLK1 is full, the valid data of BLK1 is copied to BLK2 (Block 2), then BLK2 is marked as the active block, and the step of erasing BLK1 is carried out. Specifically, 1 sector of BLK1 is erased, the number of erased sectors is recorded as +1, and it is judged whether all sectors of BLK1 have been erased. If not, it returns to the step of erasing 1 sector of BLK1. If so, BLK1 is marked as an inactive block, and the GC (Garbage Collection) process from BLK1 to BLK2 is completed.
[0172] Disadvantages of the prior art:
[0173] Problems of implementing hardware EEE with a single Flash device:
[0174] From the operation process of hardware emulating EEPROM, it can be seen that during the GC (Garbage Collection) process, after the current block is full, all the current valid data needs to be copied to the next valid active block area, and at the same time, the current block is erased.
[0175] Since Flash is erased in units of sectors (sectors, 1KB in size), and the time required for simultaneous erasure is relatively long, usually between 3 - 6 ms (milliseconds). If a block includes 16 sectors, it will take 48 ms - 96 ms.
[0176] Since there is only one Flash device in the system, the Flash read / write module and the EEE control module need to perform arbitration before accessing the Flash device. Only the winning party in the arbitration can obtain the access right to the Flash device.
[0177] During the EEE GC process, the Flash device is occupied by the EEE control module, and the CPU cannot access the programs and data stored in the Flash device through the bus. This period will cause the CPU to execute pending (waiting).
[0178] For application scenarios with high real-time requirements, the 48 ms - 96 ms pending time of the CPU is unacceptable.
[0179] Simplified block diagram reference of the system implementing the hardware EEE function Figure 12, including CPU (central processing unit), bus, bus interface analysis, SRAM (static random access memory) read / write module, EEE (EEPROM simulation) control module, Flash (flash memory) device and EERAM (SRAM simulating EEPROM) module, Flash read / write module. Among them, the SRAM read / write module can read and write EERAM control signals, SRAM interface signals and send EEE write control signals to the EEE control module; the EEE control module can send Flash interface signals to the Flash device; the Flash read / write module can read and write Flash control signals and Flash interface signals.
[0180] This application example proposes a hardware EEE and CPU hardware and software interaction mechanism to ensure that when the EEE performs a GC operation, the occupation of the Flash device can be temporarily released, and the CPU notifies the EEE to continue the GC operation after processing the emergency affairs.
[0181] During the hardware EEE GC process, the following actions are performed before data is copied between different blocks and sectors are erased:
[0182] 1. EEE notifies the CPU in the form of an interrupt (eee_pend_intr, EEE pause interrupt) that the EEE GC process is pending;
[0183] 2. EEE releases the Flash device;
[0184] 3. The CPU obtains access rights to the Flash device and executes the corresponding program;
[0185] 4. The CPU clears the EEE pending interrupt (eee_pend_intr);
[0186] 5. After the CPU finishes executing the program, it sends the configuration (eee_continue_go, EEE continues to execute) to notify EEE to continue the GC operation.
[0187] In the EEE implementation structure, the interrupt signal eee_pend_intr and the control signal eee_continue_go are added to interact with the CPU.
[0188] Simplified block diagram of the system for reference Figure 13, including a CPU (Central Processing Unit), a bus, a bus interface parser, an SRAM (Static Random Access Memory) read / write module, an EEE (EEPROM Emulation) control module, a Flash (Flash Memory) device, and an EERAM (SRAM Emulating EEPROM) module, a Flash read / write module, an arbitration & routing module. Among them, the SRAM read / write module can read and write EERAM control signals, SRAM interface signals, and send an EEE write control signal to the EEE control module; the EEE control module can send an EEE access Flash signal to the arbitration & routing module; the Flash read / write module can read and write Flash control signals and interact with the arbitration & routing module through AHB access Flash signals, and the arbitration & routing module can interact with the Flash device through Flash interface signals; the EEE control module notifies the CPU in the form of an interruption (eee_pend_intr, EEE Pause Interruption), and subsequently the CPU can issue a configuration (eee_continue_go, EEE Continue Execution) to the EEE control module.
[0189] Update the operation process of the hardware emulating EEPROM.
[0190] The execution process reference Figure 14 , first, BLK1 (Block 1) is the current active block, write data to BLK1; then determine whether BLK1 is full, if not full, continue to write data to BLK1; if BLK1 is full, EEE releases the Flash occupation and interrupts to notify the cpu. After the cpu completes the emergency task, EEE requests the Flash resource again and continues the EEE operation. The valid data of BLK1 is copied to BLK2, mark BLK2 as the active block, EEE releases the Flash occupation and interrupts to notify the cpu. After the cpu completes the emergency task, EEE requests the Flash resource again and continues the EEE operation. Erase one sector of BLK1, record the number of erased sectors +1, whether all sectors of BLK1 are erased, if so, mark BLK1 as an inactive block, and complete the GC process from BLK1 to BLK2. Among them, EEE releases the Flash occupation and interrupts to notify the cpu, after the cpu completes the emergency task, EEE requests the Flash resource again and continues the EEE operation, specifically as follows: generate eee_pend_intr, notify the cpu that EEE releases the occupation of Flash, the CPU obtains the access right of Flash, EEE Pending (waiting), the CPU executes the program, the cpu configures the eee_pend_intr interruption to be cleared, and the cpu issues the eee_continue_go command, and EEE obtains the access right of Flash.
[0191] Expansion technical solution:
[0192] Introduce the rapid response mechanism of EEE to handle emergencies.
[0193] In the EEE and CPU software-hardware interaction solution introduced above, the CPU pending time can be controlled within the time of erasing one Flash sector. However, for emergencies, a faster response is required. Therefore, the EEE and CPU software-hardware interaction solution needs to be optimized for emergency scenarios.
[0194] When an emergency or interruption occurs, it is desired to immediately terminate the Flash EEE GC operation, and at this time, EEE needs to be temporarily paused.
[0195] If the CPU is running in SRAM (Static Random Access Memory), the CPU can execute programs in parallel with EEE operations. At this time, the CPU can also issue a configuration (eee_pend_req, EEE pause request) to temporarily pause EEE.
[0196] After the EEE module receives an emergency interrupt event or the eee_pend_req request sent by the CPU, the EEE GC operation immediately stops and generates an eee_pend_intr interrupt to notify the CPU. The subsequent process is the same as the EEE and CPU software-hardware interaction solution introduced above.
[0197] Emergencies may occur during the data copy and Flash erasure phases of the GC process. The handling methods for these two phases are different:
[0198] If EEE is paused due to an emergency during the data copy process, after EEE is restarted, the subsequent copy actions are continued from the interrupted position.
[0199] If EEE is paused due to an emergency during the Flash sector erasure process, after EEE is restarted, the previously erased sector is erased again.
[0200] In the EEE implementation structure, add the interaction between EEE and the interrupt controller, and between EEE and CPU control signals.
[0201] Refer to the simplified block diagram of the system Figure 15, including an interrupt controller, a CPU (Central Processing Unit), a bus, a bus interface parser, an SRAM (Static Random Access Memory) read / write module, an EEE (EEPROM Emulation) control module, a Flash device, and an EERAM (SRAM Emulating EEPROM) module, a Flash read / write module, an arbitration & routing module. Among them, the SRAM read / write module can read and write EERAM control signals, SRAM interface signals, and send an EEE write control signal to the EEE control module; the EEE control module can send an EEE access Flash signal to the arbitration & routing module; the Flash read / write module can read and write Flash control signals and interact with the arbitration & routing module through an AHB access Flash signal, and the arbitration & routing module can interact with the Flash device through a Flash interface signal; the EEE control module notifies the CPU in the form of an interrupt (eee_pend_intr, EEE pause interrupt), and subsequently the CPU can issue a configuration (eee_continue_go, EEE continue execution) to the EEE control module. Among them, the interrupt controller can send an emergency interrupt event to the CPU and the EEE control module, and the CPU can issue a configuration (eee_pend_req, EEE pause request) to the EEE control module.
[0202] Update the operation process of the hardware emulating EEPROM.
[0203] Refer to the execution process Figure 16, first, BLK1 (block 1) is the current active block, and data is written to BLK1. Then, it is judged whether BLK1 is full. If it is not full, data is continuously written to BLK1. If BLK1 is full, EEE releases the Flash occupancy and interrupts to notify the CPU. After the CPU completes the emergency task, EEE requests the Flash resource again and continues the EEE operation. The valid data of BLK1 is copied to BLK2, BLK2 is marked as the active block, EEE releases the Flash occupancy and interrupts to notify the CPU. After the CPU completes the emergency task, EEE requests the Flash resource again and continues the EEE operation. One sector of BLK1 is erased, and the number of erased sectors is recorded as +1. Whether all sectors of BLK1 have been erased. If so, BLK1 is marked as an inactive block, and the GC process from BLK1 to BLK2 is completed. Among them, EEE releases the Flash occupancy and interrupts to notify the CPU. After the CPU completes the emergency task, EEE requests the Flash resource again and continues the EEE operation, as follows: generate eee_pend_intr, notify the CPU that EEE releases the occupancy of Flash, the CPU obtains the access right to Flash, EEE is pending, the CPU executes the program, the CPU configures the eee_pend_intr interrupt to be cleared, and the CPU issues the eee_continue_go command, and EEE obtains the access right to Flash. Among them, after receiving an emergency interrupt event or eee_pend_req (EEE pause request), it will return to the step where EEE releases the Flash occupancy and interrupts to notify the CPU. After the CPU completes the emergency task, EEE requests the Flash resource again and continues the EEE operation.
[0204] The GC pending event optimization mechanism introduced above can be extended in several aspects: when performing Flash sector erasure, the number of sectors that can be erased each time can be configured according to the system's requirements for real-time performance. Whether to enable the software-hardware interaction mechanism of GC can be configured. When not enabled, the GC process is completed at one time.
[0205] The technical solution provided by this application example realizes the problem that the program cannot be executed for a long time when performing hardware simulation EEPROM GC operations in an SOC (system-on-chip / single-chip system) chip with only a single Flash device; while saving costs, good overall performance is obtained.
[0206] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are displayed in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless specifically stated herein, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, at least some of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least some of the steps or stages in other steps or other steps.
[0207] Based on the same inventive concept, an embodiment of the present application also provides a garbage collection operation device for implementing the garbage collection operation method described above. The solution provided by this device to solve the problem is similar to the solution described in the above method. Therefore, the specific limitations in one or more embodiments of the garbage collection operation device provided below can refer to the limitations on the garbage collection operation method in the above text, and will not be repeated here.
[0208] In an exemplary embodiment, as Figure 17 shown, a garbage collection operation device is provided, which is applied to a control unit. The garbage collection operation device 1700 may include:
[0209] A signal sending module 1701, configured to send an interrupt signal of the control unit to the processing unit and stop occupying the storage unit when it is detected that a garbage collection operation needs to be performed on the storage unit; the processing unit is configured to obtain the access right of the storage unit in response to the interrupt signal, perform a preset operation on the storage unit, and send a control signal to the control unit after the preset operation is completed; the garbage collection operation includes multiple garbage collection sub-operations;
[0210] A signal response module 1702, configured to perform a garbage collection operation on the storage unit in response to the control signal;
[0211] An operation completion module 1703, configured to jump to the step of sending an interrupt signal of the control unit to the processing unit and stopping occupying the storage unit after one garbage collection sub-operation is completed, until the garbage collection operation is completed.
[0212] In an exemplary embodiment, multiple garbage collection sub-operations include a data copy operation and multiple data erasure operations; the signal response module 1702 is further configured to, in response to a control signal, perform a data copy operation on a storage unit; the operation completion module 1703 is further configured to, after completing the data copy operation, send a new round of interruption signals of the control unit to the processing unit and stop occupying the storage unit; the processing unit is configured to, in response to the new round of interruption signals of the control unit, obtain access rights to the storage unit, perform a new round of preset operations on the storage unit, and after completing the new round of preset operations, send a new round of control signals to the control unit; in response to the new round of control signals, perform a data erasure operation on the storage unit; after completing one data erasure operation, jump to the step of sending a new round of interruption signals of the control unit to the processing unit and stop occupying the storage unit until multiple data erasure operations are completed.
[0213] In an exemplary embodiment, the signal response module 1702 is further configured to, when not receiving a control signal, remain in a waiting state; when receiving a control signal, in response to the control signal, obtain access rights to the storage unit and perform a data copy operation on the storage unit; the operation completion module 1703 is further configured to, when not receiving a new round of control signals, remain in a waiting state; when receiving a new round of control signals, in response to the new round of control signals, obtain access rights to the storage unit and perform a data erasure operation on the storage unit.
[0214] In an exemplary embodiment, the operation completion module 1703 is further configured to, after completing one data erasure operation, determine whether the current storage block in the storage unit has been completely erased; if the current storage block has not been completely erased, jump to the step of sending a new round of interruption signals of the control unit to the processing unit and stop occupying the storage unit until multiple data erasure operations are completed.
[0215] In an exemplary embodiment, the apparatus 1700 further includes an erasure confirmation module, configured to confirm that the current storage block has not been completely erased when not all storage sectors in the current storage block have been completely erased; and confirm that the current storage block has been completely erased when all storage sectors in the current storage block have been completely erased.
[0216] In an exemplary embodiment, the apparatus 1700 further includes an operation stop module, configured to, during the process of performing a garbage collection operation on a storage unit, when receiving an emergency event signal, in response to the emergency event signal, stop the garbage collection operation and send an interruption signal corresponding to the emergency event signal to the processing unit; the emergency event signal includes an emergency interruption event signal sent by an interruption control unit or a waiting request signal of the control unit sent by the processing unit.
[0217] In an exemplary embodiment, the process of the garbage collection operation is the process of the data copy operation; the apparatus 1700 further includes: a first operation module, configured to, when receiving a control signal sent by the processing unit, in response to the control signal, continue to execute the data copy operation from the operation interruption position of the storage unit.
[0218] In an exemplary embodiment, the process of the garbage collection operation is the process of the data erasure operation; the apparatus 1700 further includes: a second operation module, configured to, when receiving a new round of control signals sent by the processing unit, in response to the new round of control signals, continue to execute the data erasure operation from the operation interruption position of the storage unit.
[0219] Each module in the above garbage collection operation apparatus can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor in the computer device in the form of hardware or be independent of it, or can be stored in the memory of the computer device in the form of software, so as to be called by the processor to execute the operations corresponding to the above respective modules.
[0220] In an exemplary embodiment, a computer device is provided. The computer device can be a terminal, and its internal structure diagram can be as Figure 18 shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface, the display unit, and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used for exchanging information between the processor and external devices. The communication interface of the computer device is used for communicating with external terminals in a wired or wireless manner. The wireless manner can be implemented through WIFI, a mobile cellular network, NFC (Near Field Communication), or other technologies. The computer program, when executed by the processor, implements a garbage collection operation method. The display unit of the computer device is configured to form a visually visible picture, which can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covering the display screen, or a button, a trackball, or a touchpad provided on the housing of the computer device, or can also be an external keyboard, a touchpad, or a mouse, etc.
[0221] Those skilled in the art can understand that Figure 18The structure shown is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.
[0222] In an exemplary embodiment, a computer device is further provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, the steps in the above method embodiments are implemented.
[0223] In an exemplary embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0224] In an exemplary embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0225] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memories. Non-volatile memories can include read-only memory (ROM), magnetic tapes, floppy disks, flash memories, optical memories, high-density embedded non-volatile memories, resistive random access memories (ReRAM), magnetoresistive random access memories (MRAM), ferroelectric random access memories (FRAM), phase change memories (PCM), graphene memories, etc. Volatile memories can include random access memory (RAM) or external cache memories, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., without limitation.
[0226] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope recorded in this specification.
[0227] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A garbage collection operation method, characterized in that, Applied to a control unit, the method includes: When it is detected that a garbage collection operation needs to be performed on a storage unit, sending an interrupt signal of the control unit to a processing unit and stopping occupying the storage unit; the processing unit is configured to, in response to the interrupt signal, obtain access rights to the storage unit, perform a preset operation on the storage unit, and send a control signal to the control unit after completing the preset operation; the garbage collection operation includes multiple garbage collection sub-operations; In response to the control signal, perform the garbage collection operation on the storage unit; After completing one garbage collection sub-operation, jump to the step of sending the interrupt signal of the control unit to the processing unit and stopping occupying the storage unit until the garbage collection operation is completed.
2. The method according to claim 1, wherein The multiple garbage collection sub-operations include a data copy operation and multiple data erasure operations; The performing the garbage collection operation on the storage unit in response to the control signal includes: In response to the control signal, perform the data copy operation on the storage unit; The jumping to the step of sending the interrupt signal of the control unit to the processing unit and stopping occupying the storage unit after completing one garbage collection sub-operation until the garbage collection operation is completed includes: After completing the data copy operation, sending a new round of interrupt signal of the control unit to the processing unit and stopping occupying the storage unit; the processing unit is configured to, in response to the new round of interrupt signal of the control unit, obtain access rights to the storage unit, perform a new round of preset operation on the storage unit, and send a new round of control signal to the control unit after completing the new round of preset operation; In response to the new round of control signal, perform one data erasure operation on the storage unit; After completing one data erasure operation, jump to the step of sending the new round of interrupt signal of the control unit to the processing unit and stopping occupying the storage unit until the multiple data erasure operations are completed.
3. The method according to claim 2, wherein The performing the data copy operation on the storage unit in response to the control signal includes: When the control signal is not received, remain in a waiting state; When the control signal is received, in response to the control signal, obtain access rights to the storage unit and perform the data copy operation on the storage unit; The performing one data erasure operation on the storage unit in response to the new round of control signal includes: When the new round of control signal is not received, remain in a waiting state; When the new round of control signal is received, in response to the new round of control signal, obtain access rights to the storage unit and perform one data erasure operation on the storage unit.
4. The method according to claim 2, wherein The jumping to the step of sending the new round of interrupt signal of the control unit to the processing unit and stopping occupying the storage unit after completing one data erasure operation until the multiple data erasure operations are completed includes: After completing one data erasure operation, determine whether the current storage block in the storage unit has been completely erased; If the current storage block has not been completely erased, jump to the step of sending a new round of interrupt signals from the control unit to the processing unit and stop occupying the storage unit until the multiple data erasure operations are completed.
5. The method according to claim 4, wherein If the current storage block has not been completely erased, before jumping to the step of sending a new round of interrupt signals from the control unit to the processing unit and stopping occupying the storage unit until the multiple data erasure operations are completed, it further includes: If the storage sectors in the current storage block have not all been erased, confirm that the current storage block has not been completely erased; If the storage sectors in the current storage block have all been erased, confirm that the current storage block has been completely erased.
6. The method according to claim 2, wherein The method further includes: During the garbage collection operation on the storage unit, when an emergency event signal is received, in response to the emergency event signal, stop the garbage collection operation and send an interrupt signal corresponding to the emergency event signal to the processing unit; the emergency event signal includes an emergency interrupt event signal sent by the interrupt control unit or a waiting request signal of the control unit sent by the processing unit.
7. The method according to claim 6, wherein The process of the garbage collection operation is the process of the data copy operation; After stopping the garbage collection operation and sending an interrupt signal corresponding to the emergency event signal to the processing unit when an emergency event signal is received during the garbage collection operation on the storage unit, it further includes: When the control signal sent by the processing unit is received, in response to the control signal, continue to perform the data copy operation from the operation interruption position of the storage unit.
8. The method according to claim 6, wherein The process of the garbage collection operation is the process of the data erasure operation; After stopping the garbage collection operation and sending an interrupt signal corresponding to the emergency event signal to the processing unit when an emergency event signal is received during the garbage collection operation on the storage unit, it further includes: When the new round of control signal sent by the processing unit is received, in response to the new round of control signal, continue to perform the data erasure operation from the operation interruption position of the storage unit.
9. A garbage collection operation device, characterized in that, Applied to a control unit, the device includes: A signal sending module, configured to send an interrupt signal of the control unit to the processing unit and stop occupying the storage unit when it is detected that a garbage collection operation needs to be performed on the storage unit; the processing unit is configured to obtain access rights to the storage unit in response to the interrupt signal, perform a preset operation on the storage unit, and send a control signal to the control unit after completing the preset operation; the garbage collection operation includes multiple garbage collection sub-operations; A signal response module, configured to perform the garbage collection operation on the storage unit in response to the control signal; The operation completion module is used to, after completing one of the garbage collection sub-operations, jump to the step of sending an interrupt signal of the control unit to the processing unit and stop occupying the storage unit until the garbage collection operation is completed.
10. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 8.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1 to 8.
12. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1 to 8.
Citation Information
Cited By
A method, device and equipment for processing historical data of external memory of a collection terminal
CN122507326A
A method, device and equipment for processing historical data of external memory of a collection terminal
CN122507326B