Re: atomic access

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

 



On Sun, 2003-02-16 at 16:07, Frank A. Uepping wrote:

> can I assume that the access (read/write) to an int is atomic
> on all supported platforms?
> Does the kernel define some type like the C sig_atomic_t
> for kernel space?

Well, yes - on all architectures Linux supports, word-size stores and
loads are atomic.  There is code in the kernel today that makes use of
this assumption, so it is a safe one.

For example, you can always store a pointer value and rest assured the
store will not interleave with another.  Likewise, a concurrent read
will always see the previous value or the new value, but never a mix.

Nonetheless, if you need to do anything more complicated, I suggest
using the atomic operators.  See include/asm/atomic.c

There is atomic read and write, atomic add-and-store, sub-and-store,
swap, etc.

	Robert Love

--
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