What is atomic_load in C ?

Syntax

C atomic_load( volatile A* obj );

The atomic_load function atomically returns the value that the obj is pointing to. The volatile keyword informs the compiler that the value of this variable may change anytime.

This is an atomic operation that uses sequential consistency - memory_order_seq_cst. The memory order is given as an argument to those functions that carry out atomic operations. It states how operations on various threads are synchronized.

Explanation

A - one of the atomic types.

C - A's corresponding non-atomic type.

Parameters

The function takes in one parameter, as stated below:

obj - the pointer to the atomic object that has to be read.

Return value

The value of atomic variable that the object is currently pointing at.

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved