Atomic Operations


 
Thread Tools Search this Thread
Operating Systems Linux Atomic Operations
# 1  
Old 10-29-2012
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..
# 2  
Old 10-29-2012
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
Code:
mkdir /home/flag

is an atomic operation (without the -p option)
so that even if you submit it many time
Code:
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 Smilie
# 3  
Old 10-29-2012
Hi

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

Thanks in advance!!
# 4  
Old 10-29-2012
This discusses atomic_t and operations that are atomic.
Code:
i++

is atomic, possibly depending on the datatype of i.

Atomic Operations
Login or Register to Ask a Question

Previous Thread | Next Thread

4 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

system calls and atomic operation

Are system calls atomic operations? Is a system call can be interrupted? (2 Replies)
Discussion started by: vistastar
2 Replies

2. Programming

Atomic Read and Write with stdio

hi guys. can we use fread and fwrite with pipes to write data more than PIPE_BUF atomically since they lock FILE object until I/O operation finish? (1 Reply)
Discussion started by: majid.merkava
1 Replies

3. Programming

Atomic lock file creation

Hello, I need to implement a locking system in C. My problem is how to make the check if the lock file exist and locking it atomic operation. I want to make something like this: FILE* lock_fname; lock_fname = fopen ( "file.lock", "r"); /*check if file exsists*/ if (lock_fname) { fclose... (7 Replies)
Discussion started by: tsurko
7 Replies

4. UNIX for Dummies Questions & Answers

Is `mv dir dir2` atomic ?

if I rename a dir mv dir dir2 Is this operation atomic? Suppose there 100 files in dir, does linux rename them one by one or at once? In other words, is there a time at which both dir and dir2 exist, with dir has, say 30 files and dir2 has the rest 70 files? (4 Replies)
Discussion started by: meili100
4 Replies
Login or Register to Ask a Question