Historical philosophical, theoretical, and legal foundations of special and i...
Memory Management
1. B.Tech – CS 2nd Year Operating System (KCS- 401) Dr. Pankaj Kumar
Operating System
KCS – 401
Memory
Dr. Pankaj Kumar
Associate Professor – CSE
SRMGPC Lucknow
2. Outline of the Lecture
B.Tech – CS 2nd Year Operating System (KCS- 401) Dr. Pankaj Kumar
Memory Hierarchy Design
Cache Memory
Address and Address Space
Virtual Memory
3. Memory Hierarchy Design
B.Tech – CS 2nd Year Operating System (KCS- 401) Dr. Pankaj Kumar
Memory Hierarchy is an enhancement to organize the
memory such that it can minimize the access time. The
Memory Hierarchy was developed based on a program
behavior known as locality of references.
Memory Hierarchy Design is divided into 2 main types:
1. External Memory or Secondary Memory –
Comprising of Magnetic Disk, Optical Disk, Magnetic
Tape i.e. peripheral storage devices which are
accessible by the processor via I/O Module.
2. Internal Memory or Primary Memory –
Comprising of Main Memory, Cache Memory & CPU
registers. This is directly accessible by the processor.
4. Memory Hierarchy Design
B.Tech – CS 2nd Year Operating System (KCS- 401) Dr. Pankaj Kumar
Auxiliary Memory
Auxiliary memory is known as the lowest-cost, highest-capacity and slowest-access storage in a
computer system. Auxiliary memory provides storage for programs and data that are kept for
long-term storage or when not in immediate use. The most common examples of auxiliary
memories are magnetic tapes and magnetic disks.
A magnetic disk is a digital computer memory that uses a magnetization process to write, rewrite
and access data. For example, hard drives, zip disks, and floppy disks.
Magnetic tape is a storage medium that allows for data archiving, collection, and backup for
different kinds of data.
Main Memory
The main memory in a computer system is often referred to as Random Access Memory
(RAM). This memory unit communicates directly with the CPU and with auxiliary memory
devices through an I/O processor.
The programs that are not currently required in the main memory are transferred into auxiliary
memory to provide space for currently used programs and data.
5. Cache Memory
B.Tech – CS 2nd Year Operating System (KCS- 401) Dr. Pankaj Kumar
Cache Memory is a special very high-speed memory. It is used
to speed up and synchronizing with high-speed CPU. Cache
memory is costlier than main memory or disk memory but
economical than CPU registers. Cache memory is an extremely
fast memory type that acts as a buffer between RAM and the
CPU.
Purpose-
It is used for bridging the speed mismatch between the fastest CPU and the main memory.
•It does not let the CPU performance suffer due to the slower speed of the main memory.
Execution Of Program-
Whenever any program has to be executed, it is first loaded in the main memory.
•The portion of the program that is mostly probably going to be executed in the near future is
kept in the cache memory.
•This allows CPU to access the most probable portion at a faster speed.
6. Cache Memory Locality of reference
B.Tech – CS 2nd Year Operating System (KCS- 401) Dr. Pankaj Kumar
Locality of reference –
Since size of cache memory is less as compared to main memory. So to check which part of main
memory should be given priority and loaded in cache is decided based on locality of reference.
Types of Locality of reference
Spatial Locality of reference
This says that there is a chance that element will be present in the close nearness to the reference
point and next time if again searched then more close proximity to the point of reference.
Temporal Locality of reference
In this Least recently used algorithm will be used. Whenever there is page fault occurs within a
word will not only load word in main memory but complete page fault will be loaded because
spatial locality of reference rule says that if you are referring any word next word will be referred
in its register that’s why we load complete page table so the complete block will be loaded.
7. Address and Address Space in OS
B.Tech – CS 2nd Year Operating System (KCS- 401) Dr. Pankaj Kumar
Logical Address is generated by CPU while a program is running. The logical address is virtual
address as it does not exist physically, therefore, it is also known as Virtual Address. This address
is used as a reference to access the physical memory location by CPU. The term Logical Address
Space is used for the set of all logical addresses generated by a program’s perspective.
The hardware device called Memory-Management Unit is used for mapping logical address to its
corresponding physical address.
Physical Address identifies a physical location of required data in a memory. The user never
directly deals with the physical address but can access by its corresponding logical address. The
user program generates the logical address and thinks that the program is running in this logical
address but the program needs physical memory for its execution, therefore, the logical address
must be mapped to the physical address by MMU before they are used. The term Physical
Address Space is used for all physical addresses corresponding to the logical addresses in a
Logical address space.
8. Virtual Memory
B.Tech – CS 2nd Year Operating System (KCS- 401) Dr. Pankaj Kumar
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 disk that's set up to
emulate the computer's RAM.
Virtual Memory is a storage scheme that provides user an illusion of having a very big main
memory. This is done by treating a part of secondary memory as the main memory.
In this scheme, User can load the bigger size processes than the available main memory by
having the illusion that the memory is available to load the process.
Instead of loading one big process in the main memory, the Operating System loads the different
parts of more than one process in the main memory.
By doing this, the degree of multiprogramming will be increased and therefore, the CPU
utilization will also be increased.