lkml.org 
[lkml]   [2007]   [Apr]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] use spinlock instead of binary mutex in idt77252 driver
Hi,

On 4/23/07, Eddie C. Dost <ecd@atecom.com> wrote:
> as long as mutexes are not converted to nop when CONFIG_SMP is not
> defined (I don't know what current kernels do), this is of course
> correct. You need to verify the headerfiles for the above.

Yes, even on UP different threads accessing the same data could race.
Mutexes (== binary semaphores) are *required* to synchronize access to
shared data.

You might be confusing mutexes with spinlocks. Spinlocks _are_
compiled away on UP (actually !CONFIG_SMP && !CONFIG_PREEMPT) kernels,
but that is still safe because spinlocks are busy-waiting loops
(unlike mutexes and semaphores that block) and hence no thread is
allowed to sleep when holding a spinlock.

> On Mon, Apr 23, 2007 at 09:40:26AM +0200, Matthias Kaehlcke wrote:
> > El Mon, Apr 23, 2007 at 09:16:08AM +0200 Eddie C. Dost ha dit:
> > > Please note that the semaphore is used to lock the idt77252 config
> > > tables among multiple users including atmsigd even on single processor
> > > machines. Does this work with mutexes?
> >
> > afaik mutexes have the same behaviour as binary semaphores that are
> > used as mutexes (always locked and unlocked by the same
> > process/thread):

Mutexes / binary semaphores / spinlocks are used to synchronize access
to shared data by *multiple* threads ... there is no meaning in
locking access to something if we know only one thread will ever touch
it.

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

\
 
 \ /
  Last update: 2007-04-23 10:05    [W:0.037 / U:0.584 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site