I'd greatly appreciate advice and code snippets on how to create a ram
disk within a C/C++ program.
I also need to be able to determine the free space.
Thanks in advance for any help.
Yikes! -- I just realized how specific and problematic something I use
to do back in 1986 has become! Anybody remember the $1986 AT&T model
6300 sold in the year 1986? With that dual floppy 8 k byte ram green
monochrome monitor system I used a ram disk to speed things up. Floppy
drive reads were very slow. From the comments received I have gleaned
at least a few things.
1) The route I was hoping to take may not be the best choice.
2) The task is VERY sensitive to the operating system.
3) Some folks in here absolutely hate usage of the ++ tag onto there
favorite language C. Additionally they have little patience with
anyone who has diminutive skills compared to themselves. I certainly
apologized, if needed, for using the ++ and I really am trying to
become less stupid.
Even though it would be ideal for there to be an established news
group of experts for my particular challenge ... I will again wish for
some additional advice here in this group. After all ... my program
(that I have worked years on) is about 96% C and 4% ++. Additionally,
the ++ groups seem to be even faster in slamming up barriers and
crying out that you are in the wrong place! But again, what I hope to
do is within a C program and not something done purely at the
operating system level. Perhaps it is too cumbersome to create the
actual ram disk in C? But that still leaves my need to determine the
free space within the C code and provide logic that
manages the ram drive appropriately.
=====================================================================
Additional information for those kind enough to have read this far >>
1) - I have a very large sequential data file. Approximately 400 M
byte in size. As I process this data I need to dynamically optimize on
a moving window of smaller size (approximately 20 M byte window size).
Specifically, the large file contains 20+ years of S&P index data and
the window represents a smaller time frame of this same data. The
optimization program is iterative and is used to generate settings for
forward performance evaluation. The program and the method are thus
totally blind to the future data and this provides a realistic test of
the method's long term robustness.
The optimization method iterates through the moving window 100's of
times before declaring the multi-dimensional, non-linear topology
space adequately searched. I have been using file pointers to reset to
the beginning of the moving window for each iteration. This works but
I have no clue about how efficient the cache management system is
working. I have no information on how many times blocks of data are
being read from the hard drive. I do know the program is slow. It can
take 60 hours to process 7 years of data while moving the edge of the
window every 3 months.
In the past I tried using very large storage arrays. My system has
sufficient memory ... but once I set the array size above
approximately 600,000 the program will not compile. This is
troublesome because Microsoft's help reference indicates that arrays
can be of size_t which provides a limit of 0x7CFFFFFF (or
2,097,151,999 -- if I correctly converted).
Most likely there are better ways to solve the problem than using a
Ram disk, but I am clueless to what they may be. I am certainly open
to all suggestions!!
The program does work when digesting the full data file. I have tuned
up the entire 20+ years to one set of parameters successfully;
however, this in itself does not demonstrate dynamic tuning
efficiency.
I was hoping to put the moving window data into ram to speed up data
throughput and possible reduce hard drive wear and tear. When I run
the program; about 1/2 of my system's 1 Gig of memory is not being
used ... So there is plenty of memory available. The program is to
clear the memory space and reload data only when the window is moved.
Not when simply iterating through the data for the tuning of that
specific time period. Also the program is to include logic to prevent
writing too much data to the ram disk.
2) I am using Win 2000 and Visual C++.NET.
3) Whether you can provide helpful suggestions or not ... I thank you
having read the above. Best wishes to all.
-- Tom