From: "Peter A. Friend" <octavian@corp.earthlink.net>
To: "Ben A. Abderrazek" <baa@sowa.is.uec.ac.jp>
Cc: help-gcc@gnu.org
Subject: Re: LRU algorithm
Date: Fri, 31 Dec 1999 22:24:00 -0000 [thread overview]
Message-ID: <Pine.GSO.4.10.9912020900260.25089-100000@ebola.it.earthlink.net> (raw)
Message-ID: <19991231222400.rT-YEfHR2Ia_MJtebVth2JyLb3oy2v9uwf2ILRLaU3I@z> (raw)
In-Reply-To: <3845EB92.3DE5D53E@sowa.is.uec.ac.jp>
Well, that depends on how fancy you want to get. I use LRU for a cache
of log file descriptors in Apache. It is simply a doubly linked list of
structures. The basic operation is:
o If an oldest item is needed (to be re-used, or whatever), take it from
the tail of the list.
o Move the old item you just grabbed to the head of the list.
o If you are re-using at item from somewhere in the middle of the list,
also move it to the head of the list before using it.
The idea is the the items that get "hit" most are going to be at the
head of the list, and the oldest at the tail. This approach may or may
not work for you, as you may not want to do all of the pointer juggling.
As for implementing this in gcc, all that you really have to do is
manipulate the doubly linked list. This structure is discussed at length
in numerous texts, I can suggest some if you like.
BTW, this isn't really a gcc specific question, as this can be done in
any language. Any further discussion should be done privately or on one
of the comp.lang newsgroups.
HTH,
Peter
---
Software Engineer
EarthLink Network
On Thu, 2 Dec 1999, Ben A. Abderrazek wrote:
>
> Hi all,
>
> Is any one has a hint about how to write an LRU algorithm in gcc ?
>
> I have some variables and I want to find the least recently used.
>
>
> Thank you for any help,
>
> Ben,
next prev parent reply other threads:[~1999-12-31 22:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-12-01 19:47 Ben A. Abderrazek
1999-12-02 9:13 ` Peter A. Friend [this message]
1999-12-31 22:24 ` Peter A. Friend
1999-12-31 22:24 ` Ben A. Abderrazek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.GSO.4.10.9912020900260.25089-100000@ebola.it.earthlink.net \
--to=octavian@corp.earthlink.net \
--cc=baa@sowa.is.uec.ac.jp \
--cc=help-gcc@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).