Você está na página 1de 19

Y 


2 
  
 
 

   
 

2 
   

V Thrashing
V Working Set
  
V Swapping out a piece of a process just
before that piece is needed
V The processor spends most of its time
swapping pieces rather than executing
user instructions
2   

V 2rogram and data references within a


process tend to cluster
V Only a few pieces of a process will be
needed over a short period of time
V 2ossible to make intelligent guesses about
which pieces will be needed in the future
V This suggests that virtual memory may
work efficiently
 
 
 2
  
V f a process does not have ³enough´
pages, the page-fault rate is very high.
This leads to:
Ô low C2 utilization
Ô operating system thinks that it needs to
increase the degree of multiprogramming
Ô another process added to the system

V Thrashing 0 a process is busy swapping


pages in and out
  
! 2  
V Why does demand paging work?
Locality model
Ô 2rocess migrates from one
locality to another
Ô Localities may overlap

V Why does thrashing occur?


Πsize of locality > total memory
size
’ 
V ^ 0 working-set window 0 a fixed number of
page references
Example: 10,000 instruction
V ’  ^working set size of 2rocess 2) =
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
V ! = Œ ’  0 total demand frames
V if ! >  Thrashing
V 2olicy if ! > m, then suspend one of the
processes
’  
d   ’ 
V îpproximate with interval timer + a reference
bit
V Example: ^ = 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
Ô f one of the bits in memory = 1  page in
working set
V Why is this not completely accurate?
V mprovement = 10 bits and interrupt every 1000
time units
2 
V Smaller page size, less amount of internal
fragmentation
V Smaller page size, more pages required
per process
V More pages per process means larger
page tables
V Larger page tables means large portion of
page tables in virtual memory
V Secondary memory is designed to
efficiently transfer large blocks of data so
a large page size is better
2 
V Small page size, large number of pages
will be found in main memory
V îs time goes on during execution, the
pages in memory will all contain portions
of the process near recent references.
2age faults low.
V ncreased page size causes pages to
contain locations further from any recent
reference. 2age faults rise.
G 
  
V  

     
        
  
   
V    
 
  

V      
 

  
   

 
 
G 
 
V G


 

  
 

V 



G


Ñ     
!""
 #   
 $" 
    %    

 
  
 @  
 
 

u  
 @ @


   @   iu
u 
 
 

 i  X 


 i  X 





V &      
       

V '
  2    
 
  
  
 

  
  

  
   
—

V —lobal replacement ± process
selects a replacement frame from
the set of all frames; one process
can take a frame from another.
V Local replacement ± each process
selects from only its own set of
allocated frames.

Você também pode gostar