lkml.org 
[lkml]   [1999]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: mutexs for synchronization between kernel threads?
> Well, under 2.2.6 spin_lock and spin_unlock in the non SMP case are
> NOOPS (do { } while(0)). This is not what I want.

no, this _is_ what you want. remember that on UP, a kernel thread cannot
thread can be pre-empted unless it voluntarily blocks. this itself
guarantees mutual exclusion for your threads A and B. that's why spinlocks
are no-ops in UP.
what this means is that A and B do not run in "parallel". however,
interrupts may occur "in parallel" or asynchronous with A and B, so you
need to protect against them.
that's why you use spinlock_irqsave and spinlock_irqrestore to protect your
structures in A and B rather than plain spinlocks. they work out to
save_flags(flags);cli() and restore_flags(flags) in UP which is exactly
what you want.

ganesh

-
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/

\
 
 \ /
  Last update: 2005-03-22 13:51    [W:0.044 / U:0.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site