Segmentation topic is presented in a most easy way.
Segmentation is a user view of memory in Operating System. Segmentation is one of the most common ways to achieve memory protection. In a computer system using segmentation, an instruction operand that refers to a memory location includes a value that identifies a segment and an offset within that segment.
6. Segmentation:
Memory-management scheme that supports user view of memory
(Programmar’s View).
A program is a collection of segments. A segment is a logical unit such as:
• main program
• procedure
• function
• method
• object
• local variables, global variables
• common block
• stack
• symbol table
• arrays
Siraj Munir – CS@DSU
12/21/2016 6
7. User’s View of a Program:
Siraj Munir – CS@DSU
12/21/2016 7
8. Logical View of Segmentation
Siraj Munir – CS@DSU
1
2
3
4
1
4
2
3
user space physical memory space
12/21/2016 8
9. Segmentation :
Each segment has a name and length
Address specify both the segment name and offset
Instead of using name the segments are numbered
The logical address consists of a tuple:
<segment-number,offset>
Siraj Munir – CS@DSU
12/21/2016 9
10. Segmentation Architecture:
Logical address consists of a two tuple:
<segment-number, offset>,
Segment table – maps two-dimensional physical addresses; each table entry has:
base – contains the starting physical address where the segments reside in memory
limit – specifies the length of the segment
Segment-table base register (STBR) points to the segment table’s location in memory
Segment-table length register (STLR) indicates number of segments used by a program;
segment number s is legal if s < STLR
Siraj Munir – CS@DSU
12/21/2016 10
12. Segmentation Hardware:
Logical address generated by CPU consists of two parts
Segment no. ‘s’:-used as a index into segment table
Offset ‘d’:- must be between ‘0’ and segment limit
A trap is generated if offset exceeds the segment limit
(Correct offset + segment base = address in physical memory)
Segment table is an array of base-limit register pair
Siraj Munir – CS@DSU
12/21/2016 12
Segmentation is a Memory management scheme that supports user view of memory.
As we’ve already seen, the user’s view of memory is not the same as the actual physical memory.
What if the hardware could provide a memory mechanism that mapped the programmer’s view to the
actual physical memory?
The system would have more freedom to manage memory, while the programmer would have a more natural programming
environment.
Segmentation provides such a mechanism.
Segmentation is a Memory management scheme that supports user view of memory.
User jo physical memory interact krne k liye asaani hou, 4 process hain, 1,4,2,3 ko aesay place krdia hai k 4ro k aik hisab se memory milay, Alag alag segments mei divide krde, agar koi naya process aye tou who aik format mei aajaega, bajae iske k who idhr udhr allocate hojae.
Segment table has two addresses, Base and Limit, STBR location ko point krta hai, aur STLR segments ki length batata hai.