In
Operating System there are many concepts such as: Process Management, File
Management, Memory Management and I/O Management. All the above mentioned
concepts are very vast and vital in their self. Today I’m writing about the sub
topics from Memory Management (Paging and Segmentation).
There
are many processes executed by CPU but there should be some memory management
for utilizing CPU. When CPU wants to execute a process then, it generates a
logical address having info about that process where it resides in physical
memory. Paging and Segmentation are the concepts for mapping that logical
address to physical address (address of physical memory for process to be
executed).
Terms you should know before going to Paging and Segmentation:
Frames: these are the equal sized parts
into which main memory is divided.
Pages: these are the equal sized parts
into which virtual memory (use the space from secondary storage) is divided.
(One page is indicated by a single entry in Page Map Table (PMT).
Segments: these are the different sized
parts of main memory. (Considered by base address and an offset).
PAGING
Paging
is the concept of using that data which is not in main memory, that data is
stored in the form of pages in virtual memory and operating system has
capability to handle this type of transferring data from virtual memory to main
memory.
Firstly,
many processes have stored in main memory in the form of pages and the
addresses for those pages are mapped in page map table (PMT). PMT having two
values a page number and a frame address. When CPU gives request for any page
then first operating system check that in main memory and if not found page
fault will occur and operating system would check for that page in virtual
memory then, store that page to main memory for further use.
This
is the main concept of paging but the flow of checking pages in main memory is
explained by below figure. Where,
P is
a page number,
D is
an offset address and,
F is
a frame address
First
of all CPU generates a logical address (or virtual address) having two parts,
first part consider page number and second part offset. Using page number as an
index searching operation would be executed in PMT for finding frame address
mapped with given page number. After getting frame address, given offset is
added to frame address and finally physical address is generated and from this
physical address process is returned to CPU for execution.
SEGMENTATION
In
Segmentation only the main alteration is in frames. Frames are replaced with
segments and segments have a base address and size (is, how many addresses come
under particular segment). The entry or information of segments is added in
segment table, so segment table having three values segment name (or segment
no.), segment base address, and segment size.
The
logical address generated by CPU having two parts, a segment number and offset.
In segmentation firstly the segment number given in logical address mapped
within segment table and get base address and size of the segment of main
memory.
After that offset is compared with size of particular segment i.e.
offset should be less than retrieved size of segment. If offset is greater than
size of particular segment than a fault occur.
After
comparison of offset with size of segment, the offset is added with base
address of particular segment and physical address will be generated. This
physical address is used to retrieve the process from main memory for
execution.
Note:
If you have suggestions and queries put them in comment box.
0 comments
If you have any questions or suggestions, you are free to ask, i will appreciate that and, i will try my best...