Local vs. Global Page Replacement Local: Select victim only among allocated Think Global, frames Equal or proportional frame allocation Act Local (?) Global: Select any free frame, even if allocated to another process Processes have no control over their own page fault rate 119 Brother, can you Brother, can you spare a frame? spare a frame? Time 0 1 2 3 4 5 6 7 8 9 10 11 12 Time 0 1 2 3 4 5 6 7 8 9 10 11 12 Requests a b c d a b c d a b c d Requests a b c d a b c d a b c d 0 a a a a a a a a a a a a a FIFO 0 a a a a d d d c c c b b b FIFO 1 b b b b b b b b b b b b b 1 b b b b b a a a d d d c c 2 c c c c c c c c c c c c c 2 c c c c c c b b b a a a d 3 - - - - d d d d d d d d d Faults X X X X X X X X X Faults X So, what’ s wrong with global replacement? 120 121
Demand May What May Exceed Resources Happen Instead When not enough frames... Demand paging enables frames to cache the currently used part of a process VA space high page fault rate If the cache is large enough, hit ratio is high low CPU utilization OS may increase degree of multiprogramming! few page faults What if not enough frames to go around? should decrease degree of multiprogramming release frames of swapped out processes reduce contention over limited resources 122 123 What May Locality of Reference Happen Instead When not enough frames... If a process access a memory location, then it is likely that high page fault rate the same memory location is going to be accessed low CPU utilization again in the near future (temporal locality) OS may increase degree of multiprogramming! nearby memory locations are going to be accessed in the future (spatial locality) Thrashing CPU Utilization 90% of the execution of a program is sequential process spends all its Most iterative constructs consist of a relatively small time swapping pages number of instructions in and out Degree of Multiprogramming 124 125
<latexit sha1_base64="ZHG+RkPq35frN/qTOCNhAC+vQ8=">AB3icdVDLSgMxFL1TX7W+qi7dBIvgapix4gMUC25cVnRsoS0lk6ZtaGYmJHeEUrp3o7hS3Pk5/oK/4ReYtrqojwMXDuecS+5JqKQw6HnvTmZmdm5+IbuYW1peWV3Lr2/cmCTVjAcskYmuhtRwKWIeoEDJq0pzGoWSV8Le+civ3HJtRBJfY1/xRkQ7sWgLRtFKV6opmvmC73pjkP9J4ezjVL0CQLmZf6u3EpZGPEYmqTE131PYGFCNgk+zNVTwxVlPdrhg/GBQ7JjpRZpJ9pOjGSsTuVoZEw/Cm0yotg1P72R+JdXS7F91BiIWKXIYzZ5qJ1KgkZtSUtoTlD2beEMi3shYR1qaYM7Z/kbHXPLR7s+0WP/Cbf1YM9j1L/1C6QmyMIWbMu+HAIJbiAMgTAoAP38ATPTujcOQ/O4ySacb52NmEKzsnDGaL9w=</latexit><latexit sha1_base64="1/VW9mlyb6fVGRlOAzoBG5h9tNU=">AB3icdVDLSgMxFL1TX3V8V26CRbB1TBjxQdYLhxWdGxhbaUTJpQzMzIckIpXTvRnGluPZn/APxN/wCM60u6uPAhcM5J7EgjOlHbdys3Mzs3v5BftJeWV1bXCusb1ypJaE+SXgi6wFWlLOY+pTutCUhwFnNaC/lnm126oVCyJr/RA0FaEuzELGcHaSJeizdqFoue4Y6D/SfH0oyxe3uxytV14bXYSkY01oRjpRqeK3RriKVmhNOR3UwVFZj0cZcOxweO0I6ROihMpJlYo7E6lcORUoMoMkI6576WXiX14j1eFRa8hikWoak8lDYcqRTlDWFnWYpETzgSGYSGYuRKSHJSba/IltqrtO6WDfK7noN/mu7u85x4534RUrJzBHrZgG3bBg0OowDlUwQcCXbiDR3iyAuvWurceJtGc9bWzCVOwnj8BgsCNGA=</latexit><latexit sha1_base64="1/VW9mlyb6fVGRlOAzoBG5h9tNU=">AB3icdVDLSgMxFL1TX3V8V26CRbB1TBjxQdYLhxWdGxhbaUTJpQzMzIckIpXTvRnGluPZn/APxN/wCM60u6uPAhcM5J7EgjOlHbdys3Mzs3v5BftJeWV1bXCusb1ypJaE+SXgi6wFWlLOY+pTutCUhwFnNaC/lnm126oVCyJr/RA0FaEuzELGcHaSJeizdqFoue4Y6D/SfH0oyxe3uxytV14bXYSkY01oRjpRqeK3RriKVmhNOR3UwVFZj0cZcOxweO0I6ROihMpJlYo7E6lcORUoMoMkI6576WXiX14j1eFRa8hikWoak8lDYcqRTlDWFnWYpETzgSGYSGYuRKSHJSba/IltqrtO6WDfK7noN/mu7u85x4534RUrJzBHrZgG3bBg0OowDlUwQcCXbiDR3iyAuvWurceJtGc9bWzCVOwnj8BgsCNGA=</latexit><latexit sha1_base64="1/VW9mlyb6fVGRlOAzoBG5h9tNU=">AB3icdVDLSgMxFL1TX3V8V26CRbB1TBjxQdYLhxWdGxhbaUTJpQzMzIckIpXTvRnGluPZn/APxN/wCM60u6uPAhcM5J7EgjOlHbdys3Mzs3v5BftJeWV1bXCusb1ypJaE+SXgi6wFWlLOY+pTutCUhwFnNaC/lnm126oVCyJr/RA0FaEuzELGcHaSJeizdqFoue4Y6D/SfH0oyxe3uxytV14bXYSkY01oRjpRqeK3RriKVmhNOR3UwVFZj0cZcOxweO0I6ROihMpJlYo7E6lcORUoMoMkI6576WXiX14j1eFRa8hikWoak8lDYcqRTlDWFnWYpETzgSGYSGYuRKSHJSba/IltqrtO6WDfK7noN/mu7u85x4534RUrJzBHrZgG3bBg0OowDlUwQcCXbiDR3iyAuvWurceJtGc9bWzCVOwnj8BgsCNGA=</latexit><latexit sha1_base64="1/VW9mlyb6fVGRlOAzoBG5h9tNU=">AB3icdVDLSgMxFL1TX3V8V26CRbB1TBjxQdYLhxWdGxhbaUTJpQzMzIckIpXTvRnGluPZn/APxN/wCM60u6uPAhcM5J7EgjOlHbdys3Mzs3v5BftJeWV1bXCusb1ypJaE+SXgi6wFWlLOY+pTutCUhwFnNaC/lnm126oVCyJr/RA0FaEuzELGcHaSJeizdqFoue4Y6D/SfH0oyxe3uxytV14bXYSkY01oRjpRqeK3RriKVmhNOR3UwVFZj0cZcOxweO0I6ROihMpJlYo7E6lcORUoMoMkI6576WXiX14j1eFRa8hikWoak8lDYcqRTlDWFnWYpETzgSGYSGYuRKSHJSba/IltqrtO6WDfK7noN/mu7u85x4534RUrJzBHrZgG3bBg0OowDlUwQcCXbiDR3iyAuvWurceJtGc9bWzCVOwnj8BgsCNGA=</latexit><latexit sha1_base64="r/Ss4if5ogUMD6/+QWEvGwrnzac=">AB3icdVDLSgMxFL1TX7W+qi7dBIvgapixQe4KLhxWdGxhbaUTJpQzOZIbkjlNK9G8WV4h/5C/6N6cNFfRwIHM454d5zw1QKg5736eSWldW1/LrhY3Nre2d4u7evUkyzXjAEpnoRkgNl0LxAVK3kg1p3EoeT0cXE38+gPXRiTqDocpb8e0p0QkGEUr3aYd0SmWfNebgvxPSjBHrVP8aHUTlsVcIZPUmKbvpdgeUY2CST4utDLDU8oGtMdH0wXH5MhKXRIl2j6FZKou5GhszDAObTKm2Dc/vYn4l9fMDpvj4RKM+SKzQZFmSYkElb0hWaM5RDSyjTwm5IWJ9qytDepGCre275tOKXPfKbfFcPTtwL17/xS9XL+Q3ycACHcAw+nEVrqEGATDowRO8wpsTOo/Os/Myi+ac+Z9WIDz/gXJiIl5</latexit> Tracking Locality The Working Set Model Define a WS window of � references When a process executes it moves from locality (set of pages used together) to locality Goal: Keep in memory a process’ W S WS i = distinct pages referenced in latest � the size of the process’ locality (a.k.a. its p i working set) can change over time � too small does not cover locality � too large covers many localities Goal: track the size of the process’ working set, dynamically acquiring and releasing frames as Thrashing if WS i > # frames Σ i necessary if so, swap out one of the processes If enough free frames, increase degree of multiprogramming 126 127 WS Page Replacement WS Page Replacement � = 4 � = 4 Time 0 1 2 3 4 5 6 7 8 9 10 Time 0 1 2 3 4 5 6 7 8 9 10 Requests c c d b c e c e a d Requests c c d b c e c e a d Page a t =0 • Page a t =0 • • • • • • Pages in Memory Pages in Memory • Page b Page b • • • • Page c Page c • • • • • • • • • • t = − 1 t = − 1 Page d • Page d • • • • • • • • t = − 2 t = − 2 Page e • Page e • • • • • • • Faults Faults X X X X X • page fault & page mapped to a frame • page fault & page mapped to a frame • page mapped to a frame • page mapped to a frame • page referenced & mapped to a frame • page referenced & mapped to a frame 128 129
WS and Computing the WS Page Fault Frequency Use interval timer , the R bit, and extra bits k τ When too many page faults, increase WS; when per page too few, decrease it Define ∆ = τ × k Keep time of last page fault t last When elapses, shift right once the bits, On page fault: k τ copy R bit in most significant bit, and reset R 1) add faulting page to the working set threshold If one of the bits is 1, the corresponding k 2) if , then unmap all pages not t current − t last > τ ∗ page is in WS referenced in [ ] t last , t current 130 131 PFF Page Replacement PFF Page Replacement τ ∗ = 2 τ ∗ = 2 Time 0 1 2 3 4 5 6 7 8 9 10 Time 0 1 2 3 4 5 6 7 8 9 10 Requests c c d b c e c e a d Requests c c d b c e c e a d • • • • • Page a Page a Pages in Memory Pages in Memory Page b Page b • Page c Page c • • • • Page d • Page d • • • • • Page e • Page e • • • • Faults Faults X X 1 3 t current − t last t current − t last 132 133
PFF Page Replacement τ ∗ = 2 Time 0 1 2 3 4 5 6 7 8 9 10 Requests c c d b c e c e a d • • • Page a • • • Pages in Memory Page b • • • • • • • • • Page c • • • • • • • • • • Page d • • • • • • Page e • • • • • • • • • X X Faults X X X 1 3 2 3 1 t current − t last 134
You Need to Get Out More! I/O Devices How does a computer connect with the outside world? Interacting I/O Architecture with a Device CPU MEM MEM CPU Graph Memory Bus Interface Registers Status Command Data (what the OS sees) PCIe Abstraction eSATA I/O General I/O Bus CHIP (PCI) (what the user sees) Internals (what is needed to Graph USB implement the abstraction) Peripheral I/O Bus (SCSI, SATA USB)
Recommend
More recommend