Run a computer without RAM?

95,232

Solution 1

At some point this gets into the question of what even counts as "RAM." There are many CPUs and microcontrollers that have plenty of on-chip memory to run small operating systems with no separate RAM chips attached. In fact, this is actually relatively common in the world of embedded systems. So, if you're just referring to not having any separate RAM chips attached, then, yes, you can do it with many current chips, especially those designed for the embedded world. I've done it myself at work. However, since the only real difference between addressable on-chip memory and separate RAM chips is just the location (and, obviously, latency,) it's perfectly reasonable to consider the on-chip memory to itself be RAM. If you're counting that as RAM, then the number of current, real-world processors that would actually run without RAM is greatly reduced.

If you're referring to a normal PC, no, you can't run it without separate RAM sticks attached, but that's only because the BIOS is designed not to attempt to boot with no RAM installed (which is, in turn, because all modern PC operating systems require RAM to run, especially since x86 machines typically don't allow you to directly address the on-chip memory; it's used solely as cache.)

Finally, as Zeiss said, there's no theoretical reason that you can't design a computer to run without any RAM at all, aside from a couple of registers. RAM exists solely because it's cheaper than on-chip memory and much faster than disks. Modern computers have a hierarchy of memories that range from large, but slow to very fast, but small. The normal hierarchy is something like this:

  • Registers - Very fast (can be operated on by CPU instructions directly, generally with no additional latency,) but usually very small (64-bit x86 processor cores have only 16 general-purposes registers, for instance, with each being able to store a single 64-bit number.) Register sizes are generally small because registers are very expensive per byte.
  • CPU Caches - Still very fast (often 1-2 cycle latency) and significantly larger than registers, but still much smaller (and much faster) than normal DRAM. CPU cache is also much more expensive per byte than DRAM, which is why it's typically much smaller. Also, many CPUs actually have hierarchies even within the cache. They usually have smaller, faster caches (L1 and L2) in addition to larger and slower caches (L3.)
  • DRAM (what most people think of as 'RAM') - Much slower than cache (access latency tends to be dozens to hundreds of clock cycles,) but much cheaper per byte and, therefore, typically much larger than cache. DRAM is still, however many times faster than disk access (usually hundreds to thousands of times faster.)
  • Disks - These are, again, much slower than DRAM, but also generally much cheaper per byte and, therefore, much larger. Additionally, disks are usually non-volatile, meaning that they allow data to be saved even after a process terminates (as well as after the computer is restarted.)

Note that the entire reason for memory hierarchies is simply economics. There's no theoretical reason (not within computer science, at least) why we couldn't have a terabyte of non-volatile registers on a CPU die. The issue is that it would just be insanely difficult and expensive to build. Having hierarchies that range from small amounts of very expensive memory to large amounts of cheap memory allows us to maintain fast speeds with reasonable costs.

Solution 2

It would be theoretically possible to design a computer to operate with very little (a few registers' worth) or no RAM (look up the definition of a Turing machine -- which can actually be constructed in a suitably large/fast implementation of Conway's Life simulation).

