Memory
At Higher level you will be able to differentiate between the different types of memory in terms of function and speed of access. The types of memory you need to know about are:
Registers
Main Memory
Backing Storage
Registers have already been covered, see the section earlier for a recap.
Random Access Memory (RAM)
Random Access Memory is the most commonly used. RAM is the computer’s short term memory. If a machine has 2GB of RAM then every program (including the Operating System) is loaded into the system’s RAM.
RAM is known as volatile memory, this means that when it has no power it loses its contents. This is why if you have not saved a document to a hard disk etc. and the machine resets then because there is no power for a second the contents of RAM are lost.
RAM is very fast compared to backing storage, to give you some idea modern DDR3 RAM can transfer approximately 12,800MB/s versus a Hard Disks 600MB/s (maximum).
Types of RAM
There are two main types of RAM:
Dynamic Ram
Static RAM
Dynamic RAM
Dynamic RAM is the more common type of memory, this will be the RAM that you upgrade your system with. The dynamic refers to the fact that it constantly requires power to refresh its contents. It is far less complex than static RAM requiring less components so is far cheaper.
Access time for this type of RAM is approx. 22.5 nanoseconds (DDR3-1600). It comes in a variety of sizes, the two more commonly used are full size DIMM’s (Dual In-line Memory Module) for use in desktops and SO-DIMMS (Small Outline DIMM’s) for use in laptops and small form factor machines.
Will usually be described ranging from PC10666 to PC14400. The PC number is its maximum theoretical bandwidth. They can also run at different clock speeds ranging from 1333 – 1800 MHz.
RAM Timings
The timings can also be written as 9-9-9-28. This means that it takes 9 clock cycles to deliver data, the last number is the time for the RAM to read or write from a different (as opposed to consecutive) area in RAM.
Virtual Memory
If a computer runs out of free Ram it can use a temporary storage file on the hard disk, sometimes known as a swap file. Comparatively backing storage is much slower – nanoseconds (RAM) vs. milliseconds (Backing Storage).
Static RAM and Cache
Static RAM is a more complex and faster to access type of RAM that does still require power to hold its data but does not require refreshed as often. Due to its complexity it would be difficult to use in high capacity situations for example as the main memory in a desktop computer, modern personal machines can have on average 8-16GB of RAM. It is often used for cache memory in the processor or devices. Static RAM does not need to be refreshed as often as Dynamic RAM.
Cache Hits and misses
There is a limited amount of cache memory and not all instructions can be stored within. A cache hit occurs when a processor requests an instruction that is stored within cache memory. A cache miss occurs when the instruction requested is not in cache, this means that the instruction will have to be fetched from main memory.
There are a few methods to optimise cache use :
The CPU will fetch the next memory location to the one being asked for (typically 64 bytes).
A hardware prefetcher can then also load a larger amount of data . Intel chips have a 256-byte prefetcher, so it caches the next 256 bytes after the line already loaded.
This prefetch can be triggered when successive cache misses occur (so frequently used instructions will be cached).
Modern CPU’s can achieve cache hits of approx 80% using these and other techniques.
Cache Examples
In the example below cache will improve the execution time of instructions 2 and 3 as they will already be pre-fetched (pre-loaded) in cache i.e. a cache hit will occur. Data in memory location 2000 will already be in cache improving access time/instruction time.
Levels of Cache
A processor may have different levels of cache, Levels 1(Primary)-3. The higher the level the longer the access times. Access times can be in the area of 1-15 nanoseconds. Particularly in multi core chips each core will have its own cache while having access to larger areas of shared cache memory.
Level 3 cache might be the largest but would be slower to access than Level 1 - which would generally have a smaller storage capacity.
Read Only Memory ( ROM)
Read Only Memory is a non-volatile type of memory. Once the contents are programmed it is very difficult to erase/alter.
A common use of ROM inside a computer is for the BIOS chip on a motherboard that will contain the basic start up instructions for the motherboard. Another function is as a bootstrap loader, this is used to select and start the operating system. This is being replaced by the EFI (Extensible Firmware Interface) on some motherboards.