An optimal demand prepaging algorithm

An optimal demand prepaging algorithm

v*~7,nunlber3 INFORMATION PROCESSING LETTERS April1978 55 AN OPTIMAL DEMAND PREPAGING AISORI’IWM Radha Krishan ARORA and ILK. SUBRAMANIAN Cbmputer...

620KB Sizes 2 Downloads 76 Views

v*~7,nunlber3

INFORMATION PROCESSING LETTERS

April1978

55

AN OPTIMAL DEMAND PREPAGING AISORI’IWM Radha Krishan ARORA and ILK. SUBRAMANIAN Cbmputer Centre, In&n Institute of Technology,New Delhi I IO029, In& Received 8 December 1977

Optimal algorithms, prepaging, LRU stack

The important performance measures of programs using gaged virtual memory systems are the nlsmber of page faults, the number of page pulls and the spacetime product of the main memory. The paging algorithms attempt to minimize these performance measures. However, none of the realizable algorithms reach the actual minimum, because they face uncertainty when choosing a page for either removal [ 1 ] or prepaging [2,3]. Algorithns which minimize the ‘performance measures are called optimal algorithms and MIN [ 1], OPT [4], VMIN [S] and DPMIN [6] are the important optimal dgorithms. MIN and OPT are fmed space demand paging algorithms which minimize the number of page pulls. VMIN is a variable space demand paging algorithm which minimizes the space-time product subject to certain assumptions. DPMIN is a fixed space demand prepaging algorithm which minimizes the number of page faults. All these algorithms axe unrealizabld as *theyeither require a look-ahead or involve a delay. However, finding the minimum performance measure fo:r a given reference string and main memory size will be useful to evaluate memory configurations and page management schemes, Belady’s MIN algorithm can process the reference string as it is generated by the program and given a fixed memory size, compute the associated single page pull count by constructing the memory state and transitions. This is simple, requires no look-ahead and is efficient for one value of the memory size; but the memory states are obtained only after a necessary 132

and variable delay. The OPT algorithm processes the reference string and gives the memory states and transitions for various memory sties. But it requires two passes of the string and large storage. Relay and Palmer [7] have suggested a modified MIN algorithm called multivalued MIN, which does not require a look-ahead, requires only a small amount of information to be recorded or stored and thereby enables itself to be used on-line. Trivedi [6] has described an optimal demand prepaging algorithm called DPMIN which is optimal with respect to page faults. It scans!,at the time of a page fault, the f lture reference string and fetches the first ‘m’ pages cohere 'm' is the size of the memory allotted) that will be referred in the future. The statement of DPMIN algorithm is given in the appendix. It is obvious that DPMIN uses a look-ahead policy and needs the knowledge of future references and hence unrealizable. This paper describes another optimal algorithm called ODPP which, for a given page trace and memory capacity, gives tihe minimum number of page faults any demand prepaging algorithm could produce. It also gives the corresponding page pulls. Unlike the DPMIN, this does not require a look-ahead. ODPP picks up every reference and checks whether it is to be included in the previous loading, in which case this reference is not to cause a page fault, or it is not to be loadtd earlier and hence to cause a new page fault. The algorithm also decides whether the refed ence will be responsible for a page pull or not. Though, like DPMIN, ODPP is also not a stack algoritnm, simultaneous determination of the total

Volume 7, number3

INFORMATIONPROCIZWNG’ LE’IWRS

April 1878

n

number of page faults and page pulls for various memory sizes is easy. A modified version of ODPP for simultaneous operation Withvarious memory sizesis also presented. The on-like use of the algorithm is discussedin Section 3. 2. An optimal demand prepaging

algorithm

