Implementation of lru, Operating System

Assignment Help:

1. On every access, mark the page with a timestamp. Whenever we need to evict a page, we search through memory for the oldest page, the least-recently used page. But we need memory accesses to be fast. With this approach, on every memory access we would also need to read(load) a clock (or counter) and perform a store.

2. Maintain a queue of pages. Every time we touch a page, wemove that page to the beginning of the queue. When we need to evict a page, we evict the last element of the queue. Again, the pointer manipulation to do this would slow down the memory accesses, which we need to be fast on average.

3. Use a hash table rather than a queue. In this case, we have to compute a hash address on every memory access. Bad idea.

4. Approximate LRU.We can do this by maintaining reference bits for every page. On each memory access, the MMU hardware sets the page's reference bit to 1. Periodically, the OS tells the MMU to reset all the reference bits. Whenever we need to evict a page, we select one that has a reference bit not set. (So eviction may require an O(n) search through page tables to ?nd a page with reference bit not set, but the common case, cache hits, are very fast, done in hardware.) This algorithm considers any page which is zeroed to be "old enough". Then, although we can't know exactly what is the least-recently used, we do know that whatever is marked is a least more recent than something not marked. In practice, this approach works pretty well.

LRU is already only an approximation to OPT. In practice, we also approximate LRU itself. Our LRU approximation optimizes for the common case, which is cache hits, rather than cache misses. (If the common case is not cache hits, then your cache is not helping you.)


Related Discussions:- Implementation of lru

Design issues of network operating system, expalin about the design issues ...

expalin about the design issues of network operating system

Explain about diffrent process state, Q. Explain about diffrent Process Sta...

Q. Explain about diffrent Process State? Process State When process executes, it changes its state. Process state is defined as the current activity of the process. Fi

Digital circuits and design , 1. Draw a schematic diagram of a CMOS inverte...

1. Draw a schematic diagram of a CMOS inverter and explain its operation. 2. Draw schematic diagrams of CMOS NAND and NOR gates, and explain their operation. 3. Explain what

Demand paging, Demand paging gives that pages could only be brought into ...

Demand paging gives that pages could only be brought into memory if the running process acts them. This is usually referred to as lazy evaluation as only those pages operated by

Introduction to microprocessors, Let us consider the pining details of the ...

Let us consider the pining details of the 68HC11 as shown below.     Each pin has a defined function, some easy, some complex. A microprocessor designer should understan

Hashed page table, Hashed page tables A common approach for handling ad...

Hashed page tables A common approach for handling address spaces larger than 32 bits is to use a hashed page table. Every entry in the hash table having a linked list of elemen

Cpu scheduling algorithm, Q. A CPU scheduling algorithm determined an orde...

Q. A CPU scheduling algorithm determined an order for the execution of its scheduled processes. Convinced n processes to be scheduled on one processor how numerous possible differ

Explain file, What is a file? A named collection of related data explai...

What is a file? A named collection of related data explained by the creator, recorded on secondary storage.

List disadvantages of using a single directory, List disadvantages of using...

List disadvantages of using a single directory. Users have no privacy. Users must be careful in choosing file names, to avoid names used by others. Users may destroy each othe

Determine the requiring variables on the scope of a thread, Determine the R...

Determine the Requiring Variables on the Scope of a Thread It is very common in server application programs to require variables on the scope of a thread. To provide such a sco

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd