Re: [RFC] Migrating net/sched to new module interface

Werner Almesberger (wa@almesberger.net)
Thu, 16 Jan 2003 15:58:15 -0300


Roman Zippel wrote:
> > - prepare_deregister (like "deregister", but reversible)
> > - commit_deregister
> > - undo_deregister
>
> You can simplify this. All you need are the following simple functions:
>
> - void register();
> - void unregister();
> - int is_registered();
> - void inc_usecount();
> - void dec_usecount();
> - int get_usecount();

I'm not sure if you, you're not changing the semantics. What I was
describing was a non-blocking interface, e.g.

if (!prepare_deregister(foo))
return -E...;
if (!prepare_deregister(bar)) {
undo_deregister(foo);
return -E...;
}
commit_deregister(foo);
commit_deregister(bar);
return 0;

With your interface, you're not guaranteed that you can re-register.
Well, you could externalize this, e.g. with

int error = 0;

inc_usecount(foo);
inc_usecount(bar);
unregister(foo); /* does nothing irrevokable since use count > 0 */
unregister(bar);
if (get_usecount(foo) > 1 || get_usecount(bar) > 1) {
register(foo); /* re-registers foo */
register(bar); /* re-registers bar */
error = E...;
}
dec_usecount(foo);
dec_usecount(bar);
return error;

Is that what you had in mind ?

- Werner

-- 
  _________________________________________________________________________
 / Werner Almesberger, Buenos Aires, Argentina         wa@almesberger.net /
/_http://www.almesberger.net/____________________________________________/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/