Presentation is loading. Please wait.

Presentation is loading. Please wait.

Allocation of Frames Each process needs minimum number of pages Two major allocation schemes –fixed allocation –priority allocation.

Similar presentations


Presentation on theme: "Allocation of Frames Each process needs minimum number of pages Two major allocation schemes –fixed allocation –priority allocation."— Presentation transcript:

1 Allocation of Frames Each process needs minimum number of pages Two major allocation schemes –fixed allocation –priority allocation

2 Fixed Allocation Equal allocation – For example, if there are 100 frames and 5 processes, give each process 20 frames. Proportional allocation – Allocate according to the size of process

3 Priority Allocation Use a proportional allocation scheme using priorities rather than size If process P i generates a page fault, –select for replacement one of its frames –select for replacement a frame from a process with lower priority number

4 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

5 Thrashing If a process does not have “enough” pages, the page-fault rate is very high. This leads to low CPU utilization Thrashing  a process is busy swapping pages in and out It may happen –operating system thinks that it needs to increase the degree of multiprogramming –another process added to the system

6 Thrashing

7 Why does paging work? –Locality model Process migrates from one locality to another Why does thrashing occur? –  size of locality > total memory size

8 Dynamic Paging Algorithms Paging algorithms considered so far all assume that a process is allocated a fixed amount of memory when it is started and the amount does not change during the computation Static algorithms do not adjust the allocation of frames, even if the process passes through phases in which it requires a large physical address space or its memory requirements are modest A process changes locality as it executes. When the locality changes, not only do the identities of the pages change but also the number of pages in the locality is likely to change Sometimes the process needs only a few frames to hold the pages it is using, while at other times it needs many frames Dynamic paging algorithms adjust the memory allocation to match the process’s needs as they change

9 Working Set Model   working set window  a fixed number of page references (e.g., 10,000 instructions) WS(t i )  working set at time t i  pages referenced in the most recent  (up to t i ) –if  too small will not encompass entire locality –if  too large will encompass several localities –if  =   will encompass entire program

10 Working Set Model For any fixed value of , the working set size can vary over time –For many programs, periods of relatively stable working set sizes alternate with periods of rapid change –When a process first begins executing, it gradually builds up to a working set as it references new pages –Eventually, by the principle of locality, the process should stabilize on a certain set of pages –Subsequent transient periods reflect a shift of the program to a new locality

11 Working Set Model The OS monitors the working set of each process and allocates enough frames to provide it with its working set size –If there are enough extra frames, another process can be initiated –D =  |WS(t i )|  sum of working set sizes of all processes at t i  total demand frames –if D > m  Thrashing –Policy: if D > m, then suspend one of the processes This strategy prevents thrashing while keeping the degree of multiprogramming as high as possible. Thus, it optimizes CPU utilization

12 Example Given the following reference string: (a) Determine WS(t i ) with  = 3 (b) Determine WS(t i ) with  = 4 (c) Determine WS(t i ) with  = 9


Download ppt "Allocation of Frames Each process needs minimum number of pages Two major allocation schemes –fixed allocation –priority allocation."

Similar presentations


Ads by Google