ODPP,an optimal demand prepaging algorithm, constructs an LRU stack and uses the stack distance of a reference, which givesthe backward distance of the reference to the same page, for deciding whether the reference to a page will cause a page fault or would have been prepaged. We also decide whether it could have caused a page pull. For a particular size of the main memo&we construct another stack, called ODPP stack, which gives the number of page faults, the number of page pulls and the number of pages that have been pulled and are now present in the main memory. The first element, Say PIG, of the ODPP stack gives the number of pages to have been pulled into main memory. The second element, say PF, gives the page faults occurred. The third element, say PULL, gives the ntunber of pages pulled after the last page fault. The last element, Say, TPIJLL, gives the total number of page pulls. This algorithm does not use look-ahead and there is no delay involved in determining the page faults. However, the total number of page pulls and the other elements will be exact only when either the complete reference string is processed or the memory is full, i.e., PK; = m. ODPPa@withm Initialize the PPG element of the ODPP stack with m a?d others with 0. For the reference rt find the stack distance dt. If dt G PPG update the LRU stack and return. If PPG = m do the following with the ODPP stack and r&urn: Reset PPG and PULL with 1. Increase PF and TPULL by 1. Increase PPO by 1. If dt - m < PULL return. Increase PULL and TPULL by 1.

Return.

It can be seen from the following that this al-t_ rithm g&s the same number~of page faults andpage pulls as DPMDL& givesthe backward distance of any reference. It actually givesthe distance between two references to the same page in terms of the nunher of distixrctpages referred. Hence, dt G PPG means that the pa8e referred now, has been referred and. f0und available in the main memory after the last page fault or loaded during the last page fault. Hence

it will cause neither a new page fault nor a new page pd. dt > ITG means that the page referred could not have been loaded during the last page fault. Now PPG marybe either equal to m or less than m. If PPC i13equal to m that means that the memory is full and the page referred will cause a page fault and page pull. If PPG < m the present reference is considered to be avdable in the main memory and hence will not c.luse a page fault. However, if dt > m + PULL, i,e., the page wan neither pulled after the last page fault nor available in the memory at the time of the pa.ge fault, the reference causes a pull and nc:,pull otherwise. A procrf is given in the appendix, along with the statement of the algorithm, to Show that ODPP computes exactly the Same number of page faults and page pu.ils as DPMIN algorithm, which has been proved optimal by Trivedi [63. It can be: seen easily that since dt depends only on the past references this algorithm! does not need a! look-ahead. An example, using this algorithm on $a reference string is Shown in Table 1. The ODPP may be easily extended for simultaneous use with different memory sizes using the ODP?
Volume 7, number 3

INFORMATION PROCSSIIWG LETTERS

Table 1 Performance of ODPP with 112= 3 Ref. string:

1314276453246

LWU rkack

1314276453246 131427645324 3142764532 314276453 31127665 3312777 3

dt PPG PF PULL TPULL

OD0, 2 WceO~4 31223123123123 011112223334k4 01223123123112 0 1 2 2 3 4 5 6

1

1

f

1

-7645

7 8

April 1978

eliminates the need for the storage of the reference string. All that need be stored is an LRU stack and the ODPP stack having 5 elements. Thus ODPP requires that only a small amount of information be recorded or stored while processing and hence it can be easily used on-line. In systems with LRU replacement algorithm; as the system itself maintains the LRU stack, the additional storage required to use ODPP on-line is only to store the ODPP stack and the additional execution time required is only for updating the ODgP stack. Hence the cost of on-line use of the ODPP algorithm, in such a system will be very much less.

9101011

4. Conclusion No. of page faults = 4

No. of page pulls = 11

whose PPG ele.ments are equal to the corres-

ponding column beads and mark them off: Reset PPC and PULL elements with 1. Increase PF and TPULL elements by 1. Increase the PPG elements of unmarked columns by 1. Mark off the columns in which dt G sum of the column head and PULL element. Increase the PULL and TPULL elements of the unmarked columns by 1. Return. Table 2 gives the example of using this algorithm on our reference striig, with M = 3 and m = 4. The LRU stack in Table 1 has been used.

3. On-line use of the algorithm The ODPP algorithm computes the minimum number of page faults and the corresponding page pulls of a program for a given ftued size of memory. It does not use a look-ahead. The references already processed are not needed again by the algorithm as it retains the necessary information in the form of the LRU stack. In fact, at any ina:ant, it picks up okay one reference, processes it ar!d then only goes to the next reference. Hence it can process the refere~c string as it is generated by the program. This 1.34

An algorithm for computing the minimum number of page faults and the corresponding page pulls of a program for a fixed memory size is presented in this paper. Its extension for simultaneous computation of the quantities for many memory sizes is also presented. This could very well serve as a bench mark of performance among all the demand prepaging algorithms. As ODPP uses the references only when they are generated and does not need them when once used, it can be used on-line. The extra cost involved in using the algorithm, on-line, with systems using LRU stack will be only marginal.

Appendix

Let sy, $2, *.*, St ..* be the sequence of memory states corresponding to the reference string R =rr, ta, .**,r; .... and the initial memory state se. If Yand s’ are the memory states before and after the reference rr the DPlMN algorithm could be defined as follows:

s’ =s s’=(yl,y2 where Yl =rt

ifr,Es, ,..., y,)

ifr?Gs,

34 11 21 11 11

34 00

00 0 0

ak: PF

PULL TRILL

m: 3 No. of page faults: 4 No. of page pulls: 12

2

Ref. stxhg

4 3 9

34 22 11 22 2 2

3

4

34 33 12 33 3 3

1

22 34 11 22 2 2

Table 2 -e-m.. Pesfonnance 01 UlPrY wi& m = 3 an4 m = 4

34 14 21 14 44

2

22 34 22 21 5 5

7

I

4

34 13 32 12 7 6

6

32 34 22 32 6 6

34 24 32 23 8 7

5

2

34 22 43 12 10 9

3

34 31 33 31 9 8

23 34 43 12 20 9

4

34 43 22 11 9

6

9,number3 yl

-

INFOWATION

PR0CESSING LETTERS

mink@*, R > t, such that

Using the terminology of d,, PIG, PF, PULL, TPULI, etc. as defined in Section 2 the ODPP algo= rithm could be defined as follows: If bt C MPGthen return PPG=mthenBeginPF=PF+l; = t;TPULL=TPULL+ 1 end &eBe&PPG=PPG+l; tldt-m>PULLthenBeginPULL=PULL+l; TPULL = TPULL + 1 end end

April 1978

last page fault occur&d). It can be seen that this is the same as the PPG in ODPP. Hence for ODPP et,+r = m. From the definition of DPMIN, bfj+l = m. Hence bri+I = b,i,l* This could be true only when (i) either tj+l = tj+.l,or (ii) allthe references betwceenq+i and r;+l refer only to the pages in the set ofm f 1 distinct pages referred from t3 to tl.+l or t-+1 whichever is smaller. This is clearly impossible as the first reference to the m + 1th distinct page (at the instant t3+l or ti+l whichever is early) should have made both the algorithms to incur a page fault, Hence the result.

