Operating System Paging

                               
Paging - is a memory management scheme that will permit physical address space of a process to be non-contiguous

The amount of data that is transferred to and from main memory to secondary storage is called paging

Paging   will avoid the problem of trying to fit varying sized memory segments in to back-up storage

When swapping takes place sum of the code residing in the main memory has to be sent back to the secondary storage

There is also problem of fragmentation where the data can be stored in random locations in the secondary storage

The physical memory (HD OR FLOOPY) is broken in to the fixed size blocks called frames
The logical memory (ram addressing) is also broken in to the blocks of the same size called pages

Every address generated by the CPU is divided in to “2” parts a page no ’p’ & a pageoffset’d’

The page no is used as an index in to a page table. The page table contains the base address Of each page  in the physical memory.

The size of a page is typically a power of 2 varying between 512 bytes & 16mb per page depending upon the comp architecture

If the size of the logical address space is 2m and a page size is 2n  addressing units then the high order m-n is the page no

When a process arrives in the system to be executed its size expressed in pages is examined.

Each page of the process needs one frame .Thus, if the process requires “n” pages at least “n” frames must be available in the memory.
If ‘n” frames are available they are allocated to this arriving process

The first page of the process is loaded in to the allocated frames and the frame no is put in to the page table for this process.
The next page is loaded in to the another frame and the process continues

The paging concept gives a clear view of the difference between the user’s view of the memory and the actual physical memory

The user views the program to be present in a single contiguous allocation but the actual storage will be non-contiguous

The program is divided in to equal size parts, each part is called page.

The main memory is also divided in to equal fixed size parts. These parts are called frames.

In paging the page is inserted in to the frame and executed by the CPU. This can

be implemented by creating the page table. The page table contains page no,

frame no and the corresponding associative bit. If the associative bit is “1” the

corresponding page is present in the frame, if it is “0” the page is not present in main memory.


Segmentation

Is a  memory management scheme which supports the user view.
Segmentation is based on dividing the logical address of the program in to the smaller parts known as segments.
Therefore user will see the program as collection of segments rather than in its entirety(as a whole).
Every segment will be having the segment no or a name along with a segment offset.
A segment table will be maintained which contains the segment base and the segment limit.
Each segment can contain a different contents search as one segment may contain Program and other segment may contain a table or data.
Another advantage of segmentation is it involves the sharing of code or data.
Segments are shared when entries in the segment tables of two different processes Point to same physical location.



Segmentation  with paging

We can combine both the techniques paging and segmentation to bring out the efficiencies of both the techniques

Segmentation technique involves dividing the program in to imp parts so that each part can be dealt separately such as data , instn’s, subroutines(fns).

Paging involves managing the programs and data even though they are not allocated contiguously.

Combining both these techniques would see that a program is divided in  to
Smaller modules known as segments and to locate and identify each segments we can use the concept of paging.

Virtual memory

The concept of virtual memory gives the advantage that we can have software or programs which are much larger then the ram size.
It also gives the feeling to the user that there is more memory then what actually is available.
Virtual memory concept is implemented by using demand paging and also
Demand segmentation.

Demand paging

DEMAND PAGING is a concept which uses a paging system and swaps in
And swaps out pages
Rather then swapping the entire process we can swap only the selected pages of the process which is known as a lazy swapper or pager.
When a process is required the pager will identify what pages that will be really required. Therefore, Instead of swapping the entire process it would swap only the necessary pages .this would not only decrease the time but also saves the amount of memory.
The technique here is to mark some pages as valid and some pages as invalid by using special bits

The h/w supported needed for demand paging would be the same as normal segmentation and paging
We require a page table which marks a particular page as valid or invalid
Secondary memory which can hold the entire pages of the process which also contains
The space known as swap space
The performance of demand paging will have a significant effect on the performance
Of a comp system. This is known as effective access time of demand paged memory as long as there are no page faults
i.e unable to identify the page

Effective access time = (1-P) * Ma +P * page fault time

Ma-> means memory access


LOGICAL & PHYSICAL ADDRESS SPACE

The address which is generated by the cpu is known as a logical address
Where as the actual address where the data is stored in the memory is known as
Physical address.

The   physical address is a number that is loaded in to the memory address register

The compile time and the load time address binding methods generate identical logical and physical address

The execution time address addresses the binding scheme is differing   the  logical and
Physical addresses.

The runtime mapping from virtual  to physical addresses is done by a hardware device called the memory management unit

To perform memory mapping we need a register known as  the base register also known as the relocation register.

Every time the user attempts to process the data in to the memory it is done by adding the number to the base address .Therefore, The program never sees the actual address.





DYNAMIC LINKING:

Some programming lang’s and os’s support only static linking(remains in the memory as long as the software is active)
Static linking means the libraries are loaded in to the ram along with the program
The opposite for static linking is known as dynamic linking.
In dynamic linking we have lang subroutine libraries stored in the hard disk and they will be linked and loaded only when necessary.
In dynamic linking a stub is included for each library routine reference
This stub is a smaller piece of code which will tell where to locate the library routine
When this stub is executed it will load the library routine in to the memory.
This routine can be shared by all the programs in the ram.
This feature will save the time and disk space.This feature can also be extended to library updates where all the programs can share only the latest version  of the library that is available.











      

Post a Comment

0 Comments