Why not create an OS that runs in ram

memoryoperating systems

this might be the wrong StackExchange site to ask this question, but I couldn't find one better. There doesn't seem to be one for questions about Operating Systems.

I've been thinking recently about an OS that runs purely in ram, and that it would have a lot of benefits.

  • It would be much simpler to create such an OS, because you wouldn't have to deal with filesystems, caching, etc.
  • It would be much faster.
  • Programs would be easier to write because they wouldn't need to load or save anything.
  • Instead of writing source code and then compiling, programs could be directly manipulated in memory. REPLs get somewhere near this, but why not go all the way? Also LightTable is like this in that it 'lets you modify running programs', but I think it can be taken further. Obviously we would need some other way of manipulating/building programs in memory.
  • Databases would be massively simplified, as there would be no query-caching to do. They might not even be necessary at all.
  • No booting or shutting down necessary

Obviously there are problems with this approach:

  • Memory is volatile: You would have to change the hardware so that memory was always kept alive with a backup battery or something.
  • There are lots of situations where data will be too big to fit in ram. E.g. large websites with massive databases, people with huge music/video collections, etc. However, most people don't have huge video collections, they stream stuff from netflix. I.e. look at the success of the ChromeBook, which only has a 16gb SSD.
  • updating the OS in memory could be tricky, but some languages already do this e.g. Java, Erlang hot-swapping

Anyway, I must be missing something otherwise all the computer scientists who are much more intelligent than me would have done this already, but what is it?

Best Answer

You can't use RAM effectively if all you have is RAM for two reasons:

  1. If a page is dirty but not accessed, you have to keep it in RAM, even though you'd rather use RAM for other things.

  2. Any time an application might use memory or might not, you have to say no unless you can accommodate every reservation you've already made, even if most of those reservations are unlikely to ever be used, because otherwise you'd have to forcibly terminate processes.

So all you have is RAM, and you can't use it effectively. That would be a horrible recipe for a general-purpose operating system.

But the basic reason this is a bad idea is this simple -- having things other than RAM doesn't force you to use them. It simply allows you to use them if it's beneficial. You can't make things better by taking away options.

Related Question