14

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?

  • 1
    Similar: superuser.com/q/805340/334004 – Cornelius Dec 27 '14 at 19:02
  • 1
    @Cornelius thanks for your reply i'll check it out :) – akash ujjwal Dec 27 '14 at 19:05
  • 12
    What happens is some beeps then the screen turns blank. – arch-abit Dec 27 '14 at 19:07
  • 1
    My question is, can i at least test that a graphics card is working? Would there be video or the monitor work minimally? – marshal craft Oct 18 '18 at 20:05
29

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.

| improve this answer | |
  • now lastly i get what i need.You answered Exactly what I'am aspecting. Thank you very much :) – akash ujjwal Dec 27 '14 at 20:17
  • 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. – arch-abit Dec 27 '14 at 20:37
  • @arch-abit yeah its true, but is RAM is necessary component to run a computer? – akash ujjwal Dec 27 '14 at 20:47
  • 2
    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. – Maciej Piechotka Dec 28 '14 at 1:21
  • 1
    32 bit x86 cpu registers are only 32 bits, not 64, and 64 bit x86 cpus have 32 rather than 8 of them. – psusi Dec 28 '14 at 3:40
23

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.

| improve this answer | |
  • 4
    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. – jamesqf Dec 27 '14 at 21:49
  • 1
    I think your estimations for the slowness of a "virtual memory only" machine are a bit exaggerated, but in principle right. – leftaroundabout Dec 27 '14 at 23:46
  • 1
    Since disk is >1,000,000 slower than RAM, I think the estimate is, if anything, on the low side. – Dancrumb Dec 28 '14 at 0:54
  • 3
    @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. – user Jun 2 '17 at 20:04
  • 1
    @PeterCordes Edited so it doesn't seem I'm claiming Win/Linux could run without RAM. – Zeiss Ikon Sep 13 '17 at 16:38
11

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.

| improve this answer | |
  • 4
    +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") – Sebi Dec 27 '14 at 22:39
11

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.

| improve this answer | |
  • 2
    +1 for being the only answer here dealing with the real issue, not only of what would happen, but also why. – user201265 Dec 27 '14 at 20:07
  • @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. – akash ujjwal Dec 27 '14 at 20:10
  • 2
    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. – LawrenceC Dec 27 '14 at 23:45
  • 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). – Peter Cordes Sep 12 '17 at 20:58
  • 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? – Motti Shneor Apr 17 at 16:36
7

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.

| improve this answer | |
  • 5
    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? – arch-abit Dec 27 '14 at 19:14
  • @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? – akash ujjwal Dec 27 '14 at 19:25
  • 1
    RAM is fast memory storage, disk access is slow, non-volatile memory storage and the CPU cache is there for other reasons. – Fiasco Labs Dec 27 '14 at 19:28
  • 1
    @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. – reirab Dec 27 '14 at 20:13
  • And a computer won't be running standalone on it, hence "other reasons" – Fiasco Labs Dec 27 '14 at 20:51
5

The computer will not run. RAM is an essential part of successful post from the motherboard. When RAM is not present or damaged, many motherboards typically give beeps codes to indicate where to look in troubleshooting.

| improve this answer | |
2

Actually you could in at least two cases run a computer without what is technically referred to as RAM

  1. The first old mechanical "computers" (Konrad Zuse's construction and Charles Babbage's computer were mechanical devices with no RAM arestill called computers)

  2. A modern computer with no RAM and only a processor (chip) with registers. In most cases you have SRAM (cache memory) on the processor but the fastest computer memory is called registers located on the chip, and technically registers on the chip are not RAM.

| improve this answer | |
  • 1
    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). – Zeiss Ikon Dec 28 '14 at 12:41
1

It just won't run. Motherboard will most probably beep in an unusual way and shut down. If you don't have enough RAM, even 128MB for Windows XP, it'll refuse to install (actually tried this with an old computer; one of the chips wasn't correctly placed). So, with the current setups is impossible. Even if you could disable motherboard checks, CPU can't read data directly from hard disk and needs RAM for every operation.

I guess, in theory it'd be possible to construct a machine which uses little or no RAM, but it'd be ineffecient.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.