DragonFly submit List (threaded) for 2008-01
DragonFly BSD
DragonFly submit List (threaded) for 2008-01
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: mention msleep() in porting_drivers.txt


From: Aggelos Economopoulos <aoiko@xxxxxxxxxxxxxx>
Date: Sun, 6 Jan 2008 23:32:19 +0200

On Sunday 06 January 2008, Jeffrey Hsu wrote:
> Well, we do have a msleep() function.  It function atomically
> releases a lock before sleeping to ensure that no wakeup is missed.
> It is the same as the msleep() function that's currently in FreeBSD,
> except in FreeBSD it release a mutex lock and in DragonFly it
> releases a spin lock.  For short critical sections that don't block,
> substituting a spinlock and msleep() for a mutex lock and msleep()
> would be the most direct way to convert between FreeBSD and DragonFly.

Unfortunately it was not obvious from the patch context, but the added text
is part of an example of how to convert MTX_DEF FreeBSD mutexes. So I guess
this comment does not apply.

> For more complicated critical sections, it might be better to pursue
> a different MP-safety strategy entirely, such as per-cpu data along with
> crit_enter()/crit_exit().  This has lower overhead and also parallelizes,
> rather than serializes, the work load.

Agreed. The reason I didn't just add an example for MTX_SPIN mutexes is
precisely not to encourage just blindly copying FreeBSD's fine-grained
locking. Explaining alternative strategies and tradeoffs would require
a seperate article of its own though.

Aggelos



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]