Accident history table or queue?

I am trying to create an alarm history structure that will be stored in non-volatile flash memory. Flash memory has a limited number of write cycles, so I need a way to add records to the structure without overwriting all flash pages in the structure each time or writing updated queue head / tail pointers.

Also, as soon as the available flash space has been used up, I want to start overwriting the entries previously stored in the flash, starting with the first entry that was added first for the first time. This makes me think that the circular buffer is best for adding elements. However, when viewing records, I want the structure to work as a stack. For example. Records will be displayed in reverse chronological order for the last time.

The size of the structure, head, tail, indices cannot be saved if they are not stored in the record itself, because if they were written out each time in a fixed place, this would exceed the maximum recording cycles on the page where they were saved.

So should I use a stack, queue, or some kind of hybrid structure? How to store head, tail and size information in flash memory so that it can be reinitialized after power up?

+5
source share
6 answers

See the related question Circular buffer in Flash .

+5
source

Search ring buffer

Assuming you can work out what is the last record (from a timestamp, etc., so you don't have to write a marker), this also has better performance in terms of wear.

+4
source

: OP: . - .

, , , .

, - .

+2

. , - ... .

0

. , , . ( nbr > 2 * ), , .

0

, , , , . , , , , . , .

0

All Articles