Rama Krishna wrote:
Hi,
For nonblocking implementation of stacks and queues we actually required the 
use of CAS (Compare and Swap instruction)instruction in the C program.From 
google search and wikipedia 
(http://publib16.boulder.ibm.com/pseries/en_US/libs/ktechrf1/compare_and_swap.htm)
i came to know that it a atomic function and is available in 
#include<sys/atomic_op.h> header. When i used this header file in the C program 
and try to compile it is showing no such header file is there. Actually we want to 
know which libraries to include to use CAS instruction. Can any one who know how to 
use CAS instruction ,please inform us.

Rama


On Solaris Nevada and I believe Solaris 10 update 1,
try man atomic_cas.

SYNOPSIS
     #include <atomic.h>

     uint8_t atomic_cas_8(volatile uint8_t *target, uint8_t  cmp,
     uint8_t newval);

     uchar_t atomic_cas_uchar(volatile uchar_t  *target,  uchar_t
     cmp, uchar_t newval);

     uint16_t atomic_cas_16(volatile uint16_t  *target,  uint16_t
     cmp, uint16_t newval);

     ushort_t   atomic_cas_ushort(volatile   ushort_t    *target,
     ushort_t cmp, ushort_t newval);

     uint32_t atomic_cas_32(volatile uint32_t  *target,  uint32_t
     cmp, uint32_t newval);

     uint_t atomic_cas_uint(volatile uint_t *target, uint_t  cmp,
     uint_t newval);

     ulong_t atomic_cas_ulong(volatile ulong_t  *target,  ulong_t
     cmp, ulong_t newval);

     uint64_t atomic_cas_64(volatile uint64_t  *target,  uint64_t
     cmp, uint64_t newval);

     void *atomic_cas_ptr(volatile void *target, void *cmp,  void
     *newval);

DESCRIPTION
     These functions enable a compare and swap operation to occur
     atomically. The value stored in target is compared with cmp.
     If these values are equal, the value  stored  in  target  is
     replaced  with  newval.  The  old  value stored in target is
     returned by the function  whether  or  not  the  replacement
     occurred.

- Bart


--
Bart Smaalders                  Solaris Kernel Performance
[EMAIL PROTECTED]               http://blogs.sun.com/barts
_______________________________________________
opensolaris-discuss mailing list
[email protected]

Reply via email to