Related Tags

c

# What is ATOMIC_CHAR32_T_LOCKFREE in C?

ATOMIC_CHAR32_T_LOCK_FREE is a macro defined in the C11 atomic library. ATOMIC_CHAR32_T_LOCK_FREE is relative to the primitive type char32_t, which is an unsigned integer type for 32-bit wide characters.

The macro takes on the value $0$, $1$, or $2$ depending on whether the type is lock-free:

• $0$ defines that the type is never lock-free
• $1$ defines that the type is sometimes lock-free
• $2$ defines that the type is always lock-free

## Lock-free programming

Lock-free programming is an alternative to the mutex locks and semaphores for concurrent programming. Instead of using locking mechanisms to block threads from accessing data or putting them to sleep (as is the case with mutex), lock-free programming allows atomic operations on the data using a transactional memory model.

## Transactional memory model

The transactional memory model bunches up a series of memory accesses and implements them at once as a transaction, similar to how transactions in databases work.

Lock-free programming is non-blocking, which allows lock-free programs to access shared resources without blocking other threads and introducing race conditions. The non-blocking property of lock-free programming carries many performance advantages over mutex locks because concurrent access to resources is not blocked by other threads accessing the same data.

RELATED TAGS

c

CONTRIBUTOR