atomic read-write operations

atomic read-write operations

Post by cuibi » Sun, 06 Oct 2002 17:30:39



Hi all,
       what's the atomic operations such as test-and set and
compare-and-swap? is there any C function for this or in UNIX?
- -
Best Regards
CuiBin
 
 
 

atomic read-write operations

Post by Nithyanandham » Sun, 06 Oct 2002 21:51:27



> what's the atomic operations such as test-and set and
> compare-and-swap? is there any C function for this or in UNIX?

See the functions listed in <sys/atomic.h>. It contains the routines for
atomic
operations. But, as I understand, they are available only in kernel mode
and not
in user mode.

--

Nithyanand.
Siemens, Bangalore, India.
(Opinions expressed are my own and do not reflect the opinions of my
employer, SIEMENS)

 
 
 

atomic read-write operations

Post by cuibi » Sun, 06 Oct 2002 22:15:22


So can I use it in my C program?

--

- -
Best Regards
CuiBin



> > what's the atomic operations such as test-and set and
> > compare-and-swap? is there any C function for this or in UNIX?

> See the functions listed in <sys/atomic.h>. It contains the routines for
> atomic
> operations. But, as I understand, they are available only in kernel mode
> and not
> in user mode.

> --

> Nithyanand.
> Siemens, Bangalore, India.
> (Opinions expressed are my own and do not reflect the opinions of my
> employer, SIEMENS)

 
 
 

atomic read-write operations

Post by Sony E Anton » Mon, 07 Oct 2002 01:24:47



> Hi all,
>        what's the atomic operations such as test-and set and
> compare-and-swap? is there any C function for this or in UNIX?

The only way to do this portably is to roll your own ones with locks
around them. These mutexes will be global ones sitting in the
implementation .c files. So that they are not exposed ouside the
implementation. I can t think of any other way considering that it could
be a multi processor machine.

--sony

Quote:> - -
> Best Regards
> CuiBin

 
 
 

atomic read-write operations

Post by Joshua Jone » Mon, 07 Oct 2002 05:38:30



> So can I use it in my C program?

If it's a regular user-mode program, no.  See the other suggestion
about rolling your own.

--
 Joshua Jones
 josh(at)homemail.com  |  jonesjos(at)us.ibm.com