Wednesday, 15 May 2013

c - Functions for performing atomic operations -



c - Functions for performing atomic operations -

are there functions performing atomic operations (like increment / decrement of integer) etc supported c run time library or other utility libraries?

if yes, operations can made atomic using such functions?

will more beneficial utilize such functions normal synchronization primitives mutex etc?

os : windows, linux, solaris & vxworks

the c library doesn't have any.

on linux, gcc provides -- __sync_fetch_and_add, __sync_fetch_and_sub, , on.

in case of windows, interlockedincrement, interlockeddecrement, interlockedexchange, , on. if utilize gcc on windows, i'd guess has same built-ins on linux (though haven't verified that).

on solaris, it'll depend. presumably if utilize gcc, it'll (again) have same built-ins under linux. otherwise, there libraries floating around, nil standardized.

c atomicity

No comments:

Post a Comment