memory allocation in Storage Media

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Okay lads, whats your thinking about memory allocation for storage media.  When opening a file would you allocate for the entire contents or only a segment of a file for example?

Also, when a folder is deleted on a FAT filing system the contents are marked as deleted, so when do you actually mark the contents as free?

Wm.

 

EDITTED: I have 512MBytes of DDR 

Last Edited: Sun. May 19, 2019 - 07:38 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In general, you assume the file won't fit in memory. In an embedded project, you don't have much memory.

The largest known prime number: 282589933-1

In my humble opinion, I'm always right. 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What "memory" are you talking about? Do you mean flash with FAT? If so then it's clear isn't it? You allocate one AU at a time as you need it. The moment you reach the last byte in the last sector of the last allocation unit of a file you go back to the FAT and allocate a new AU.

 

As for deletion/reuse. When a directory is deleted you need to recursively visit every dir/file within it and delete one at a time. Each will delete the entire chain of AUs in the FAT. At the highest level when a file/dir us deleted it's marked E5. When you later come to add a new file you iterate the directory and reuse the first slot that starts with either E5 or 00.

 

I guess you could forget E5 if you don't mind deletion being permanent and just wipe entire entries to 32 bytes of 00 when you erase.