Re: volatile and caches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Okay I stand corrected the Linux implementation of the locks do give you
the current value and not cached, I checked the code for x86.

On Wed, 28 Aug 2002, Jan Hudec wrote:

> On Wed, Aug 28, 2002 at 02:54:47PM -0600, Tom Bradley wrote:
> > > Well, every variable that may change without code being in place must in
> > > first place be locked or operated using atomic operations. And these
> >
> > NO!
> >
> > Locks are used to keep two pieces of code from accessing a variable at the
> > same time, nothing to do with cached values. I.e. the Reader/Writer
> > problem.  Atomic operations state that this operation is gaurenteed to
> > complete without interuption, atomic variables are volatile, and are
> > used to perform locks. Locks around a variable DO NOT gaurentee you are
> > getting the latest value, you can still be getting a cached value.
>
> Locks, at least in kernel DO guarantee you are geting the latest value
> because they are defined to be optimization barriers.
>
> Locks or atomic operations are only way to ensure you don't get garbage.
> Consider loading sparc register with constant, when you only have 16
> bits for an operand in each instruction.
>
> -------------------------------------------------------------------------------
> 						 Jan 'Bulb' Hudec <bulb@ucw.cz>
>

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux