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:)

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
commented: I don't know how you keep doing it, but your replies are always excellent :) +17
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.