tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: MP locking?
On Wed, Jun 30, 2010 at 05:15:53PM -0400, der Mouse wrote:
> I have some kernel code which was written for a pre-MP kernel; it uses
> spl*() for locking.
> I'd like to roll this forward to something at
> least slightly more modern - specifically, a dual-CPU 4.0.1 machine.
>
> lock(9) outlines locking facilities which I believe I can use to do
> what I want - but there are other issues, such as cache coherency; do I
> need to do anything special with shared data structures to ensure
> coherency between processors? Is it enough to declare them volatile,
> or do I need memory barriers as well, or what?
You need memory barriers, modern CPUs can do speculative reads, and some
can reorder writes. AFAIK, lock operations act as memory barriers.
atomic ops do not.
--
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
NetBSD: 26 ans d'experience feront toujours la difference
--
Home |
Main Index |
Thread Index |
Old Index