The reason all real-world computers use RAM is, first, historical: core memory (the prototype for RAM, only semi-volatile) greatly predates mass storage like magnetic drum or disk (though it did come after punch cards and paper tape -- the former of which dates back, in its primitive form, to 1801 (yes, the start of the 19th century; Jacquard looms used punched cards to automatically weave a color pattern of arbitrary complexity decades before even Babbage Difference Engines or Hollerith tabulators); secondly, RAM (like core memory), being electronic, is a great deal faster than any device that depends on physical movement of the storage media to present the data to a read/write mechanism.

A system or similar complexity to a modern Windows or Linux computer running without RAM (similarly to a true Turing machine), would take days just to start up, and hours to update the screen for a graphic interface at modern resolutions. Even a text-only operating system comparable to CP/M or early versions of DOS would take a very long time to reach the initial command prompt.

Solution 3

ALL modern, standard, general-purpose CPUs fundamentally work like this:

  • CPU maintains a register that points in its address space to the next instruction
  • CPU fetches whatever is in that address space and increments that register
  • If instruction needs additional information, like a destination address or other operand, it is also fetched
  • CPU executes instruction
  • If instruction is a jump, call, return, return-from-interrupt or branch, it may modify the register that points to the next instruction.
  • Repeat

CPU fetches whatever is in that address space and increments that register

What can "live" in an address space?

  • Nothing (can return zeros, random data, or cause CPU to lockup)
  • RAM (motherboard RAM, RAM from a PCI device such as a graphics adapter, etc.)
  • ROM
  • Registers of an I/O device (this includes "internal I/O devices" like the CPU's local APIC)
  • Modern CPUs allow "cache as RAM" so a portion of the CPUs cache can appear in the address space

Notice "hard disk" is not in that list. The hard disk is not directly connected to the CPU. Data comes to and forth of the hard disk by way of an I/O device (SATA host adapter) connected to the CPU.

The I/O device uses DMA to load/save data to/from the hard disk. This means the I/O device directly reads/writes RAM itself - without CPU intervention - and also relies on RAM being there. But if the data has not been loaded into RAM by the I/O device the CPU has no chance of seeing it.

So you cannot have the CPU fetch instructions directly from the hard disk.


What happens during a page fault is:

  • CPU attempts to access a page of memory that is marked as swapped out in the local CPU page tables (which are always present in RAM.)
  • This access causes a page fault exception in the CPU.
  • CPU, now in kernel mode, looks at the page the other process was trying to access.
  • The kernel notices a user process is trying to access a swapped out page, and invokes the normal I/O process to swap that page back in from disk. This is the same process that would be used when loading/saving any other data from disk. It's not different just because the CPU is paging in swapped memory.
  • CPU then hands control back to the interrupted process, which continues as though nothing has happened.

So the CPU needing to get data from the disk because memory is swapped out is no different.

Solution 4

You can, because when an x86 CPU starts, L2 cache is initially a SRAM before used as cache. So you can write your own bios in order to not initialize the RAM and use only the small amount of SRAM inside the CPU as RAM rather than L2/L3 cache.

Just read BIOS guidelines from CPU manufacturers.

Solution 5

A personal computer requires RAM to run. Every application launched from the harddisk will be copied to RAM first before it is being executed.

So if you do not have any RAM in your computer, your computer will not start up, probably give you several warning beeps to let you know that there isn't any RAM installed.

Share:
95,232

Related videos on Youtube

akash ujjwal
Author by

akash ujjwal

Updated on September 18, 2022

Comments

  • akash ujjwal
    akash ujjwal over 1 year

    I was reading about CPU fetch time, where I found that CPUs take much less time to access data from RAM as compared to accessing a hard disk, and that RAM is present for storing the information and data of executing program.

    Then I wondered about what will happen when we only use a hard disk but no RAM?

    • Cornelius
      Cornelius over 9 years
    • akash ujjwal
      akash ujjwal over 9 years
      @Cornelius thanks for your reply i'll check it out :)
    • arch-abit
      arch-abit over 9 years
      What happens is some beeps then the screen turns blank.
    • marshal craft
      marshal craft over 5 years
      My question is, can i at least test that a graphics card is working? Would there be video or the monitor work minimally?
  • arch-abit
    arch-abit over 9 years
    Then you knock on your forehead and say "I should not have try to install these RAM-sticks in a carpeted environment with less than 10% humidity, in December 27th on the Northern Hemisphere?" Yes?
  • akash ujjwal
    akash ujjwal over 9 years
    @LPChip why it is stored to Ram what is the main purpose of it. To make system fast or reduce the access time, there is inbuilt cache to do it. Is i'am right or wrong?
  • Fiasco Labs
    Fiasco Labs over 9 years
    RAM is fast memory storage, disk access is slow, non-volatile memory storage and the CPU cache is there for other reasons.
  • Fiasco Labs
    Fiasco Labs over 9 years
    Yep, they were little metal rings that would be magnetized/demagnetized. en.wikipedia.org/wiki/Magnetic-core_memory (In reply to a comment about old vacuum tube computers that has been deleted)
  • akash ujjwal
    akash ujjwal over 9 years
    lkon your answer is too unique and very useful thanks :)
  • arch-abit
    arch-abit over 9 years
    Nice, you REALLY summed it up for theory and for science.
  • Admin
    Admin over 9 years
    +1 for being the only answer here dealing with the real issue, not only of what would happen, but also why.
  • akash ujjwal
    akash ujjwal over 9 years
    @ultrasawblade why not cpu has a chance to see the data, even if cpu demand for a page(info) and if it is not available in ram(primary memory), then there is page fault occurs, then cpu request to the hardisk for that desired data. That means cpu lastly has to go to hard disk for required information.
  • reirab
    reirab over 9 years
    @FiascoLabs Actually, CPU cache is there for the same reason as RAM: It's really fast storage. It's much faster than RAM, but more expensive per byte.
  • akash ujjwal
    akash ujjwal over 9 years
    now lastly i get what i need.You answered Exactly what I'am aspecting. Thank you very much :)
  • arch-abit
    arch-abit over 9 years
    Actually, the reason PCs do not boot without RAM is the BIOS, if the BIOS code is not able to find a relocation address in RAM it aborts. All you are going to hear is the humming of the power-supply and the noise of fans and maybe spinning disks - but the computer is basically brain-dead. The CPU never gets a chance to make it all work. So yes, RAM is pretty important.
  • akash ujjwal
    akash ujjwal over 9 years
    @arch-abit yeah its true, but is RAM is necessary component to run a computer?
  • Fiasco Labs
    Fiasco Labs over 9 years
    And a computer won't be running standalone on it, hence "other reasons"
  • jamesqf
    jamesqf over 9 years
    I think you could perhaps consider some DSPs (digital signal processors) and similar microprocessors to be computers that run without RAM, as they're essentially doing computations on a continuous stream of data.
  • reirab
    reirab over 9 years
    @arch-abit Yes, that's what I said in my second paragraph. The BIOS will abort the boot if it detects that no RAM is installed. And the reason it chooses to do so is that no PC operating system will work without RAM installed.
  • Sebi
    Sebi over 9 years
    +1 for stating that. In fact, every x86 system (computer) starts up "without using ram". Bios code first detects if there is any ram, and beeps in case there isn't any. This code can run without ram ;) (ofc not a lot can be done without ram, for sure registers wouldn't be sufficient to handle HDD and use it "as ram")
  • LawrenceC
    LawrenceC over 9 years
    See edits. The kernel paging in swapped memory is not different than a program loading or a program reading/writing to disk. It just happens within the kernel and behind the scenes of a user process, but not behind the scenes of the kernel.
  • leftaroundabout
    leftaroundabout over 9 years
    I think your estimations for the slowness of a "virtual memory only" machine are a bit exaggerated, but in principle right.
  • Dancrumb
    Dancrumb over 9 years
    Since disk is >1,000,000 slower than RAM, I think the estimate is, if anything, on the low side.
  • Maciej Piechotka
    Maciej Piechotka over 9 years
    In addition to what @reirab said it's possible to run a 'PC' without DRAM in a sense of executing instructions - this is mode in which system operates before the DRAM controller is initialized (it's done by BIOS/EFI/Coreboot etc.). However it's unlikely that you'll be able to do anything useful as most components probably use DMA anyway.
  • psusi
    psusi over 9 years
    32 bit x86 cpu registers are only 32 bits, not 64, and 64 bit x86 cpus have 32 rather than 8 of them.
  • reirab
    reirab over 9 years
    @psusi Good catch! I've only programmed in the 32-bit x86, so I didn't realize that the 64-bit extensions added more general purpose registers. And, yes, obviously, the general purposes registers are only 32 bits wide on 32-bit x86 processors. However, Wikipedia seems to suggest that they only increased the general-purpose register file from 8 to 16 registers in x86_64. What are the other 16 you're referring to?
  • reirab
    reirab over 9 years
    @FiascoLabs It certainly can. It's not even uncommon in embedded systems. Even in normal desktop computers, though, the decision not to make it addressable is purely a processor design decision. There's no theoretical reason you can't run the system with purely on-chip memory, just as there's no theoretical reason that you need cache (or RAM) in the first place. They're both just there because they're relatively economical ways to speed things up. The whole memory hierarchy exists solely for that reason.
  • L.B.
    L.B. over 9 years
    Shoot! That explains something about the speed of a computer I dealt with recently... I opened it up and found no RAM...
  • Zeiss Ikon
    Zeiss Ikon over 9 years
    Thanks for this answer -- first time I recall hearing about Zuse and his early electromechanical computers (even though the earliest readings I recall about computers always spoke of "relays" as the switching units, all the other early computers seem to have used vacuum tubes).
  • psusi
    psusi over 9 years
    @reirab, there are only 16 64 bit general purpose registers, but there are also another 16 128 bit mmx/sse registers. This is actually what is responsible for most of the performance improvement of 64 bit; on 32 bit of the 8 general purpose registers, only 7 can be used and none are preserved across a function call, so lots of local variables have to be saved and restored to/from the stack, and all arguments are put on the stack. With 64 bit, 15 registers can be used for local values and 6 of them are preserved across function calls so often those values don't need to be saved to the stack.
  • reirab
    reirab over 9 years
    @psusi Ah, yeah, I was aware of the SSE registers, but I was excluding them (and the segment registers and the FPU register file, etc.) in mentioning general-purpose registers. Also, they've obviously been around much longer than the 64-bit extensions (though their size and usefulness has increased over the years.)
  • user
    user almost 7 years
    Even within disks we sometimes have tiered structures these days. Think SSHDs (rotational hard disks fronted by a smaller solid-state cache, all built into one physical device), or you can build something similar yourself. ZFS lets you use RAM as first level cache (always available, but can be disabled) and add a (usually fast) disk as second level cache (referred to in ZFS as L2ARC, for Level 2 Adaptive Replacement Cache), compare ZFS caching mechanisms on Wikipedia.
  • user
    user almost 7 years
    @Dancrumb I'm not sure where your 1,000,000 (times?) came from. DDR3 SDRAM can give you on the order of 10 GB/s, whereas even a rotational 7200 rpm HDD will get you about 100 MB/s (0.1 GB/s) sequential. That's a factor of 100; certainly significant, but a far cry from 1,000,000 times. Where RAM greatly outperforms a HDD is in seek latency, but you can greatly alleviate that by using a SSD. DDR3 has a latency in the 10 ns region, and a fast SSD might have a latency in the 10,000 ns region (100k IOPS), for a factor 1,000; still a far cry from 1,000,000.
  • reirab
    reirab almost 7 years
    @MichaelKjörling Very true. Even aside from SSHDs, hard drives have included internal cache for many years (though that is typically in the tens of megabytes, not the tens of gigabytes like the SSHDs.)
  • Dancrumb
    Dancrumb almost 7 years
    @Michael, I honestly don't know why I wrote 1000000. Your analysis is correct.
  • Peter Cordes
    Peter Cordes over 6 years
    Modern Windows or Linux can't work without RAM (or at least using cache as RAM). There's nowhere for them to write the page tables for virtual->physical translation, and on a page fault they want to read bring a whole 4k page into memory. To work without RAM, every access that isn't to a register would have to use PIO to read or write just that byte or dword on disk. Also, they don't support paging (all parts of) the kernel. Linux doesn't page kernel memory at all, and Windows has some "unpageable" memory. On x86, you'd need at least some stuff in ROM like GDT/LDT/IDT for 32/64-bit mode.
  • Peter Cordes
    Peter Cordes over 6 years
    Oh, and of course instruction bytes have to be somewhere other than the HD. Using cache as RAM is a thing, and used in early boot by some actual BIOS implementations. (e.g. before they've detected the RAM chips and configured the memory timings!) stackoverflow.com/questions/27699197/…
  • Peter Cordes
    Peter Cordes over 6 years
    Note that x86 at least can use cache as RAM with no-fill mode, but then you're in the same boat as microcontrollers that come with some built-in RAM. Running the CPU with only ROM and no writeable address space is plausible (if all your state fits in registers, and note that the most recent x86 CPUs have thirty-two 512b ZMM vector registers...) But agreed that it's not plausible with no readable address space for code (and GDT/LDT/IDT and other tables for x86).
  • Zeiss Ikon
    Zeiss Ikon over 6 years
    @PeterCordes Hence my opening note that it would be possible to design a computer to run without RAM. A Turing machine doesn't have RAM, hence a computer need not. In fact, there are a number of Turing machines implemented in Life (cellular automata simulation) that are "pure" -- using only the tape-and-step system originally described by Alan Turing.
  • Peter Cordes
    Peter Cordes over 6 years
    Yup, first part of the answer is excellent, but then the last paragraph is a mis-step. Even with the Linux kernel in ROM, it would still need several pages of physical RAM to run a user-space process unless you heavily modified it. In which case maybe you could get that down to 2 pages of physical RAM: current user-space code page and a data page, so user-space could make forward progress on a load or store instruction. (Assuming no unaligned accesses that split across two 4k pages, but some non-x86 ISAs disallow that anyway)
  • Zeiss Ikon
    Zeiss Ikon over 6 years
    @PeterCordes Edited so it doesn't seem I'm claiming Win/Linux could run without RAM.
  • Motti Shneor
    Motti Shneor about 4 years
    Still the question stands, how far, expensive and difficult is it to build a computer whose “normal” RAM is implemented using a non-volatile memory module, such ad, for example, a modern SSD module? I would guess that today’s SSDs aren’t slower from previous decade’s RAM modules? How different are the electronic interfaces? Is this feasible? Forget windows PC, I’m interested in building some kind of Linux computer that is secure to turn off at any moment, whose whole state is non volatile.
  • Motti Shneor
    Motti Shneor about 4 years
    I’d gladly settle for no-swapping/paging computer if my RAM modules could be replaced by a 2Terabyte SSD MODULE. iPhones turn off swapping mechanism of their VM for performance gains today. You also said today’s CPU could map PCI based memory as RAM. Why not have PCI based SSD modules?
  • LawrenceC
    LawrenceC about 4 years
    NAND flash doesn't work like RAM at all. For example, a NAND module will allow you to write like 2k to a page in a bigger block of like 16 pages. If you want to write a different 2k of data in that same page, you have to erase the whole bigger block of 16 pages just to change that 2k. This is SLOW even if a microcontroller in the middle makes it look like RAM (which would probably have to use real RAM itself to keep the block rewriting straight). RAM is simple - you read an address, or overwrite it anytime you want, and the only delays are with caching which are stilll faster than NAND.
  • reirab
    reirab about 4 years
    @MottiShneor The main problem you would run into with that is that very few, if any, CPUs would support such a configuration. You'd probably have to find some way to translate the DDR interface to an interface on which SSD modules exist, such as PCIe, and probably also make significant modifications to the bootloader in order to do this with current hardware. You would also need to find some way to get the SSD to send something as small as a single CPU cache line, not the large sectors they normally transmit by DMA to RAM.
  • Motti Shneor
    Motti Shneor about 4 years
    @LawrenceC We all know the differences, and the inherent slowness of SSD (NAND) interface. I think for SOME uses, however, such computers will be beneficial, despite their inherent slowness - which, like every usable technology, will eventually be remedied and evolved. Think about medical equipment. Think about Car/Ship/Aircraft computers, think about routers. a non-volatile-state computer will cause a paradigm shift in software (both OS and applications). I think it worthwhile to try.
  • prosfilaes
    prosfilaes about 3 years
    I've wondered this from a different direction than the question; the CPU caches may be small, relative to modern RAM, but a Core i9 has more cache than a 286 could theoretically support in RAM.
  • phuclv
    phuclv about 3 years
    the mininum memory requirement in Windows XP is 64MB RAM. I've installed XP on such a PC around 2001 although the experience wouldn't be called good until RAM was upgraded to 128MB