GCC Atomic Builtins instead of pthread?

c, gcc, lock-free, multithreading, parallel-processing

Solution

Is this a good idea?

Not if you ever intend to compile the code with something other than gcc. Is pthreads causing you any specific problems?

Problem

I've found following article: Use GCC-provided atomic lock operations to replace pthread_mutex_lock functions It refers to GCC Atomic Builtins. What the article suggest, is to use GCC atomic builtins instead of pthread synchronization tools. Is this a good idea? PS. The mysql post is obviously misleading. Atomic Builtins can't replace all pthread tools. For example, the locking requires, that if a lock can't be acquired, a thread has to wait. In other words, it asks the OS to wait, so that the wait is passive. Simple GCC builtin can't do that.

Original source