9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] fidtab in u9fs
@ 2003-02-17  3:21 Andrew Simmons
  2003-02-17  3:27 ` Russ Cox
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Simmons @ 2003-02-17  3:21 UTC (permalink / raw)
  To: 9fans

I've been looking at the source for u9fs, and am a bit puzzled by the
table of fids and the newfid function. The table is declared as

Fidtab *fidtab[1];

and the business part of newfid is:

f = emalloc(sizeof(*f));
f->next = fidtab[fid%nelem(fidtab)];
if(f->next)
    f->next->prev = f;
fidtab[fid%nelem(fidtab)] = f;
f->fid = fid;

As far as I can see, nelem(fidtab) is 1, so that fidtab is always
indexed by 0, and there is only ever a single element in the table,
whose next and prev elements point at itself. And if so, what's the
point of the loop in lookupfid?

I'm probably being really thick here, but what am I missing?


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

* Re: [9fans] fidtab in u9fs
  2003-02-17  3:21 [9fans] fidtab in u9fs Andrew Simmons
@ 2003-02-17  3:27 ` Russ Cox
  0 siblings, 0 replies; 3+ messages in thread
From: Russ Cox @ 2003-02-17  3:27 UTC (permalink / raw)
  To: 9fans

There can be more than one element in the list --
if you call newfid twice then there will be two fids
in the list.  You should look at removefid too.

It would be a more effective hash table if fidtab
were declared with more than one element.
That was probably debugging that never got taken out.

Russ



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

* Re: [9fans] fidtab in u9fs
@ 2003-02-17  3:40 Andrew Simmons
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Simmons @ 2003-02-17  3:40 UTC (permalink / raw)
  To: 9fans

> It would be a more effective hash table if fidtab
> were declared with more than one element.

Thanks. I was fixating on the declaration so much that I didn't read
the code properly. Mea maxima culpa.


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

end of thread, other threads:[~2003-02-17  3:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-17  3:21 [9fans] fidtab in u9fs Andrew Simmons
2003-02-17  3:27 ` Russ Cox
2003-02-17  3:40 Andrew Simmons

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 NNTP newsgroup(s).