mk79 wrote:bwinkel67 wrote:The only internal difference that I can deduce is that there is a while loop using fseek() to figure out the size of a file (doing so in 64 byte blocks)
I must say I find it almost comical that the provided LIBC doesn't provide a better way.
Yeah, it's weird. The only file I/O they provided besides opening, seeking, and closing is delete...why delete?
mk79 wrote:
Only way I see is
Code: Select all
long src[8];
long ret[8];
src[0] = 0x42;
src[1] = -1;
src[3] = -1;
src[4] = fd;
trap3(src, ret);
// file size now in ret[1]
Ha, I had looked at using that trap but somewhere it read I needed a 64
byte buffer (on top of the src and ret arrays) and so it seemed less trivial than what you just wrote so I will give it a go. I'm already using trap3 for getting I/O and this seems just as simple -- thanks!
mk79 wrote:
Is it really worth putting up with this very limited compiler?
I like optimization problems and they can formulate themselves differently in different contexts. Using a limited resource and finding ways around obstacles can be a good intellectual challenge. The idea of implementing my own internal heap structure is getting more appealing (I've taught the various ways they formulate but don't get much use in practical circumstances). It also keeps the mind off of the current news cycle and in the US it ain't good presently. Plus, my server at school crashed a month ago and I can't get in there as the entire A/C unit is being replaced and they don't want anyone in there until completed so I can't work on research which is what summers are for (I do speech recognition, another challenging optimization task wrapped in probability theory).
mk79 wrote:
before it does the malloc (and it fails on the malloc before it actually reads in the file). So I speculate that QDOS has read in part of the file while fseeking through it and is using part of the heap leaving the file in cache.
File caching is done in the slave blocks, which reside in the "free" memory, not in the heap. What will get allocated in the heap is the channel block, i.e. when opening the file. I'd be VERY surprised if seeking had any impact.
Oh, so literally a small chunk of memory is fragmenting the heap for me in that instance...D'oh. I will look to use the trap3 to get file size and allocate memory before opening. I think I'll get the whole thing implemented (still need to add floating point) before I optimize its memory usage into a single 16K chunk with its own internal heap.
Many thanks!