Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Fast calculation of free size

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> AVR-DOS
View previous topic :: View next topic  
Author Message
mpe

Bascom Member



Joined: 31 Jul 2007
Posts: 13

denmark.gif
PostPosted: Thu Aug 07, 2008 2:49 pm    Post subject: Fast calculation of free size Reply with quote

The DISKFREE() function can be very slow. I have found about 30 s for an nearly empty 2 GB SD-RAM and the CPU running at 7.3 MHz! Sad
Can anybody suggest a faster way to find the size of the free RAM.
Back to top
View user's profile
taroosheh

Bascom Member



Joined: 16 Mar 2007
Posts: 32
Location: Iran

iran.gif
PostPosted: Sun Sep 28, 2008 8:40 pm    Post subject: hi Reply with quote

in my project this problem is very bad because this command get 3 seconds or more than

I had to define a long variable and at startup this function called and any times when generate a file or delete add/minus with this variable but this method not very good

I am working on memory allocation table in FAT independence form AVR-DOS maybe this problem solved with any way

good luck

http://www.electrorc.blogfa.com
Back to top
View user's profile Yahoo Messenger
oe9vfj

Moderator



Joined: 17 Jun 2004
Posts: 269
Location: Austria, Hard

austria.gif
PostPosted: Fri Feb 20, 2009 10:12 am    Post subject: Reply with quote

DISKFREE counts in all FAT-Sectors the free Cluster entries and calculates the Free Disk-space.
The main factor for the time, which DISKFREE needs to do its job is the count of FAT-sectors to check.
I use a 2GB SD-Card from SanDisk (Speed Class 2) and DISKFREE needs less than 1 second to calculate the free Disk space.
This Card is formatted with FAT16 and have 236 FAT-Sectors.
A Card with 2GB formatted in FAT32 have appr. 3800 FAT Sectors. So DISKFREE uses on a FAT32 appr. 16 times the time to get the free disk space.
Cards up to 2GB can be formatted with FAT16.
FAT16 has one disadvantage if you save a lot of very small files. On a 2GB Card the smallest allocation Unit is 32KB, so every File will need at least 32 KB on a 2GB Card formatted with FAT16.
If the majority of your files have 32KB or more, FAT16 will be the better option to format a 2GB Card.

_________________
regards Josef

DOS - File System for BASCOM-AVR on http://members.aon.at/voegel
Back to top
View user's profile Visit poster's website
mpe

Bascom Member



Joined: 31 Jul 2007
Posts: 13

denmark.gif
PostPosted: Sat May 23, 2009 5:10 pm    Post subject: Free size Reply with quote

I am more or less forced to use FAT32 as most of my files are about 10k and the maximum size is 24k.
But my problem was wrongly formulated. I am not really interested in the total free space, but I only want to know, if there is free space for the next file. Therefore. I am modifying the routine to check for 100k free space. This is fast and gives the information I need. The needed time is also independant of the total free size, so I can optimize the code.
Back to top
View user's profile
anatom

Bascom Member



Joined: 06 Dec 2005
Posts: 93

slovenia.gif
PostPosted: Tue Oct 22, 2013 11:01 am    Post subject: Re: Free size Reply with quote

mpe wrote:
I am more or less forced to use FAT32 as most of my files are about 10k and the maximum size is 24k.
But my problem was wrongly formulated. I am not really interested in the total free space, but I only want to know, if there is free space for the next file. Therefore. I am modifying the routine to check for 100k free space. This is fast and gives the information I need. The needed time is also independant of the total free size, so I can optimize the code.


As I have exact same problem I'd ask if you can explain how you modified routine?
Back to top
View user's profile
Tiny

Bascom Member



Joined: 10 Nov 2010
Posts: 101
Location: The Netherlands

netherlands.gif
PostPosted: Thu Apr 04, 2019 7:18 am    Post subject: Reply with quote

Please will you share with you have modified, I also only need to know if there is freespace for the next logfile.
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> AVR-DOS All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum