2.1.2+Primary+Memory+and+2.1.3+Cache+Memory

=**__2.1.2 Primary Memory (SHORT VERSION - scroll for extensive explanation)__**= =__Primary memory__= Primary memory is the working memory or the memory that can be used at run time. It stores program instructions and data to be accessed by the CPU.
 * ROM (Read only memory)
 * just for reading
 * BIOS is on ROM
 * depends on hardware, not really software
 * manages data flow between OS and hardware
 * can be deleted and reprogrammed
 * PROM (Programable Read Only Memory)
 * EPROM (Erasable Programable Read Only Memory)
 * EEPROM (Electrically Erasable Programmable Read Only Memory)
 * RAM (Random Access Memory)
 * SRAM (static RAM)
 * Cache
 * 0/1 stored until no power
 * doesn't need refreshing
 * saved, when saved
 * smaller, but faster
 * 6-8 transistors
 * DRAM (dynamic RAM)
 * mini battery
 * needs refreshing
 * cheap for a lot of power
 * moments without access
 * slower than SRAM
 * OS runs on RAM
 * The Cache, RAM, ROM* all belong to the primary memory but cache, for instance, is included on the CPU chip in modern processors
 * Registers belong to the CPU itself; hard drives, for ex. are an example of secondary memory
 * Parts of primary Memory are volatile (RAM, for example)
 * The primary memory is not included as part of the CPU in some definitions.
 * Primary memory is more expensive per byte than secondary memory

There is a comparison of primary and secondary memory here: http://www.bookrags.com/research/primary-and-secondary-memory-wcs/ (Note: according to the IB ROM and cache are considered as primary memory. Therefore there might be slight differences between what this wiki says and information in other articles on the world wide web).

__RAM – Random Access Memory __
 * The RAM is where programs, instructions, values are stored at runtime
 * The RAM can be accessed a lot faster than the hard disk
 * All information is lost when the power is turned off
 * Allows storage and random access of the data
 * Each program instruction & piece of data in the RAM has a unique address

__ROM* – Read Only Memory __ * Note: in some definitions ROM is not included as part of the primary memory. However for the IB it is.
 * Can not be written to easily or at all (often times once only, then never again)
 * In modern PCs usually used for firmware in CPU, Graphics card, hard disks, etc.
 * Many ROM modules are replaced with Flash modules nowadays (ex. BIOS, firmware modules) to allow easier updating
 * In devices like keyboards, etc. which aren’t designed for firmware updates ROM might still be used
 * Stores code for interrupter

__Virtual memory__ To expand memory usable by the CPU it is possible to use something called virtual memory where the most important instructions for the program are stored in the RAM and the less necessary information is stored in secondary memory (usally the HDD) and then the data is switched between RAM and virtual memory as it is needed (to swap).

Advantages:
 * More memory to work with.

Disadvantages:
 * It is very slow compared to the primary memory
 * Thrashing can occur. Thrashing is a condition when there is too much data that needs to be swapped between RAM and virtual memory, and the computer's response time is compromised.

Here is a more-in-depth article of virtual memory: http://computer.howstuffworks.com/question684.htm

Written by Jocbe & Lucie Magister Last updated: 19/03/2015

Sources:
 * "Computer Data Storage." Wikipedia. 26 August 2010. Wikimedia.org. 2 September 2010. https://secure.wikimedia.org/wikipedia/en/wiki/Primary_memory
 * Jones, Richard. Computer Science Java Enabled. Victoria: IBID Press, 2004.
 * Class Notes.