Re: spinlocks

From: Jeff Garzik (jgarzik@mandrakesoft.com)
Date: Tue Feb 08 2000 - 07:51:39 EST


"Ashutosh S. Rajekar" wrote:
>
> Hello,
>
> Are there any pitfalls in using critical code locked through spinlocks,
> inside a pair of lock_kernel()/unlock_kernel() calls on an SPM machine ?
> I'm not familiar with SMP machines, hence the question.
>
> Say we have the following code: is it safe, or should I use the classical
> save_flags(), cli(), restore_flags() stuff ?

Read linux/Documentation/spinlocks.txt.

Basically, critical sections should usually be
spin_[un]lock_irq{save,restore}. This even evaluates down to
save_flags/cli/restore_flags on UP.

If your critical section need not be guarded against interrupts, you can
use the simpler and faster spin_[un]lock variants.

there are also reader/writer spinlocks, if your device accesses follow
that pattern.

        jeff

-- 
Jeff Garzik         | Only so many songs can be sung
Building 1024       | with two lips, two lungs, and
MandrakeSoft, Inc.  | one tongue.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Feb 15 2000 - 21:00:12 EST