0

Hi all,
I'm just a newbie and I need your help, I should write a code about NRU and frankly speaking, I don't know what to do:$ . do you have some related codes, so I can undrestand where to begin and how to do it?
any suggestions would be appriciated,
thanks:)

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Tom Gunn
1

NRU is a caching algorithm based on time. Cache some data and when the data is used set a flag bit. At regular intervals, check the flag bits and deallocate the memory for any of the data where the bit is not set. NRU means not recently used inside the time interval.

The code can be as simple as this:

const THRESHOLD = [I]{some seconds}[/I]

let start = time()

while true do
    // do stuff
    // load data into cache if not there
    // set flag bit when cache data is used

    if diff(time(), start) >= THRESHOLD then
        for x = 0 to sz
            if isset(cache[x].flag) then
                release(cache[x])
                remove(cache[x])
            end if
        loop
    end if
loop
Votes + Comments
I don't know how you keep doing it, but your replies are always excellent :)
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.