CPC G06F 11/1064 (2013.01) [G06F 9/466 (2013.01); G06F 11/0772 (2013.01); G06F 11/0778 (2013.01); G06F 11/1471 (2013.01)] | 8 Claims |
1. A method for ensuring failure atomicity in a non-volatile memory, the method comprising:
executing transactions encapsulated by one or more operations that need to ensure the failure atomicity in accordance with the following steps:
(S1) executing operations in a current transaction in sequence, for each write operation in the current transaction, if the oldest value of its corresponding data has not been saved into a log of the non-volatile memory, then creating an UndoRedo log entry for it, and if the oldest value of its corresponding data has been saved into the log of the non-volatile memory, then creating a Redo log entry for it;
wherein while log entries are created, the log entries are managed by using corresponding log management strategies according to types of log entries;
(S2) after all operations in the current transaction are executed, committing the current transaction; and
(S3) completing the execution of the current transaction;
wherein information recorded in the UndoRedo log entries comprises: transaction number, write operation address, and oldest value and new value of corresponding data;
information recorded in the Redo log entries comprises: transaction number, write operation address, and new value of corresponding data; and the oldest value of data is a value of the data when the current transaction just starts to be executed, and the new value of data is a value of the data after the execution of a corresponding write operation is completed;
wherein an active log cache and a lazy log cache are added in a processor of the non-volatile memory; and
the log management strategies comprise: active write-back strategies and lazy write-back strategies; and in the step (S1), an active write-back strategy is used to manage the UndoRedo log entries, and a lazy write-back strategy is used to manage the Redo log entries;
wherein using the active write-back strategy to manage the UndoRedo log entries comprises: after an UndoRedo log entry is created, it being first cached in the active log cache, and then written back to the non-volatile memory after a preset time interval; and the time interval is less than the time required for the data to be written from a first-level cache of the processor back to the non-volatile memory; and
using the lazy write-back strategy to manage the Redo log entries comprises: after a Redo log entry is created, it being first cached in the first-level cache of the processor, and when a cache line where the Redo log entry is located is evicted or updated by other transactions, the Redo log entry being cached in the lazy log cache; and when the lazy log cache is full, the Redo log entry in the lazy log cache being written back to the non-volatile memory; and log entries with the same transaction number and write operation address will be merged by the lazy write-back strategy during managing the Redo log entries.
|