By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,949 Members | 904 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

what is the purpose of atomic_t?

100+
P: 1,059
Can anyone explain

what is the purpose of atomic_t

in types.h(linux) I found the definition like this
Expand|Select|Wrap|Line Numbers
  1. typedef struct 
  2.   int counter;
  3. } atomic_t;
  4.  
But I cant understand the purpose of this definition.

Best Regards,
johny
Sep 5 '10 #1

✓ answered by newb16

The purpose of atomic_t is to implement a type and a set of functions that can operate on it correctly from different threads without requiring synchronization like mutexes. It is implemented in its own way on a specific platform so that it's guaranteed by implementation.

Share this Question
Share on Google+
3 Replies


weaknessforcats
Expert Mod 5K+
P: 9,197
Someone has defined a struct with an int member as atomic_t.

You can now use atomic_t as a type.

types.h is a non-ANSI header so I don't know the reason for this.
Sep 5 '10 #2

100+
P: 687
The purpose of atomic_t is to implement a type and a set of functions that can operate on it correctly from different threads without requiring synchronization like mutexes. It is implemented in its own way on a specific platform so that it's guaranteed by implementation.
Sep 6 '10 #3

weaknessforcats
Expert Mod 5K+
P: 9,197
Thank you for the clarification. I hadn't see atomic_t before not being a Linux guru.
Sep 6 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.