Lecture 2
Lecture 2
by
Engr. B.S. Muhammad(BEng. BUK, MSc. ABU)
A memory is just like a human brain. It is used to store data and program
(sequence of instructions). Computer memory is the storage space in the
computer, where data is to be processed and instructions required for
processing are stored.
The memory is divided into large number of small parts called cells. Each
location or cell has a unique address, which varies from zero to memory size
minus one.
Memory is primarily of three types namely;
i. Cache Memory
ii. Primary Memory (Main Memory)
iii. Secondary Memory
Cache memory is a very high speed memory which is very near to the CPU. It acts
as a buffer between the CPU and the main memory. It is used to hold those parts of
data and program which are most frequently used by the CPU. The parts of data
and programs are transferred from the disk to cache memory by the operating
system, from where the CPU can access them.
Disadvantages
Cache memory has limited capacity.
It is very expensive.
Primary memory holds only those data and instructions on which the computer is
currently working. The data and instruction required to be processed resides in the
main memory. This memory is not as fast as cache and registers It is divided into
two subcategories namely;
Volatile and
Non Volatile
The volatile memory (also referred to as the RAM) holds the data temporarily and
its erased whenever the system or program is shutdown.
The non-volatile memory (ROM) retains stored data even after the system is
shutdown
This type of memory is also known as external memory. It is slower than the main
memory. These are used for storing data/information permanently. CPU directly
does not access these memories, instead they are accessed via input-output
routines.
The contents of secondary memories are first transferred to the main memory, and
then the CPU can access it. For example, HDD.
A computer memory should be fast, large, and inexpensive. The memory hierarchy
is to obtain the highest possible access speed while minimizing the total cost of
memory system. The figure below gives the representation of the memory
hierarchy.
The following are the three key memory management techniques based on non-
contiguous memory allocation:
i. Swapping
ii. Segmentation
iii. Paging
A computer can address more memory than the amount physically installed on the
system. This extra memory is actually called virtual memory and it is a section of a
hard that's set up to emulate the computer's RAM. Paging technique plays an
important role in implementing virtual memory.
A data structure called page map table is used to keep track relation between page
of a process to a frame in physical memory.
Suppose you have a program of 8Kb but your memory can accommodate only
5Kb at a given point in time, then paging concept will come into picture. When a
computer runs out of RAM, the OS will move idle or unwanted pages of memory
to secondary memory to free up RAM for other processes and brings them back
when needed by the program. This process continues during the whole execution
of the program where OS keeps removing idle pages from main memory and write
them on secondary memory and bring them back when required by the program.