Re: [OKS] Module removal

Werner Almesberger
2002-07-09T02:31:21Z

Kevin O'Connor wrote:
> I think the above works, but the locking is a bit hairy. How about the
> following. (Taxonomy 3)

Looks like an efficient and almost correct implementation of this,
yes.

One bug: you should use yield() instead of schedule() (2.5) or do
current->policy |= SCHED_YIELD;
before calling schedule (2.4). Or play it extra-safe and use a
traditional wait queue, even though this has more overhead.

> I get the feeling you already had something like this in mind, but your
> example above was rather complicated. The latter implementation is just
> standard reference counting.

Yup, my example was simply an approximation of the current module
code, with the obvious races fixed.

> With a standard reference counting implementation I don't see any of these
> issues being a problem..

Amazing, isn't it ? :-)

> Did I miss something?

I see two possible reasons why somebody may not want this solution:

- those wishing to squeeze the very last bit of performance out of
this may find holding the spin lock during the call a better
compromise than the reference counting
- in some cases, there could be a lock that's being held by the
caller of foo_deregister and that's also needed by
bar_whatever_op. In this case, you have to drop the lock while
waiting (or re-think the locking design).

- Werner

--
_________________________________________________________________________
/ Werner Almesberger, Buenos Aires, Argentina wa@almesberger.net /
/_http://icapeople.epfl.ch/almesber/_____________________________________/