Page file on RAM disk

Programming, for all ages and all languages.
Post Reply
User avatar
AndrewAPrice
Member
Member
Posts: 2302
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Page file on RAM disk

Post by AndrewAPrice »

Does anyone know of a practical use with storing a page file on a RAM disk?
My OS is Perception.
urxae
Member
Member
Posts: 149
Joined: Sun Jul 30, 2006 8:16 am
Location: The Netherlands

Re: Page file on RAM disk

Post by urxae »

MessiahAndrw wrote:Does anyone know of a practical use with storing a page file on a RAM disk?
...
No, I think that's pretty much useless in practical circumstances.
Page files are meant to fake a larger memory capacity by using disk space instead, RAM disks are used to fake disk space by using memory instead. They're opposite concepts.

You could use it to test paging without wondering if any errors are caused by errors in the disk driver, though. (assuming you're confident your RAM disk code works, of course)
Does that count as "practical"? That's not practical use for the users of an OS, but it might be for the developers...
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

I could come up with some esoteric combinations where the RAM disk is some network-mapped memory of some other machine but still faster than local hard drive or somesuch... but out in the wild? I don't think so.
Every good solution is obvious once you've found it.
User avatar
AndrewAPrice
Member
Member
Posts: 2302
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

What would happen if you ran a memory intensive program and the OS tried to copy the RAM disk driver into the swap file?
My OS is Perception.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

...swapping out the RAM disk driver...?

Why on earth should an OS do that? I mean... just why? That's almost as senseless as swapping out the hard disk driver...
Every good solution is obvious once you've found it.
User avatar
AndrewAPrice
Member
Member
Posts: 2302
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Post by AndrewAPrice »

I ment, swap the RAM disk into the swap file, while the swap file is stored an a RAM disk!
My OS is Perception.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Post by Solar »

Depending on the "brains" of the system, either all hell breaks loose or the safety catch is triggered. ;)
Every good solution is obvious once you've found it.
Crazed123
Member
Member
Posts: 248
Joined: Thu Oct 21, 2004 11:00 pm

Post by Crazed123 »

Or, of course, the pager program knows better than to even try.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Page file on RAM disk

Post by Brendan »

Hi,
MessiahAndrw wrote:Does anyone know of a practical use with storing a page file on a RAM disk?
If you've got a video card with 128 MB of RAM but the OS only uses VESA for video on that card and the highest resolution the card supports is 1024 * 768 * 32 bpp, then you'll have about 124 MB of RAM sitting there doing nothing. ;)


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Tyler
Member
Member
Posts: 514
Joined: Tue Nov 07, 2006 7:37 am
Location: York, England

Re: Page file on RAM disk

Post by Tyler »

Brendan wrote:Hi,
MessiahAndrw wrote:Does anyone know of a practical use with storing a page file on a RAM disk?
If you've got a video card with 128 MB of RAM but the OS only uses VESA for video on that card and the highest resolution the card supports is 1024 * 768 * 32 bpp, then you'll have about 124 MB of RAM sitting there doing nothing. ;)


Cheers,

Brendan
That is not really a RAM Drive though, merely alternative storage, that happens to be RAM that is not in Main Memory... the same as an electronic drive with self buffering RAM.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re: Page file on RAM disk

Post by Candy »

MessiahAndrw wrote:Does anyone know of a practical use with storing a page file on a RAM disk?
Having RAM that you can't use as normal RAM but that you can use as RAM disk. Video card RAM, PCI bus bound RAM, some odd type of configuration your OS doesn't get, broken memory you've explicitly disabled (but do wish to use the upper half of), some OS that can't comprehend high memory (>1M, >4G, >900M, take your pick).
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

If you were going to use that memory space as a ramdisk and put the pagefile up there, why not just get rid of the pagefile and use that memory as normal memory. It just seems kind of circular to me.
User avatar
AndrewAPrice
Member
Member
Posts: 2302
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: Page file on RAM disk

Post by AndrewAPrice »

Brendan wrote:Hi,
MessiahAndrw wrote:Does anyone know of a practical use with storing a page file on a RAM disk?
If you've got a video card with 128 MB of RAM but the OS only uses VESA for video on that card and the highest resolution the card supports is 1024 * 768 * 32 bpp, then you'll have about 124 MB of RAM sitting there doing nothing. ;)


Cheers,

Brendan
You're a genious!! Can I store my RAM disk on my video card?

Does anyone know any documentation on accessing video card memory?
My OS is Perception.
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Page file on RAM disk

Post by Brendan »

Hi,
MessiahAndrw wrote:You're a genious!! Can I store my RAM disk on my video card?

Does anyone know any documentation on accessing video card memory?
It's simple enough - use PCI configuration space to map the video card's display memory at a physical address (or PCI or VESA to find out where it was mapped by the BIOS) and use VESA to determine how much RAM is present in the video card. Then get a list of video modes from VESA and work out the amount of memory each video mode actually needs ("lines * bytes_per_line") - the largest video mode is the amount of space to reserve for video.

Of course if your OS will only ever use one video mode then you don't need to care about the amount of memory other video modes would've used (or you could refuse to use any video mode that takes more than 4 MB and use the remainder for swap).

Then do "RAM_disk_start_address = video_physical_address + reserved_space" (and round it up to the nearest page), and "RAM_disk_size = video_card_RAM - reserved_space" (and round it down to the nearest page).

Once you've got the address and size of the RAM disk you'd need to map that somewhere (if you use paging). You may also need to be a little careful about how you access this RAM. For example, in a multi-CPU system, if write-combining is enabled you'll need to make sure the write-combining buffers are flushed before allowing other CPUs to access the data (otherwise another CPU could try to read the data from RAM before the first CPU has written it).

Of course if you actually use the extra video RAM you can't do this - for e.g. if you're storing textures in there, if you're doing page flipping, if you're doing hardware scrolling, etc. In this case you need to reserve more video RAM for video, or stop using it as swap space.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Post Reply