note

Segmentation
This scheme partitions memory into logically related data units such as module,
procedure, stack, data, file, etc. In segmentation, a reference to a memory location
includes a value that identifies a segment and an offset within that segment. Virtual
addresses become set of <segment number, offset>. It also allows programs and
data to be broken up into logically independent address spaces and to aid sharing
and protection. Each segment size can differ from one another and the segments
are resided in different part of main memory.
fig: segmentation hardware
fig: Memory view of segments
As we can see in the immediate figure above, the segments have different sizes and
can grow independently. Also they are loaded in different parts of memory.
Segmentation provide user’s perspective of memory partition. Segments or
sections are also used in object files of compiled programs when they are linked
together into a program image and when the image is loaded into memory.
Differences between paging and segmentation
Paging is used to get a large linear address space without having to buy more
physical memory.
Segmentation allows programs and data to be broken up into logically independent
address spaces and to aid sharing and protection.
Paging does not distinguish and protect procedures and data separately.
Segmentation distinguishes and separately protects procedures and data.
Unlike segmentation, Paging does not facilitate sharing of procedures.
Paging is transparent to programmers (system handles it automatically).
Segmentation requires programmer to be aware of memory limits as programmer
tries to allocate memory to functions and variables or tries to access read
only memory violation, which results in segmentation fault
(see Segmentation fault for more details on different types of seg. faults)
Mapping from logical to physical address is different for paging and segmentation.
Here's an illustration based on 16 bit-address space:
For paging :
The 6-bit page value is used to select a proper entry in process page table. the 6-bit
process entry occupying the six most significant bit and the 10-bit offset occupying
the 10 least significant bit forms a 16-bit physical address.
For segmentation :
The 4-bit segment of a logical address selects the proper entry in the process
segment table. The base value is added to the 12 bit offset value to get the 16 bit
physical address.

Comments

Popular posts from this blog

thread

psychology two questions n their answer