Re: How can I create a Ram Disk within C/C++ program?



Tom wrote:
On Mon, 28 Aug 2006 05:10:48 GMT, Tom <Thomas-911@xxxxxxxxxxxxx>
wrote:

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.

It's no more difficult and no less system specific than it was back then. The difference is that if you are doing it to speed things up you are quite possibly wasting your time and effort. Ever head of caching? It's something some OSs are quite good at.

> 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.

True. If the user wants your data files on a RAM disk they can create one and put them there. Such as on Linux making /tmp a ram disk.

2) The task is VERY sensitive to the operating system.

Yes.

3) Some folks in here absolutely hate usage of the ++ tag onto there
favorite language C.

Not necessarily. It is just that C++ is a very different language with its own new group. So C++ is no more or less topical here than Fortran, ML, TMS320C25 assembler or any of the other languages other than C that I have used.

> Additionally they have little patience with
anyone who has diminutive skills compared to themselves. I certainly

No, people have a lot of patience with those who have little knowledge or skill. We have recently had some threads where people with little knowledge or skill but who wanted to learn and were asking topical (if simple) questions where the posts were not merely answered but the original posters complimented. The difference is they were asking C questions.

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.

Complaining at us is not the best method I've ever seen of getting advice.

> 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.

C knows nothing of disks, file systems, space, caching, ram disks or lots of other stuff. It does know about streams, but which the file name means is entirely up to the system and nothing to do with C.

> Perhaps it is too cumbersome to create the
actual ram disk in C?

You can't in C and you never have been able to. You may be able to do it with OS specific extensions but that discussion belongs in an OS specific group.

> But that still leaves my need to determine the
free space within the C code and provide logic that manages the ram drive appropriately.

You can't with standard C. You will have to ask how to do that in a group dedicated to your system.

<snip>

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.

Then profile it. Until you have *measured* and *know* what the bottle neck is there is no point in doing anything.

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).

Since size_t is not a number I'm and SIZE_MAX is unlikely to be 0x7CFFFFFF I suspect you have misread it. Ask in a Windows news group since all we know is it is allowing arrays a lot larger than the standard says it has to.

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!!

<snip>

Then I *seriously* suggest you profile it. It is possible that even Windows can manage caching well enough these days and that your problem is something different.
--
Flash Gordon
Being helpful despite the attitude shown at the start of Tom's post not because of it.
.



Relevant Pages

  • Re: How can I create a Ram Disk within C/C++ program?
    ... I also need to be able to determine the free space. ... monochrome monitor system I used a ram disk to speed things up. ... a moving window of smaller size. ...
    (comp.lang.c)
  • Re: Problem with "man"; httpd slow
    ... Httpd has to be loaded from the disk each time it is invoked. ... Disk access ... You mean something like increasing the RAM disk inside the boot loader? ... I had too many computers and it ...
    (comp.os.minix)
  • Re: Anyone turned their pagefile off on XP?
    ... drive - even if you have excess memory. ... running a swapfile of RAM disk shouldn't cause too many problems. ... Windows's virtual memory system ceases to be important, ...
    (uk.comp.homebuilt)
  • Re: computer swap space
    ... > remnants of the plaintext or keyin the computer swap space for the ... only ciphertext back to the hard disk. ... If no plaintext hits the hard ... files etc. live on the RAM disk too). ...
    (sci.crypt)
  • Re: FAT32 or NTFS?
    ... >>10% wastage on 10 volumes is one whole hard disk wasted. ... >uncertainty about free space. ... Corrupt data can be better than none, ... "you can only recover part of the database". ...
    (microsoft.public.windowsxp.general)