lkml.org 
[lkml]   [2003]   [Jan]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] Migrating net/sched to new module interface
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/

\
 
 \ /
  Last update: 2005-03-22 13:32    [W:0.153 / U:11.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site