How to do proper locking
Ian Dowse
iedowse at iedowse.com
Sat Aug 6 16:02:20 GMT 2005
In message <200508060139.57143.hselasky at c2i.net>, Hans Petter Selasky writes:
>Yes, you are right, but the problem is, that for most callback systems in the
>kernel, there is no mechanism that will pre-lock some custom mutex before
>calling the callback.
>
>I am not speaking about adding lines to existing code, but to add one extra
>parameter to the setup functions, where the mutex that should be locked
>before calling the callback(s) can be specified. If it is NULL, Giant will be
>used.
>
>The setup functions I have in mind are for example: "make_dev()",
>"bus_setup_intr()", "callout_reset()" ... and in general all callback systems
>that look like these.
Note that FreeBSD's callout subsystem does already have such a
mechanism. Just use callout_init_mtx() and the specified mutex will
be acquired before the callback is invoked. See callout(9) for more
details.
Ian
More information about the freebsd-hackers
mailing list