In segmentation, a program's data and instructions are divided into blocks called segments. A segment is a logical entity in a program.
Segmentation
•
In segmentation, a program's data and instructions are divided into blocks
called segments. A segment is a logical entity in a program.
• Fig. 4.7.1 shows programmer's view.
• Logical view:
A process consists of a set segments.
• Physical
view: It consists of non-adjacent areas of memory
allocated to segments.
• All segment size may be equal or may not be equal.
Segmentation support user view of memory. Fig 4.7.1 shows
programmer`s view of a program.
• Segmentation can be implemented with
or without paging.
• Collection of segment is called as logical address space.
Each segment is identified by its name.
•
Processor generates logical addresses. These addresses consists of a segment
number and an offset into the segment. Segment number is used as an index to
segment page table.
•
Fig 4.7.2 shows logical address
•
Segment
names are normally symbolic names.
• Operating system maintains a segment
table for each process. It is usually stored in main memory as a segment that
is not to be loaded as long as the process can
•
Each entry in the segment table has a segment base and a segment limit. The
base field contains the segment relocation register for the target segment. The
segment limit field contains the length of the segment.
• Fig. 4.7.3 shows an address
translation in segmentation.
• Segment table contains the physical
address of the start of the segment. Then add the offset to the base and
generate the physical address.
•
If the required reference is not found in one of the segment registers, then
error is generated. At the same time, operating system does lookup in segment
table and loads new segment descriptor into the register.
•
Sharing of segment provides less overhead than the pure paging segment.
Multiple processes can share a segment
•
Two processes share a segment when their segment table entries point to the
same segment in main memory. Operating system maintains global segment table
for everyone and also used by OS.
•
Access rights for segment are usually included in table entry. An illegal
access of memory is protected by memory mapping hardware. It checks the
protection bits associated with each segment table.
•
Fig. 4.7.4 shows sharing in segmentation. Access rights for segments are :
Read, write, append and execute.
• Segmentation suffer from external
fragmentation because segment sizes vary. Entire segment is either memory or on
secondary storage disk.
1.
It
provides virtual memory.
2. Allows dynamic segment growth.
3. Segmentation assists dynamic linking.
4.
Segmentation is visible.
1. Maximum size of a segment is limited
by the size of main memory.
2. Difficulty to manage variable size
segments on secondary storage.
3. Fragmentation and complicated memory
management.
Example
4.7.1 Describe
a mechanism by which one segment could belong to the address space of two
different processes. AU May-16, Marks 8
Solution: Segment tables are a collection of
base-limit registers, segments can be shared when entries in the segment table
of two different jobs point to the same physical location. The two segment
tables must have identical base pointers, and the shared segment number must be
the same in the two processes.
University
Questions
1. Draw the
diagram of segmentation memory management scheme and explain its principle. AU Dec.-17, Marks 13
2. Explain
why sharing a reentrant module is easier when segmentation is used than when
pure paging is used with example. AU May-18, Marks 13
Introduction to Operating Systems: Unit III: Memory Management : Tag: : Memory Management - Introduction to Operating Systems - Segmentation
Introduction to Operating Systems
CS3451 4th Semester CSE Dept | 2021 Regulation | 4th Semester CSE Dept 2021 Regulation