For a given reference stringand the sizeof the main memory ODPP incursthe samenumber of felts and page pullsas DPMIN.

References

Roof. We will show that both the algorithms incur

u1 L.A. Belady, A study of replacement algorithms for a

Tlbanr&m.

&e page faults at the same instants or references and &-~ce the number of page faults will also be the same fog both and therefore it follows that since the reference string and the memory size are fixed the number of page pulls will be the same. bt ODPP incur page faults at time instants t1, t& r.., tk . . . and DPMIN at t;, t;, . ..$t; ... Wewant to show that ti = t; for all i. We will prove this by induction. It is trivially true that tl = t;. Let WI mume that t/ = t;. We willshow that both incur the next page faults at the same instant, i.e., tj+l = f;*,

l

defme bP as the backward distance (in terms of number of distinct pages) of the reference Q, ?o the reference rt, (the reference at which the Let us

136

virt&

storage computer, IBM Syst. 3.5 (1966) 78-101.

121M. Joseph, An analysis of paging and program behaviour, Comput. 3. 13 (1970) 48-54.

131J.L. Baier and G.R. Sager, Dynamic improvement of locality in virtual memory systems, IEEE Trans. on Software Engineering SE-2 (1976) 54-62. 141R.L. Mattson, J. Gecsei, DR. Stutz and IL. Traiger, Evaluation techniques for storage hierarchies, IBM Syst. J. 9 (1970) 78-117. 151B.G. Prieve, and R.S. Fabry, VMIN-An optimal variablespace page replacement algorithm, Commun. ACM 19, (1976) 295-297. ISI KS. Trivedi, Prepaging and applications to array algorithms, IEEE Trans. on Computers, C-25 (1976) 9 1S921. 171 L.A. Belady and F.P. Palermo, On-line measurement of paging behavior by the multivalued MIN algoritnm, IBM J. Res. & Develop 18 (1974) 2- 19.