lkml.org 
[lkml]   [2008]   [Jan]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Query on lock protection in random number driver
From
Date
On Fri, 2008-01-11 at 12:12 +0100, Andi Kleen wrote:
> Nikanth Karthikesan <knikanth@suse.de> writes:
> >
> > Also the globals random_read_wakeup_thresh and
> > random_write_wakeup_thresh are not at all protected by any locks! Why
> > locks are not needed for these?
>
> Reading variables sizeof <= native word size (32bit or 64bit depending
> on architecture) is atomic by itself. This is not necessarily
> guaranteed in ISO-C or POSIX threads, but Linux can assume that.

Yes, I found that by checking the implementation of atomic_read.

But I didnt check the implementation of atomic_set before sending the
mail and assumed assigning to a variable may not be atomic on all arch,
and because of that, we may be reading a half-written, variable! But
assigning to an int is also atomic on all arch.

Thanks a lot.

Thanks
Nikanth Karthikesan



\
 
 \ /
  Last update: 2008-01-11 12:27    [W:0.057 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site