Atomic Operations

Hello

I am a newbie in linux.
Please tell me what are atomic operations in Linux.
IS i++ a atomic oparation??
Please help..

An atomic operation is an operation that can only be done once at a certain "tick" time, eventhough another same operation is simultaneously performed by another thread on another CPU core.

For example

mkdir /home/flag

is an atomic operation (without the -p option)
so that even if you submit it many time

mkdir /home/flag &
mkdir /home/flag &
mkdir /home/flag &
mkdir /home/flag &
mkdir /home/flag &
mkdir /home/flag &
mkdir /home/flag &
mkdir /home/flag &

and even if they are handled in parallel at the "sametime" on your CPU core, only one will be successfull

You can for sur find some better explaination over the net but that was an attempt :slight_smile:

Hi

Thanks for your prompt reply.
Is i++ a atomic operation. please give me link where i can study in detail.

Thanks in advance!!

This discusses atomic_t and operations that are atomic.

i++ 

is atomic, possibly depending on the datatype of i.

Atomic Operations