Download presentation
Presentation is loading. Please wait.
Published byKelli Brittingham Modified over 9 years ago
1
1 Thursday, July 06, 2006 “Experience is something you don't get until just after you need it.” - Olivier
2
2 Example §Pt = Probability of TLB miss = 0.1 §Pf =Probability of page fault when TLB miss occurs = 0.0002 §Tt = time to access TLB = 0.1 µsec §Tm = time to access memory = 1 µsec §Td = time to transfer page to or from disk=10ms §Pd = Probability that page is dirty when replaced =0.5 What is the effective access time for a memory reference?
3
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.
4
4 Global vs. Local Allocation §Global replacement l Process cannot control its own fault rate l Set of pages allocated depends on paging behavior of other processes l Slow down due to external circumstances l More commonly used technique §Local replacement l Cannot make use of less used pages of other processes
5
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
6
6 §Thrashing occurs when a process is spending more time paging than executing.
7
7 Thrashing §If a process does not have “enough” pages, the page-fault rate is very high. This leads to: l low CPU utilization. l operating system thinks that it needs to increase the degree of multiprogramming. l another process added to the system. §Thrashing a process is busy swapping pages in and out.
8
8 Thrashing §Queue of paging device remains a problem in local replacement algorithm
9
9 Thrashing
10
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
11
11 Working-Set Model § working-set window §most recent page references §WSS i (working set of Process P i ) = total number of pages referenced in the most recent (varies in time) l if too small will not encompass entire locality. l if too large will encompass several localities. l if = will encompass entire program.
12
12 Working-Set Model §D = WSS i total demand frames §if D > m Thrashing §Policy if D > m, then suspend one of the processes.
13
13 Working-set model
14
14 Keeping Track of the Working Set §Approximate with interval timer + a reference bit §Example: = 10,000 l Timer interrupts after every 5000 time units. l Keep in memory 2 bits for each page. l Whenever a timer interrupts copy and sets the values of all reference bits to 0. l If one of the bits in memory = 1 page in working set.
15
15 Keeping Track of the Working Set §Improvement = 10 bits and interrupt every 1000 time units.
16
16 Page-Fault Frequency Scheme §Establish “acceptable” page-fault rate. l If actual rate too low, process loses frame. l If actual rate too high, process gains frame.
17
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%
18
18 What will improve the CPU utilization? §CPU utilization 20% §Paging disk97.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?
19
19 Other Considerations Program structure §Demand paging is designed to be transparent to user §Sometimes 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.
20
20 Other Considerations Program structure §Stack has good locality §Hash table produces bad locality by scattering references §However, 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.
21
21 Other Considerations Program structure §Compiler 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.
22
22 §Program structure (Assume: Less than 1024 pages are allocated the process). l A = 1024 x 1024 integer array l Each row is stored in one page l Program 1 for (j = 0; j < A.length; j++) for (i = 0; i < A.length; i++) A[i,j] = 0; l Program 2 for (i = 0; i < A.length; i++) for (j = 0; j < A.length; j++) A[i,j] = 0;
23
23 §Program structure (Assume: Less than 1024 pages are allocated the process). l A = 1024 x 1024 array l Each row is stored in one page l 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
24
24 §Program structure l A = 100 x 100 array for (j = 0; j < 100; j++) for (i = 0; i < 100; i++) A[i,j] = 0; l Array is stored row major l Page size is 400 bytes l 4 frames are allocated to the process. l One array element takes 1 byte of space l Use LRU page replacement What are the number of page faults?
25
25 Other Considerations I/O interlock §Lock bit associated with each frame §Another use: decide to prevent replacing a newly brought in page until it is used at least once.
26
26 §Swap space
27
27 User’s View of a Program
28
28 Logical View of Segmentation 1 3 2 4 1 4 2 3 user spacephysical memory space
29
29 Segmentation Architecture §Logical address consists of a two tuple:, §Segment table – maps two-dimensional physical addresses; each table entry has: l base – contains the starting physical address where the segments reside in memory. l 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.
30
30 Segmentation Hardware
31
31 Example of Segmentation
32
32 §Given a system that uses segmentation, for the following process, give the physical address for the following logical addresses § SegmentBaseLength 0219600 1230014 290100 31327580 4195296
33
33 Protection and Sharing of Segments
34
34 §Fragmentation §Caching issues similar to paging
35
35 §Process in one segment §Fixed segments §Variable segments
36
36 §Combined schemes
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.