tech-kern archive

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

Re: 4.x -> 5.x locking?

> You can still have non MP-SAFE drivers in netbsd-5 these days.  If
> you do not set D_MPSAFE flag they will be giant-locked[1], [2], [3].

Some of the code is not a device driver, in the sense that it is
entered other than via {b,c}devsw[] entries or interrupts.

> [...mutex...condvar...]
> b) In cv_wait mtx is used this mutex is released before thread went
>    to sleep and acquired before it's woken up,


>    which means that you can safely do required work in side mtx
>    guarded producer area.

Not quote.  On modern MP systems, mutual exclusion such as you outline
(which affects flow-of-control only) is not enough; you also need
memory barriers.  Joerg Sonnenberger just said that mutex_enter() and
mutex_exit() include the appropriate reordering barriers.  I don't yet
know whether they include global visibility barriers (data cache pushes
on "this" CPU and invalidates or snoops on others) or not - you may
have seen my note to the list asking - but those are needed too; if
they are part of the mutex routines, then your skeleton code is
correct, though your explanation omits part of the reason why.

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML      
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

Home | Main Index | Thread Index | Old Index