# Difference between revisions of "Atomic Variable Operations"

Jump to navigation
Jump to search

(formatting.) |
(Clarification) |
||

Line 31: | Line 31: | ||

{{funcdef|''n''int atomicCompSwap(inout ''n''int {{param|mem}}, ''n''int {{param|compare}}, ''n''int {{param|data}})}} | {{funcdef|''n''int atomicCompSwap(inout ''n''int {{param|mem}}, ''n''int {{param|compare}}, ''n''int {{param|data}})}} | ||

− | If the current value of {{param|mem}} is equal to {{param|compare}}, then {{param|mem}} is set to {{param|data}}. | + | If the current value of {{param|mem}} is equal to {{param|compare}}, then {{param|mem}} is set to {{param|data}}. Otherwise it is left unchanged. |

## Latest revision as of 04:24, 24 January 2013

All of the atomic functions return the * original* value. The term "

*n*int" can be int or uint.

*n*int atomicAdd(inout

*n*int mem,

*n*int data)

Adds data to mem.

*n*int atomicMin(inout

*n*int mem,

*n*int data)

The mem's value is no lower than data.

*n*int atomicMax(inout

*n*int mem,

*n*int data)

The mem's value is no greater than data.

*n*int atomicAnd (inout

*n*int mem,

*n*int data)

mem becomes the bitwise-and between mem and data.

*n*int atomicOr(inout

*n*int mem,

*n*int data)

mem becomes the bitwise-or between mem and data.

*n*int atomicXor(inout

*n*int mem,

*n*int data)

mem becomes the bitwise-xor between mem and data.

*n*int atomicExchange(inout

*n*int mem,

*n*int data)

Sets mem's value to data.

*n*int atomicCompSwap(inout

*n*int mem,

*n*int compare,

*n*int data)

If the current value of mem is equal to compare, then mem is set to data. Otherwise it is left unchanged.