public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* LRU algorithm
@ 1999-12-01 19:47 Ben A. Abderrazek
  1999-12-02  9:13 ` Peter A. Friend
  1999-12-31 22:24 ` Ben A. Abderrazek
  0 siblings, 2 replies; 4+ messages in thread
From: Ben A. Abderrazek @ 1999-12-01 19:47 UTC (permalink / raw)
  To: help-gcc

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,

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: LRU algorithm
  1999-12-01 19:47 LRU algorithm Ben A. Abderrazek
@ 1999-12-02  9:13 ` Peter A. Friend
  1999-12-31 22:24   ` Peter A. Friend
  1999-12-31 22:24 ` Ben A. Abderrazek
  1 sibling, 1 reply; 4+ messages in thread
From: Peter A. Friend @ 1999-12-02  9:13 UTC (permalink / raw)
  To: Ben A. Abderrazek; +Cc: help-gcc

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,

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: LRU algorithm
  1999-12-02  9:13 ` Peter A. Friend
@ 1999-12-31 22:24   ` Peter A. Friend
  0 siblings, 0 replies; 4+ messages in thread
From: Peter A. Friend @ 1999-12-31 22:24 UTC (permalink / raw)
  To: Ben A. Abderrazek; +Cc: help-gcc

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,

^ permalink raw reply	[flat|nested] 4+ messages in thread

* LRU algorithm
  1999-12-01 19:47 LRU algorithm Ben A. Abderrazek
  1999-12-02  9:13 ` Peter A. Friend
@ 1999-12-31 22:24 ` Ben A. Abderrazek
  1 sibling, 0 replies; 4+ messages in thread
From: Ben A. Abderrazek @ 1999-12-31 22:24 UTC (permalink / raw)
  To: help-gcc

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,

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-12-31 22:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-01 19:47 LRU algorithm Ben A. Abderrazek
1999-12-02  9:13 ` Peter A. Friend
1999-12-31 22:24   ` Peter A. Friend
1999-12-31 22:24 ` Ben A. Abderrazek

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