How to write a fast mutex?
I would like to have fast locks as Win32's InterlockedIncrement(). Currently I am using the swap assembler instruction. Is this correct or do I need to add a kind of memory barrier?
I would rather like to use the atomic_add function family but it doesn't seem to be available for user programs.
Does any have a suggestion in order to have fast locks?
[380 byte] By [
sadda] at [2007-11-25 23:41:18]

# 1
for lock, you can use swap, or cas.if you are just doing addition, i would suggest you look at http://lxr.mozilla.org/seamonkey/source/nsprpub/pr/src/md/unix/os_SunOS_ultrasp arc.s
# 2
From what I've read, you can use swap or cas for locking with the Sun Workshop 5.0 compiler. Is there a similar implementation for older compilers, namely, Sun 4.2 compiler?