Professional Documents
Culture Documents
What To Do When Not Enough Memory?
What To Do When Not Enough Memory?
memory?
n Thrashing: processes on system require more memory than it has.
P3
Thrashing & Disk I/O P1 P2
Real mem
n Each time one page is brought in, another page, whose contents will
Arvind Krishnamurthy soon be referenced, is thrown out.
n Processes will spend all of their time blocked, waiting for pages to be
Spring 2001 fetched from disk
n I/O devs at 100% utilization but system not getting much useful
work done
n What we wanted: virtual memory the size of disk with access time
of of physical memory
n What we have: memory with access time = disk access
CPU Util.
Program size
Multiprogramming
1
Including Page Fault Behavior Thrashing
n One way to characterize execution: n Process(es) “frequently”reference page not in memory
n Number of cycles before the next page fault (n) given physical n Spend more time waiting for I/O then getting work done
memory size (m) n Three different reasons
n Cost of page fault in cycles (p) n process doesn’t reuse memory, so caching doesn’t work
n CPU Utilization of 1 process = n/p n process does reuse memory, but it does not “fit”
n When you run more processes, say 2:
n CPU utilization (ideally) = 2*n/p
n But number of cycles before the next page fault decreases since
P1
both processes are sharing m mem
n CPU utilization < 2*n/p
n individually, all processes fit and reuse memory, but too many for
n CPU utilization = multiprogramming * page fault behavior system.
n At some point, incremental increase in multiprogramming is less n Which can we actually solve?
than incremental decrease in locality of page access
= .99 * (300 ns) + .01 (10ms) n change scheduling priorities to run processes in groups whose
= .99 (300 ns) + .01 (10,000,000ns)
memory needs can be satisfied (shedding load)
= 297 + 100,000 ~ 100 microseconds
n if new processes try to start, can refuse (admission control)
n or, 300x slower than main memory.
n Even small miss rates lead to unacceptable average access
times. Can OS help?
2
Scheduling: the balance set How to implement working set?
n If sum of working sets of all runnable processes fits in memory, then n Associate an idle time with each page frame
scheduling same as before. n idle time = amount of CPU time received by process since last
n If they do not fit, then refuse to run some access to page
n How? n page’s idle time > T? page not part of working set
n Divide into two groups:
n active: working set loaded
3
Disk organization More on disks
n Disk surface n CD’s and floppies come
n Circular disk coated with individually, but magnetic
magnetic material disks come organized in a
n Tracks disk pack
n Concentric rings around disk
surface, bits laid out serially
along each track
n Cylinder
Certain track of the platter
Sectors
n
n
4
Elevator (SCAN) C-SCAN (Circular SCAN)
n Method n Method
n Take the closest request in the n Like SCAN
0 53 199 0 53 199
direction of travel n But, wrap around
n Real implementations do not go n Real implementation doesn’t go
to the end (called LOOK) to the end (C-LOOK)
n Pros n Pros
n Bounded time for each request n Uniform service time
n Cons n Cons
n Request at the other end will n Do nothing on the return
take a while
98, 183, 37, 122, 14, 124, 65, 67 98, 183, 37, 122, 14, 124, 65, 67
(37, 14, 65, 67, 98, 122, 124, 183) (65, 67, 98, 122, 124, 183, 14, 37)