1.2 - Memory and Storage (Part 1)

Primary Storage

- Primary storage is storage that is small in capacity, generally volatile (except ROM), and is quick to access.
- It stores the data that your computer needs when turned on, for example instructions or a program's settings file.
- It is required in a computer system because of its speed, which reduces the time taken to complete operations (such as the fetch-decode-execute cycle) significantly.
- It includes RAM, but also components like cache and registers.
- Primary storage is normally closer to the CPU, to reduce access latencies.
- It's usually a lot more expensive than secondary storage, owing to its fast access times.
- ROM counts as primary storage, but it is not able to be overwritten easily, hence its name (Read-Only Memory). It is still fast and directly available to the system.
- When obtaining RAM, you have to consider its price, speed, and cost. You may have to research other factors such as error-checking but that's not on the spec (don't worry about it, unless you're a sysadmin in which case why are you doing CS GCSE?).


RAM vs ROM

- RAM, or Random Access Memory, holds the data and instructions that are currently being used.
- For the CPU to access the data on RAM, it must first be copied across from secondary storage.
- As ram is volatile primary storage, it is very fast.
- It can be written to as well as read from.
- Normally has more storage than ROM.

- ROM, or read only memory, is primary storage that holds the BIOS (Basic Input/Output System) and the boot instructions.
- It's a small memory chip on the computer's motherboard.
- It's fast, slower than RAM but faster than secondary storage.
- It's non-volatile (not wiped when power is lost) storage type.
- ROM is read-only, and it has a very small capacity.


Virtual Memory

- Virtual Memory is a virtual extension of RAM on secondary storage.
- When RAM is nearly full, virtual memory can be used so that the computer doesn't crash and programs continue to RAM.
- Programs and data not currently in use (idle) are commonly transferred to virtual memory.
- Since secondary storage is a lot slower than primary, data and programs in virtual memory will take a lot longer to access, and the system will feel slower.
- Because of the speed penalty, the computer's OS will transfer data back to RAM when it is in use or when the RAM is cleared.


Secondary Storage

- As you might have guessed by now, secondary storage is persistent (non-volatile, persists between restarts) storage in a computer, that has a higher capacity than primary storage, and is cheaper.
- Because secondary storage is non-volatile, it is used for long-term storage of programs and data that is not currently in use.
- You cannot use ROM for this purpose due to its ready-only and expensive nature.
- Secondary storage is slower than primary storage, but is perfect for storing programs, the OS, and other files.
- When buying it, the characteristics you have to consider are capacity (usually GB or TB), speed (read/write and input/output operations per second or IOPS) portability, durability, and reliability.


Types of Secondary Storage

- Secondary storage (which you may come across as just 'storage devices') comes in a few different types of media: magnetic, solid state, and optical.

- Magnetic storage, like Hard Disk Drives (HDDs) use magnets to store binary 1s and 0s on a spinning platter. They are high capacity, low cost (sidenote: SSDs are becoming cheaper and cheaper so they may not have this advantage soon) and medium speed.
- However, they are not particulary durable as they can easily break if bumped or dropped, they are heavy and large so are impractical for transport, prone to mechanical failure, and they are loud as they spin so fast.

- Solid state storage (flash memory), like SSDs or USB drives, uses electronic circuits (NAND gates) to store 1s and 0s.
- Solid state storage can range from low capacity in USB drives, to high capacity in SSDs.
- It has very fast read/write access, as there are no moving parts. This also makes it durable.
- Drives that use flash memory are normally quite small, making them good for portability.
- They are also very quiet, sometimes practically silent.

- Optical storage (like CDs and DVDs) use a laser to 'burn' the surface of a disc (DISC WITH A C, SAVEMYEXAMS), creating pits and lands which represent 1s and 0s.
- It is a very cheap type of storage per gigabyte, has no moving parts (but the surface of a disc can be scratched), and are very thin making them portable.
- The storage medium itself is slient, but any readers/writers may make noise spinning the disc.


When to use a type of Storage

When to use solid state media:
- Mobile Devices
- Portable Storage
- As an OS Drive
- For durability

When to use magnetic storage:
- For storing large files/backups
- Storing less-frequently-accessed data cheaply

When to use optical storage: - Storing multimedia content (like music or films)
- Storing games for consoles
- Archiving data long-term (with the correct type of optical disc)