Top Banner
1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier
36

1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

Dec 16, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

1

Thursday, July 06, 2006

“Experience is something you don't get until just after you

need it.”

- Olivier

Page 2: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

2

ExamplePt = Probability of TLB miss = 0.1Pf =Probability of page fault when TLB miss

occurs = 0.0002Tt = time to access TLB = 0.1 µsec Tm = time to access memory = 1 µsecTd = time to transfer page to or from disk=10msPd = Probability that page is dirty when replaced

=0.5

What is the effective access time for a memory reference?

Page 3: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

3

Global vs. Local Allocation

Global replacement – process selects a replacement frame from the set of all frames; one process can take a frame from another.

Local replacement – each process selects from only its own set of allocated frames.

Page 4: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

4

Global vs. Local Allocation

Global replacement Process cannot control its own fault rate Set of pages allocated depends on paging

behavior of other processes Slow down due to external circumstances More commonly used technique

Local replacement Cannot make use of less used pages of other

processes

Page 5: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

5

We must have enough frames to hold all the different pages that a single instruction can reference.

Defined by instruction set architecture

Allocating only the minimum results in very high paging activity

Page 6: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

6

Thrashing occurs when a process is spending more time paging than executing.

Page 7: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

7

Thrashing

If a process does not have “enough” pages, the page-fault rate is very high. This leads to: low CPU utilization. operating system thinks that it needs to increase

the degree of multiprogramming. another process added to the system.

Thrashing a process is busy swapping pages in and out.

Page 8: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

8

Thrashing

Queue of paging device remains a problem in local replacement algorithm

Page 9: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

9

Thrashing

Page 10: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

10

•Why does paging work?

Locality model•Process migrates from one locality to another.•Localities may overlap.

•Why does thrashing occur? size of locality > total memory size

Page 11: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

11

Working-Set Model working-set window most recent page references

WSSi (working set of Process Pi) =total number of pages referenced in the most recent (varies in time) if too small will not encompass entire locality. if too large will encompass several localities. if = will encompass entire program.

Page 12: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

12

Working-Set ModelD = WSSi total demand frames

if D > m ThrashingPolicy if D > m, then suspend one of

the processes.

Page 13: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

13

Working-set model

Page 14: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

14

Keeping Track of the Working SetApproximate with interval timer + a reference bitExample: = 10,000

Timer interrupts after every 5000 time units. Keep in memory 2 bits for each page. Whenever a timer interrupts copy and sets the values

of all reference bits to 0. If one of the bits in memory = 1 page in working

set.

Page 15: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

15

Keeping Track of the Working Set

Improvement = 10 bits and interrupt every 1000 time units.

Page 16: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

16

Page-Fault Frequency Scheme

Establish “acceptable” page-fault rate. If actual rate too low, process loses frame. If actual rate too high, process gains frame.

Page 17: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

17

1. CPU utilization = 13%, Paging Disk Utilization = 97%

2. CPU utilization = 87%, Paging Disk Utilization = 3%

3. CPU utilization = 13%, Paging Disk Utilization = 3%

Page 18: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

18

What will improve the CPU utilization?

CPU utilization 20% Paging disk 97.7% Other I/O devices 5%1. Install a bigger paging disk?2. Increase degree of multiprogramming?3. Decrease degree of multiprogramming?4. Install more memory?5. Install faster hard disk?6. Increase page size?

Page 19: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

19

Other ConsiderationsProgram structureDemand paging is designed to be transparent

to userSometimes system performance can be

improved if user (or compiler) is aware of underlying demand paging

Careful selection of data structures increases locality and hence lower page fault rate and number of pages in the working set.

Page 20: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

20

Other ConsiderationsProgram structureStack has good localityHash table produces bad locality by

scattering referencesHowever, locality of reference is just one

measure of efficiency of use of data structure. Other heavily weighted factors include total number of memory references and total number of pages touched.

Page 21: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

21

Other ConsiderationsProgram structureCompiler and loader can have significant

effect on paging. Loader can avoid placing routine across

page boundaries, keeping each routine in a page

Routines that call each other can be packed into same page.

Page 22: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

22

Program structure (Assume: Less than 1024 pages are allocated the process). A = 1024 x 1024 integer array Each row is stored in one page Program 1 for (j = 0; j < A.length; j++)

for (i = 0; i < A.length; i++)A[i,j] = 0;

Program 2 for (i = 0; i < A.length; i++)for (j = 0; j < A.length; j++)

A[i,j] = 0;

Page 23: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

23

Program structure (Assume: Less than 1024 pages are allocated the process). A = 1024 x 1024 array Each row is stored in one page Program 1 for (j = 0; j < A.length; j++)

for (i = 0; i < A.length; i++)A[i,j] = 0;

1024 x 1024 page faults Program 2 for (i = 0; i < A.length; i++)

for (j = 0; j < A.length; j++)A[i,j] = 0;

1024 page faults

Page 24: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

24

Program structure A = 100 x 100 array

for (j = 0; j < 100; j++) for (i = 0; i < 100; i++) A[i,j] = 0;

Array is stored row major Page size is 400 bytes 4 frames are allocated to the process. One array element takes 1 byte of space Use LRU page replacement

What are the number of page faults?

Page 25: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

25

Other ConsiderationsI/O interlockLock bit associated with each frameAnother use: decide to prevent replacing a

newly brought in page until it is used at least once.

Page 26: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

26

Swap space

Page 27: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

27

User’s View of a Program

Page 28: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

28

Logical View of Segmentation

1

3

2

4

1

4

2

3

user space physical memory space

Page 29: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

29

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.

Page 30: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

30

Segmentation Hardware

Page 31: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

31

Example of Segmentation

Page 32: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

32

Given a system that uses segmentation, for the following process, give the physical address for the following logical addresses

<0,430> <4,112>

Segment Base Length

0 219 600

1 2300 14

2 90 100

3 1327 580

4 1952 96

Page 33: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

33

Protection and Sharing of Segments

Page 34: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

34

FragmentationCaching issues similar to paging

Page 35: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

35

Process in one segmentFixed segmentsVariable segments

Page 36: 1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier.

36

Combined schemes