CREATE OWN LIBRARY

Paging

 

All basic concept of paging

# As we know CPU generates a logical address which is called a relocatable address because the CPU assumes the process will be allocated at the memory from the 0th (zero) location. 

 

# Now Memory Management Unit (MMU) converts the logical address (Relocatable address) to physical address (Absolute address) to map the process into memory with the actual address.

 

The technique of mapping the CPU to generate logical address to physical address is called paging.

 

Advantage of paging:

1. No external fragmentation because one single process can be allocated its pages in different locations (frames) of the memory in a non-consecutive manner as per the free location.

 

2. Degree of multi-programming is increased because by paging technique we can allocate the number of processes into memory. 

 

Paging Requirement:

1. Memory Management Unit converts the logical address to the corresponding physical address.

 

2. Page Table: For every process, there is a page table that holds the corresponding frame number of a page and other page-related information.

 

3. Every frame in the main memory holds some information that is free or allocated with other pages.

 

Logical Address: A logical address is the address of an instruction or data byte is used in a process; it may be obtained using the index, base, or segment registers.

 

Logical Address Space (LAS)The logical addresses in a process constitute the logical address space of the process. 

 

Logical address space = Size of the process.

 

Physical Address: A physical address is an address in memory where an instruction or data byte exists.

 

Physical Address Space(PAS): The set of physical addresses in the system constitutes the physical address space of the system. 

 

Physical address space = Size of the process.

 

The basic method for implementing paging involves breaking physical memory into fixed-sized blocks called frames and breaking logical memory into blocks of the same size called pages.

 

Let,

Process size= 16MB = Logical address space (LAS)

 

Memory size= 64 MB = Physical Address Space (PAS)

 

LAS is divided into equal size pages and assume page size = 4MB

 

Page size and frame size is the same i.e.  page size = frame size

 

PAS is also divided into equal size frames and the size is the same as page size i.e. 4MB

 

 

Number of pages = Process size(LAS) / Page size

 

Number of pages = 16MB / 4MB  = 4

 

Number of frames = Memory size (PAS) / frame size

 

Number of frames = 64MB / 4MB = 16.

 

Architecture of non-contiguous memory allocation:

 

 

Main memory vs Virtual Memory:

The memory hierarchy comprises the cache, the memory management unit (MMU), Random Access Memory (RAM), which is simply called memory.

 

We discuss the management of memory by the OS in two parts:

1) Techniques for efficient use of memory and management of virtual memory.

 

2) Management of virtual memory, which is part of the memory hierarchy consisting of the memory and the disk.

 

Now, what is virtual memory?

Virtual memory is a concept and is occurred when process size becomes large compare to available main memory.

 

So, in that case, divide the process into some equal size of pieces and load a part of the process in the memory as per availability, and the rest of the pieces keep in a particular place of secondary memory.

This concept is called virtual memory.

 

But nowadays to increase the degree of multi-programming we divide each and every process and keep a part of all processes in the memory so, that memory can working with more processes to increase the efficiency of the memory.

 

So, logical address space and virtual address space in same and we can use those words alternatively.

 

Question: GATE 99

Which of the following is/are advantages of virtual memory?

a) Faster access to memory on an average 

b) Processes can be given protected address space

c) Linker can assign addresses independent of where the program will be loaded the physical memory.

d) Programs larger than the physical memory size can be run.

 

Solution:

 

Option (a) is false:  Virtual memory never be faster, its access time is high comparatively to higher level of memories.

 

Option (b) is false: it is not related to the advantage of virtual memory. Protection can be given in continuous memory also by base and limit register.

 

Option (c) is false: This is relocation i.e. translation from reloadable to an absolute address. It is never related to virtual memory.

For more details followAddress Relocation

 

Option (d) is true: As we know if the program size larger than the available main memory we can divide and load a part of the program.

 

So, only option (d) is correct.