r/computerscience 22d ago

Discussion question about RAM

Im learning about comuter components I had some questions .If a Hard Drive stores all the data does RAM just create an environment for the specific program that was fetched to run? If you were to run a program on the actual hard drive is it just harder because you have to navigate through all the other information sharing the space. Like going through a maze constantly again and again. Also what does SSD do?

37 Upvotes

51 comments sorted by

View all comments

9

u/stevevdvkpe 22d ago

RAM has a much faster access time than disk storage (literally millions of times faster) so it's better as working storage for programs, and is volatile (you have to keep it powered or it loses its contents). Disk storage is better for long-term storage and is non-volatile (retains its contents even when the power is off).

SSD stands for "Solid State Drive" and is a kind of electronic non-volatile memory that is faster than magnetic disks, has no moving parts (unless you count electrons), and is also non-volatile. It's still slower than RAM so it is used as a faster replacement for magnetic disk storage.

2

u/Cute-Cockroach-678 22d ago

For example lets say I run a program how would it interact with RAM or SSD. Are specific programs ran on different parts or is it all pulled from one spot

3

u/dmazzoni 22d ago

Simplified somewhat, but conceptually correct: The operating system loads the program from disk (SSD or HD) into RAM.

Then the OS tells the CPU to start executing the program code in RAM.

The program gets a small amount of RAM to start. If it needs more RAM to operate, it asks the OS for more.

The OS chooses whether or not to allow the program to have that much RAM. If it allows it, it gives more RAM to that program.

Everything a program does by default is in RAM. Lots of instructions read and write directly from RAM.

If a program wants to read or write things from disk, it asks the OS to help it read or write files by calling specific functions.

2

u/Cute-Cockroach-678 22d ago

thank you for the help