Operating Systems: Syed Mansoor Sarwar

Download as pps, pdf, or txt
Download as pps, pdf, or txt
You are on page 1of 26

Operating

Systems
Lecture 35
Syed Mansoor Sarwar
Agenda for Today
 Review of previous lecture
 Sharing in paging

 Segmentation

 Logical to physical address


translation
 Hardware support needed

 Protection and sharing


14 September 2019 © Copyright Virtual University of
Pakistan
Review of Lecture 34
 Performance of paging
 Protection in paging

 Structure of the page table

Multi-level paging

Hashed page tables

Inverted page table


14 September 2019 © Copyright Virtual University of
Pakistan
Shared Pages
 Reentrant (read-only) code
pages of a process address
space can be shared
 Shared code appears in the
same logical address space of
all processes
 Multiple invocations of pico or
gcc
14 September 2019 © Copyright Virtual University of
Pakistan
Shared Pages

14 September 2019 © Copyright Virtual University of


Pakistan
Segmentation
 A memory management scheme
that supports programmer’s view
of memory.
 A segment is a logical unit such
as: main program, procedure,
function, method, object, global
variables, stack, symbol table
 A program is a collection of
segments
14 September 2019 © Copyright Virtual University of
Pakistan
Segmentation

14 September 2019 © Copyright Virtual University of


Pakistan
Segmentation

3
4

logical memory
14 September 2019 physical
© Copyright Virtual University
Pakistan
of memory
Segmentation
11

1 44

2
5

3
4 22

5 33

logical memory
14 September 2019 physical
© Copyright Virtual University of memory
Pakistan
Segmentation
11

44
1

2 5

3 22
4
segment 33
5 table

14 September 2019
logical memory © Copyright Virtual University of
Pakistan physical memory
Segmentation
 Logical address consists of a
two tuple:
<segment-number, offset>
 Segment table – maps two-
dimensional logical addresses
to physical addresses
14 September 2019 © Copyright Virtual University of
Pakistan
Segmentation
 Each segment table entry has:
base – contains the starting
physical address where the
segments reside in memory.
limit – specifies the length of
the segment.
14 September 2019 © Copyright Virtual University of
Pakistan
Segmentation
 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
14 September 2019 © Copyright Virtual University of
Pakistan
Segmentation

CPU

14 September 2019 © Copyright Virtual University of


Pakistan
Segmentation
Architecture
 Relocation
Dynamic
By segment table
 Sharing
Shared segments
Same segment number
14 September 2019 © Copyright Virtual University of
Pakistan
Segmentation
Architecture
 Dynamic Storage Allocation
First fit
Best fit
Worst fit
External fragmentation
14 September 2019 © Copyright Virtual University of
Pakistan
Segmentation
Architecture
 Protection: Bits are associated
for this purpose with each entry
in segment table:
Validation bit = 0  illegal
segment
Read, write, execute bits
14 September 2019 © Copyright Virtual University of
Pakistan
Example

14 September 2019 © Copyright Virtual University of


Pakistan
Address Translation
 Logical and Physical Addresses
 (2, 399) – PA: 4300+399 = 4699
 (4, 0) – PA: 4700+0 = 4700
 (4, 1000)  trap
 (3, 1300)  trap
 (6, 297)  trap
14 September 2019 © Copyright Virtual University of
Pakistan
Sharing of Segments
 Sharing at the segment level
and not at the fixed-size page
level
 Sharing at the code or data
level
 Segment table of multiple
processes point to the same
segment
14 September 2019 © Copyright Virtual University of
Pakistan
Sharing of Segments

14 September 2019 © Copyright Virtual University of


Pakistan
Issues with
Segmentation
 External Fragmentation
Total memory space exists to
satisfy a space allocation
request for a segment, but
memory space is not
contiguous.
14 September 2019 © Copyright Virtual University of
Pakistan
Issues with
Segmentation
 Reduce external fragmentation by
compaction
 Shuffle segments to place free
memory together in one block.
 Compaction is possible only if
relocation is dynamic, and is done
at execution time.
14 September 2019 © Copyright Virtual University of
Pakistan
Issues with
Segmentation
 I/O problem
Latch job in memory while it
is involved in I/O.
Do I/O only into OS buffers
 Very large segments  page
program segments—paged
segmentation
14 September 2019 © Copyright Virtual University of
Pakistan
Recap of Lecture
 Sharing in paging
 Segmentation

 Logical to physical address


translation
 Hardware support needed

 Protection and sharing

 Issues with segmentation


14 September 2019 © Copyright Virtual University of
Pakistan
Operating
Systems
Lecture 35
Syed Mansoor Sarwar

14 September 2019 © Copyright Virtual University of


Pakistan

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy