Messages in this thread | | | Date | Mon, 23 Apr 2007 13:32:06 +0530 | From | "Satyam Sharma" <> | Subject | Re: [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/
| |