According to this picture ROM is classified under Main Memory , but isn’t ROM a secondary storage because it’s external and non volatile ? Any clarification with reference links will be highly appreciated. Thank you.
The distinction between primary and secondary storage relies on several joint characteristics which the prototypical examples – RAM and hard drives – satisfy:
- Primary storage can be accessed directly by the CPU. Access is fast. Data is volatile – it is lost when power is turned off.
- Secondary storage cannot be accessed directly by the CPU. Access is slow. Data is non-volatile – it is retained even when power is turned off.
- Tertiary storage is similar to secondary storage, but can only be accessed via a network device. Access is even slower.
Where does ROM fall into this classification? The typical usage of ROM in computing (according to Wikipedia, now falling out of use), is for booting. When the computer is started, the CPU is directed to start running from some address, which is memory mapped to read-only memory* containing instructions for booting the system. This kind of memory satisfies the first two properties of primary storage listed above, but not the third property.
Complicating the picture, some I/O devices are memory mapped, and so in this sense can be accessed directly by the CPU. This is (or at least, used to be) common for video. Does video memory count as primary storage or as secondary storage?
What these examples show is that the classification has its limits. The purpose of such classifications is to help us conceptualize how computers work. They shouldn't be taken too seriously – they don't apply in a clean way to all possible situations.
The terms “primary memory” and “secondary memory” are intended to distinguish between memory that is directly accessible from the main processor and memory that isn't. The basic idea is that the processor can read and write directly to primary memory. On the other hand, to access the contents of secondary memory, it needs to copy the content into primary memory and arrange for a data transfer, or to use peripheral input-output instructions rather than memory load-store instructions.
This is not a hard-and-fast distinction and there are a lot of ambiguous cases. Most types of memory (RAM, ROM, Flash, EEPROM, …) can either be primary or secondary, addressable or not, depending on the hardware architecture. Classifying memory like this is pointless, and it's wrong unless you're talking about a specific architecture (e.g. a PC's main processor, or a particular family of microcontrollers, etc.).
ROM and EPROM are non-volatile by definition. They aren't necessarily external: many chips contain a small amount of ROM. (E)EPROM and flash are more often external because the erasure process generates heat which is harder to dissipate if the memory is part of a multi-function chip – an engineering concern, not a scientific distinction. ROM is often primary memory because that's where the boot code is stored, and accessing secondary memory requires some code to run, so that can't be done until the boot code has run.