Unit 5 Memory Organization
Unit 5 Memory Organization
Memory Organization
Memory Organization
• A memory unit is the collection of storage units or devices together.
The memory unit stores the binary information in the form of bits.
Generally, memory/storage is classified into 2 categories:
• Volatile Memory: This loses its data, when power is switched off.
• Non-Volatile Memory: This is a permanent storage and does not lose
any data when power is switched off.
Memory Organization
• Memory device characteristics:
– CPU should have rapid, uninterrupted access to the external memories where its
programs and the data they process are stored.
– So that CPU can operate at or near its max. speed .
Po P2
P1 P1
Pages Process
P2 P3
P3 P0
Process Main Memory
Paging
• In Paging two types of addresses are used
– Logical address:- is the address generated by the CPU for every page
– physical address:- is the actual address of the frame where each page
will be stored.
• CPU generates a logical address • Physical address consisting of two
consisting of two parts- parts-
1. Page Number:- specifies the 1. Frame Number:- specifies the
specific page of the process from specific frame where the required
which CPU wants to read the data. page is stored.
2. Page Offset:- specifies the specific 2. Frame Offset:- specifies the specific
word on the page that CPU wants to word that has to be read from that
read. page.
Paging
Page Table
• Page table is a data structure.
• It maps the page number referenced by the CPU to the frame number
where that page is stored.
• Page table is stored in the main memory.
• Number of entries in a page table = Number of pages in which the process
is divided.
• Each process has its own independent page table.
Paging
Page Table
Page 0 1 Page 0
Page 1 0 1 2
4 Page 2
Page 2 1 3
3 Page 1
Page 3 2 4
7
3 5
Logical Memory
6
Page Table Page 3
7
Physical Memory
Paging
Working of Page Table
• Page Table Base Register (PTBR)
contains the base address of page
table.
• The base address of the page table is
added with the page number
referenced by the CPU.
• It gives the entry of the page table
containing the frame number where
the referenced page is stored.
Paging
Hardware Implementation of Paging
• The following diagram illustrates the above steps of translating logical
address into physical address-
Paging
Hardware Implementation of Paging
• Example
Memory Allocation
• Levels of Memory system are divided into sets of contiguous locations
called as regions, segments or pages which are blocks of data.
• The placement of blocks of information in a memory system is called
memory allocation.
• The method of selecting the part of M1 in which an incoming block K is to
be placed is the replacement policy.
• Replacement policies assign K to M1 only when an unoccupied or inactive
region of sufficient size is available.
• Successful memory allocation methods result in a high hit ratio and a low
average access time.
Dynamic Memory Allocation Algorithms
Dynamic
Memory
allocation
Non
Preemptive
Preemptive
Optimal Page
FIFO LRU
replacement
• With only nine page faults, optimal page replacement is much better than a
FIFO algorithm, which had 15 faults.
• The optimal page replacement is difficult to implement
Memory
Paging Allocation
Least Recently Used
• If we use recent past as an approximation of the near future, then LRU
replaces the page which has not been used for the longest period of time,
This is the least recently used algorithm.