CN114610652A - SD card data access method based on bidirectional linked list - Google Patents

SD card data access method based on bidirectional linked list Download PDF

Info

Publication number
CN114610652A
CN114610652A CN202210299342.2A CN202210299342A CN114610652A CN 114610652 A CN114610652 A CN 114610652A CN 202210299342 A CN202210299342 A CN 202210299342A CN 114610652 A CN114610652 A CN 114610652A
Authority
CN
China
Prior art keywords
node
data
linked list
card
reading
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210299342.2A
Other languages
Chinese (zh)
Inventor
葛化敏
冯宇彤
吴志恒
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Nanjing University of Information Science and Technology
Original Assignee
Nanjing University of Information Science and Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Nanjing University of Information Science and Technology filed Critical Nanjing University of Information Science and Technology
Priority to CN202210299342.2A priority Critical patent/CN114610652A/en
Publication of CN114610652A publication Critical patent/CN114610652A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F12/00Accessing, addressing or allocating within memory systems or architectures
    • G06F12/02Addressing or allocation; Relocation
    • G06F12/0223User address space allocation, e.g. contiguous or non contiguous base addressing
    • G06F12/023Free address space management
    • G06F12/0238Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory
    • G06F12/0246Memory management in non-volatile memory, e.g. resistive RAM or ferroelectric memory in block erasable memory, e.g. flash memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/08Error detection or correction by redundancy in data representation, e.g. by using checking codes
    • G06F11/10Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's
    • G06F11/1004Adding special bits or symbols to the coded information, e.g. parity check, casting out 9's or 11's to protect a block of data words, e.g. CRC or checksum

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Quality & Reliability (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Memory System Of A Hierarchy Structure (AREA)

Abstract

The invention discloses a method for accessing SD card data based on a doubly linked list, which comprises the following steps: if the SD card is empty, a bidirectional data linked list of a head node and a tail node is established in a cache space of a creating unit of the SD card cache monitoring creating module; if the SD card is not empty, a bidirectional data linked list of a head node and a tail node is established in a cache space of a merging unit of the SD card cache monitoring and creating module; a head insertion storage method is adopted during sequential storage, a middle insertion storage method is adopted during middle storage, a tail deletion reading method is adopted during sequential reading, and a middle deletion reading method is adopted during middle reading; the invention establishes the double linked list for accessing data, can avoid the problem of incomplete read data caused by simultaneous access or different access pointer speeds, and can realize sequential storage and reading and the storage and reading of any position of the internal storage space by fully utilizing the characteristics of the double linked list.

Description

SD card data access method based on bidirectional linked list
Technical Field
The invention relates to a data access method, in particular to an SD card data access method based on a doubly linked list.
Background
SD cards are widely used in daily life and work, and have become the most common data storage card. SD cards are also used as their storage devices on devices such as MP3, digital cameras, and the like. The SD card is widely used because of its advantages such as low cost, large storage capacity, convenient use, and high versatility and safety. If the advantages of the SD card can be utilized, the SD card can be applied to a singlechip application development system, so that the system becomes more excellent, and the SD card has higher requirements on storage and reading. The storage and reading pointers of the existing SD card start at the same position, when the storage and the reading are carried out simultaneously, the speed of the pointers influences the situation of reading data, and when the reading pointer is faster than the storage pointer, the situation of incomplete reading data exists, and the like. The existing SD card can generate scattered cache when being used for a long time, and the scattered cache can reduce the reading speed to ensure that part of read data is incomplete.
The patent with application number CN201811624926.2 discloses a method for accessing secure digital SD card and a controller for SD card, which uses three addresses to store address expansion command, access command and memory location respectively. The method is realized by reading addresses, and has the disadvantages of single reading operation, single writing operation, multiple reading operation, multiple writing operation and erasing operation.
Disclosure of Invention
The purpose of the invention is as follows: the invention aims to provide an SD card data access method based on a double linked list, which maximizes the space of clusters, can effectively solve the problem of incomplete data caused by reading or reading and storing different speeds at the same time, solves the problems of slow or incomplete reading speed and the like caused by the existence of scattered cache, fully utilizes the characteristics of the double linked list, can realize sequential storage and reading, and can realize storage and reading at any position of a storage space.
The technical scheme is as follows: the SD card data access method based on the doubly linked list comprises a cache monitoring and creating module, wherein the cache monitoring and creating module comprises a monitoring unit for monitoring a scattered cache, a creating unit for creating clusters and a combining unit for combining the scattered cache and releasing the rest caches, and the method comprises the following steps:
(1) if the SD card is empty, a bidirectional data linked list of a head node, a middle node and a tail node is established in a cache space of a creating unit of the SD card cache monitoring creating module; if the SD card is not empty, a bidirectional data linked list of a head node, a middle node and a tail node is established in a cache space of a merging unit of the SD card cache monitoring creation module;
(2) and (3) a storage process: in the case of sequential storage, a head-on storage method is adopted to write the data to be stored in sequence from the head of the linked list; under the condition of intermediate storage, a position needing to be inserted is found by adopting an intermediate insertion storage method, and data to be stored is inserted;
(3) and (3) reading: in the case of sequential reading, reading from the tail of the data linked list by adopting a tail deletion reading method; and under the intermediate reading condition, finding the position of the data to be read by adopting an intermediate deletion reading method, reading the data, releasing the data node space, and combining a new cache space in a combining unit of the cache monitoring and establishing module.
Further, the plug-in storage method in the step (2) specifically includes the following steps:
(21) setting a node structure of a bidirectional linked list: dividing each node into a precursor pointer, a data area and a successor pointer;
(22) applying for distributing a linked list space to an internal storage space of the SD card, and applying for distributing a new node space to the internal storage space of the SD card;
(23) the data to be stored is placed in a data area of an ith node of a linked list, the initial value of i is 0, and i is less than or equal to n;
(24) the successor pointer of the new node points to the head node of the chain table, the predecessor pointer of the head node of the chain table points to the new node, and the head node becomes the new node;
(25) and (5) adding 1 to the value of i, and re-executing the steps (21) to (24) until all data is written.
Further, the intermediate insertion storage method in the step (2) specifically includes the following steps:
(31) setting a node structure of a bidirectional linked list: dividing each node into a precursor pointer, a data area and a successor pointer;
(32) applying for distributing linked list space to the internal storage space of the SD card, and applying for distributing a new node space to the internal storage space of the SD card;
(33) the successor pointer of the new node points to the next node to be inserted, the predecessor pointer of the new node points to the previous node to be inserted, the successor pointer of the previous node to be inserted points to the new node, and the predecessor pointer of the next node to be inserted points to the new node.
Further, the method for reading the end deletion in step (3) specifically includes the following steps:
(41) declaring a node q, wherein the node q points to a precursor node of a tail node;
(42) reading the data of the ith tail node of the double-linked list, releasing the space of the tail node, wherein the initial value of i is 0, and i is less than or equal to n;
(43) the tail node is changed into a node q, and a subsequent pointer of the tail node points to null;
(44) after the storage space is released, the cache monitoring and establishing module combines the scattered caches of the monitoring units and releases the rest cache space to form a new cache space;
(45) the value of i is added to 1 and steps (42) to (44) are repeated until all data are read.
Further, the intermediate deletion reading method in the step (3) specifically includes: and reading the data of the intermediate designated node, wherein the successor pointer of the predecessor node of the node points to the successor node of the node, and the predecessor pointer of the successor node of the node points to the predecessor node of the node, so that the node space is released.
Has the advantages that: compared with the prior art, the invention has the following remarkable advantages:
(1) the invention can maximize the space of the cluster, avoid generating a scattered cache region, monitor the scattered cache region in real time, combine the scattered cache region with the rest released cache, and effectively avoid the problems of low reading speed or incompleteness and the like.
(2) The invention can flexibly obtain a certain element, insert the element and delete the element, and the bidirectional linked list precursor and successor pointers improve the convenience of data access in the SD card and enable the element to be inserted and deleted more quickly. Compared with the common linked list, the insertion and deletion can be performed in situ without moving elements, and the bidirectional traversal can be performed, so that the characteristic of bidirectional access of the patent is realized.
(3) The invention can ensure the access integrity of the SD card: the pointer speeds of the SD card for storage and reading are different, which can cause the incomplete reading data, the problem of incomplete reading data caused by simultaneous access can be avoided by establishing the bidirectional linked list for data access in the SD card, and the characteristics of the bidirectional linked list are fully utilized, so that not only can the sequential storage and reading be realized, but also the storage and reading at any position of the internal storage space can be realized.
Drawings
FIG. 1 is a block diagram of a cache monitor creation module according to the present invention;
FIG. 2 is a schematic view of a linked list storage process of the present invention;
FIG. 3 is a schematic view of a linked list reading process of the present invention;
FIG. 4 is a circuit diagram of an SD card module;
FIG. 5 is a schematic diagram of a linked list sequential storage process of the present invention;
FIG. 6 is a schematic diagram of a process of inserting storage in the middle of a linked list according to the present invention;
FIG. 7 is a schematic diagram of a linked list sequential reading process of the present invention;
FIG. 8 is a diagram illustrating a middle insertion reading process of a linked list according to the present invention.
Detailed Description
The technical scheme of the invention is further explained by combining the attached drawings.
The structure of the buffer monitoring and creating module of the SD card is shown in fig. 1, and the whole module includes three units: the device comprises a monitoring unit, a creating unit and a merging unit. The monitoring unit is used for monitoring the scattered cache in the SD card and entering the scattered cache into the monitoring unit when the scattered cache is detected. The creating unit is used for creating clusters comprising 64 sectors to form a maximum cluster space, and zero-scattering cache generated by long service time of the SD card is avoided. The merging unit is used for merging the scattered caches monitored by the monitoring unit and releasing the rest caches, and merging the scattered caches into cache blocks.
The SD card can be used for storing data, and the space for storing the data is large. SD card Module Circuit As shown in FIG. 4, the SD card employs SDIO interface, which includes CLK, CMD and DAT [3:0] four data lines. The existing SD memory card is of a mesh structure and a matrix structure, is composed of small memory cells in a grid, and uses a Flash chip to store binary messages. The minimum unit of data read/write at a time by the SD card is 1 sector, that is, 512 bytes. Flash memories have a single transistor as a binary signal memory cell, and are very similar in structure to a conventional semiconductor transistor, except that a "floating gate" and a "Control gate" are added to the transistor of the flash memory. The floating gate is used for storing electrons, the surface of the floating gate is coated by a layer of silicon oxide insulator, and the floating gate is coupled with the control gate through a capacitor. When negative electrons are injected into the floating gate under the action of the control gate, the storage state of the NAND single transistor is changed from 1 to 0; and when negative electrons are removed from the floating gate, the memory state changes from 0 to 1. If data is to be written, the negative electrons in the floating gate must be removed completely, so that the target storage region is in the 1 state, and the writing action only occurs when data 0 is encountered, but the process takes a long time, so that the writing speed is always slower than the data reading speed.
Aiming at the problems that the data writing speed is slower than the reading speed caused by the access mode of the common SD card, and zero scattered cache is generated due to long service time, so that the SD card has the problems of slow and incomplete read data, the invention creates a bidirectional linked list in the cache region of the SD card cache monitoring creation module, stores the data into the bidirectional linked list, and simplifies the access process and steps by utilizing the advantages of the bidirectional linked list, and the specific access steps are as follows:
(1) if the SD card is empty, a bidirectional data linked list of head nodes, intermediate nodes and tail nodes is established in a maximized cluster space of a creating unit of the SD card cache monitoring creating module; if the SD card is not empty, combining scattered caches of the monitoring units and releasing the rest cache space in a combining unit of the SD card cache monitoring creation module, and establishing a bidirectional data linked list of a head node, a middle node and a tail node in the combining space;
(2) and (3) a storage process: in the case of sequential storage, a head-on storage method is adopted, and data to be stored is written in from the head of the linked list in sequence, as shown in fig. 2 and 5; in the case of intermediate storage, an intermediate insertion storage method is adopted to find a position to be inserted and insert data to be stored, as shown in fig. 2 and 6, the step can improve the diversity and flexibility of storage. The method specifically comprises the following steps:
(21) setting a node structure of a bidirectional linked list: dividing each node into a precursor pointer prior, a data area data and a successor pointer next;
(22) applying for distributing linked list space to the SD card storage sector, and applying for distributing a new node space malloc to the SD card storage sector;
(23) the data to be stored is placed in a data area of an ith node of a linked list, the initial value of i is 0, and i is less than n;
(24) and the successor pointer of the new node points to the head node p- > next ═ head of the chain table, the predecessor pointer of the head node of the chain table points to the head- > prior ═ p of the new node, and the head node becomes the head ═ p of the new node.
(25) The successor pointer of the new node points to the next node to be inserted s- > next ═ p, the predecessor pointer of the new node points to the previous node to be inserted s- > prior ═ p- > prior, the successor pointer of the previous node to be inserted points to the new node p- > prior- > next ═ s, and the predecessor pointer of the next node to be inserted points to the new node p- > prior ═ s.
The steps (21) to (24) are a cycle of sequential storage, and the sequential writing of one node data is completed; and (5) after the step (24) is completed, adding 1 to the value of i and re-executing the step (21) until all data is written. And (5) inserting and storing the intermediate arbitrary node in the steps (21), (22) and (25) to finish the writing of the intermediate node data.
(3) And (3) reading: in the case of sequential reading, reading is started from the tail of the data linked list by using a tail deletion reading method, as shown in fig. 3 and 7; in the case of intermediate reading, an intermediate deletion reading method is adopted to find the position of the data to be read, read the data, and delete the data node, as shown in fig. 3 and 8, which can improve the diversity and flexibility of reading. The method specifically comprises the following steps:
(31) declaring a node q, wherein the node q points to a precursor node q of a tail node, namely tail- > prior;
(32) reading data tail- > data of a tail node of the bidirectional link table, and releasing the space of the tail node;
(33) the tail node becomes node q, tail ═ q, and the tail node successor pointer points to empty tail- > next ═ NULL.
(34) After the storage space is released, the cache monitoring creation module merges the scattered caches of the monitoring units and releases the remaining cache space to become a new cache space.
(35) And reading the intermediate designated node data p- > data, wherein the successor pointer of the predecessor node of the node points to the successor node p- > prior- > next ═ p- > next, and the predecessor pointer of the successor node points to the predecessor node p- > next- > prior ═ p- > prior, so as to release the node space.
And (5) the steps (31) to (34) are a cycle of sequential reading, the sequential reading of the node data is completed, and after the step (34) is completed, the value of i is added with 1 and the step (32) is executed again until all data are read. And (35) deleting and reading any intermediate node to finish reading and deleting the intermediate node data.
(4) And when the SD card is initialized, destroying the bidirectional data linked list.
The predecessor pointer and successor pointer in the doubly linked list enable the data position to be found quickly and accurately in the access process, and when the data position is read from the tail portion more conveniently and quickly, the linked list data can be kept complete by writing from the head portion. The invention avoids the situation that the read data is not complete when the access is simultaneously carried out.

Claims (7)

1. An SD card data access method based on a doubly linked list is characterized in that an SD card comprises a cache monitoring and creating module, the cache monitoring and creating module comprises a monitoring unit for monitoring a scattered cache, a creating unit for creating clusters and a merging unit for merging the scattered cache and releasing the rest caches, and the method comprises the following steps:
(1) if the SD card is empty, a bidirectional data linked list of a head node, a middle node and a tail node is established in a cache space of a creating unit of the SD card cache monitoring creating module; if the SD card is not empty, a bidirectional data linked list of a head node, a middle node and a tail node is established in a cache space of a merging unit of the SD card cache monitoring creation module;
(2) and (3) a storage process: in the case of sequential storage, a head-on storage method is adopted to write the data to be stored in sequence from the head of the linked list; under the condition of intermediate storage, a position needing to be inserted is found by adopting an intermediate insertion storage method, and data to be stored is inserted;
(3) and (3) reading: in the case of sequential reading, reading from the tail of the data linked list by adopting a tail deletion reading method; and under the intermediate reading condition, finding the position of the data to be read by adopting an intermediate deletion reading method, reading the data, releasing the data node space, and combining a new cache space in a combining unit of the cache monitoring and establishing module.
2. The doubly-linked list-based SD card data access method as claimed in claim 1, wherein said header storage method in step (2) comprises the following steps:
(21) setting a node structure of a bidirectional linked list: dividing each node into a precursor pointer, a data area and a successor pointer;
(22) applying for distributing linked list space to the internal storage space of the SD card, and applying for distributing a new node space to the internal storage space of the SD card;
(23) the data to be stored is placed in a data area of an ith node of a linked list, the initial value of i is 0, and i is less than or equal to n;
(24) the successor pointer of the new node points to the head node of the chain table, the predecessor pointer of the head node of the chain table points to the new node, and the head node becomes the new node;
(25) and (5) adding 1 to the value of i, and re-executing the steps (21) to (24) until all data is written.
3. The doubly linked list-based SD card data access method according to claim 1, wherein the intermediate insertion storage method in the step (2) specifically includes the following steps:
(31) setting a node structure of a bidirectional linked list: dividing each node into a precursor pointer, a data area and a successor pointer;
(32) applying for distributing linked list space to the internal storage space of the SD card, and applying for distributing a new node space to the internal storage space of the SD card;
(33) the successor pointer of the new node points to the next node to be inserted, the predecessor pointer of the new node points to the previous node to be inserted, the successor pointer of the previous node to be inserted points to the new node, and the predecessor pointer of the next node to be inserted points to the new node.
4. The SD card data reading method based on the bi-directional data linked list according to claim 1, wherein the end-to-end reading method in step (3) specifically comprises the following steps:
(41) declaring a node q, wherein the node q points to a precursor node of a tail node;
(42) reading the data of the ith tail node of the double-linked list, releasing the space of the tail node, wherein the initial value of i is 0, and i is less than or equal to n;
(43) the tail node is changed into a node q, and a subsequent pointer of the tail node points to null;
(44) after the storage space is released, the cache monitoring and establishing module combines the scattered caches of the monitoring units and releases the rest cache space to form a new cache space;
(45) the value of i is added to 1 and steps (42) to (44) are repeated until all data are read.
5. The SD card data reading method based on the bidirectional data linked list according to claim 1, wherein the intermediate deletion reading method in the step (3) is specifically: and reading the data of the intermediate designated node, wherein the successor pointer of the predecessor node of the node points to the successor node of the node, and the predecessor pointer of the successor node of the node points to the predecessor node of the node, so that the node space is released.
6. The doubly-linked list-based SD card data access method of claim 1, wherein the doubly-linked list is destroyed when the SD card is initialized.
7. The doubly-linked list-based SD card data access method as claimed in claim 1, wherein the clusters created by the creation unit include 64 sectors.
CN202210299342.2A 2022-03-25 2022-03-25 SD card data access method based on bidirectional linked list Pending CN114610652A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210299342.2A CN114610652A (en) 2022-03-25 2022-03-25 SD card data access method based on bidirectional linked list

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210299342.2A CN114610652A (en) 2022-03-25 2022-03-25 SD card data access method based on bidirectional linked list

Publications (1)

Publication Number Publication Date
CN114610652A true CN114610652A (en) 2022-06-10

Family

ID=81866032

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210299342.2A Pending CN114610652A (en) 2022-03-25 2022-03-25 SD card data access method based on bidirectional linked list

Country Status (1)

Country Link
CN (1) CN114610652A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115576501A (en) * 2022-12-06 2023-01-06 苏州浪潮智能科技有限公司 Node updating method, system and related device of RAID card

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115576501A (en) * 2022-12-06 2023-01-06 苏州浪潮智能科技有限公司 Node updating method, system and related device of RAID card

Similar Documents

Publication Publication Date Title
CN108459974B (en) High bandwidth memory device integrating flash memory
CN104461964B (en) A kind of storage device
US6134151A (en) Space management for managing high capacity nonvolatile memory
US9058254B2 (en) Memory device
JP5002201B2 (en) Memory system
CN109977034B (en) Data storage device and non-volatile memory operation method
KR20070085481A (en) Memory system and method of writing into nonvolatile semiconductor memory
CN104575595B (en) The storage device of non-volatile random access
CN110347613B (en) Method for realizing RAID in multi-tenant solid-state disk, controller and multi-tenant solid-state disk
CN1833291A (en) High density flash memory with high speed cache data interface
US8429339B2 (en) Storage device utilizing free pages in compressed blocks
CN106528443B (en) FLASH management system and method suitable for spaceborne data management
CN112130749B (en) Data storage device and non-volatile memory control method
CN114610652A (en) SD card data access method based on bidirectional linked list
WO2023196249A1 (en) Aligned and unaligned data deallocation
CN114281265B (en) Storage medium failure processing method and device and solid state disk
CN109213423A (en) Concurrent I/O command is handled without lock based on address barrier
CN113986773A (en) Write amplification optimization method and device based on solid state disk and computer equipment
CN111580757A (en) Data writing method and system and solid state disk
CN105608014B (en) A kind of storage device using MRAM
CN111324284B (en) Memory device
CN109002265B (en) Data processing method and related device
KR20090046568A (en) Flash memory system and writing method of thereof
CN112083883A (en) Storage system and method for use in storage system
CN111737199B (en) Operation method of embedded anti-power-down file system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination