sched_lock && thread_lock()

Bruce Evans brde at optusnet.com.au
Fri May 25 00:27:03 UTC 2007


On Thu, 24 May 2007, Attilio Rao wrote:

> Hello,
> Let me know if this patch is right for you and if you have feedbacks, 
> comments, etc:
> http://users.gufi.org/~rookie/works/patches/schedlock/vmmeter3.diff
>
> This should fix translation errors Bruce has found and switching the _SET() 
> method in order to being a simple assignment (as Bruce has suggested).

OK.

Note that I won't be really happy until the macros and volatiles go
away.  But keep at least the macros for development.  The volatiles
are easier to remove: put them in the access macros instead of putting
them in the declarations and cancelling them in the access macros where
they are most needed.  This would leave them broken in the access
macros where they are most needed, the same as now (since the sysctl
macros just don't support volatile, they must be cancelled now and
cannot be added).  Note that we use this method for almost all "volatile"
variables in the kernel -- we don't declare quite enough things volatile,
but we add volatiles in the atomic function calls and depend on a
combination of atomic accesses and locking to avoid races.  It is easy
to get this wrong, but if we get it wrong then declaring things volatile
only reduces the races.

I forgot to mention another easy-to-fix bug: missing parentheses around
the `val' arg in macro definitions.

Bruce


More information about the freebsd-arch mailing list