> In general it's true that when a variable is protected by a lock, it's not > necessary to acquire the lock before performing a simple read (or test). > There's no advantage to > > spin_lock(&lock); > x = protected_var; > spin_unlock(&lock); > > over > > x = protected_var; > > so long as the read operation is atomic (x won't get some mixed-up > combination of values if protected_var is written at the same time as the > read occurs). The same sequence of events would happen during execution > of either code block.
Be careful with memory ordering. You may need to use memory barriers like rmb/wmb and even smp_read_barrier_depends. Also, 64 bit variable access is not atomic on 32 bit arch. ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click _______________________________________________ [EMAIL PROTECTED] To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel