Multithreading and atomic operations

I

Ioannis Vranos

I am a bit confused on the subject.

In multithreading, isn't an atomic operation a piece of code that must
be run by only one thread at a time?


Thanks.
 
C

Chris M. Thomasson

Ioannis Vranos said:
I am a bit confused on the subject.

In multithreading, isn't an atomic operation a piece of code that must be
run by only one thread at a time?

It means that a series of operations appear to happen all at once, or none
at all (e.g., conditional atomic ops). An atomic operation which mutates
shared data is usually comprised of a RMW sequence. The RMW part executes
all at once without interruption and the shared memory is updated correctly.
 
R

Ron AF Greve

Hi,

I consider something an atomic operation when it can't be interrupted or
anything by another thread, interrupt handler etc.. i.e. the operation will
guaranteed to be executed as a whole.

For instance on motorola 68xxx processors there is a 'bit test and set'
instruction it enables you to make sure a certain part of code is only
executed by one microprocessor at a time. i.e. it returns if the bit is
already set or if it just has been set (i.e. the last indicating the current
mircoprocessor acquired the lock and the other indicating some other micro
already acquired it (and this thread should either wait or do something
else).

Regards, Ron AF Greve
http://informationsuperhighway.eu
 
I

Ioannis Vranos

Ron said:
Hi,

I consider something an atomic operation when it can't be interrupted or
anything by another thread, interrupt handler etc.. i.e. the operation will
guaranteed to be executed as a whole.

For instance on motorola 68xxx processors there is a 'bit test and set'
instruction it enables you to make sure a certain part of code is only
executed by one microprocessor at a time. i.e. it returns if the bit is
already set or if it just has been set (i.e. the last indicating the current
mircoprocessor acquired the lock and the other indicating some other micro
already acquired it (and this thread should either wait or do something
else).

Regards, Ron AF Greve
http://informationsuperhighway.eu


Isn't it the same with what I said?
 
R

Ron AF Greve

Hi,

Ioannis Vranos said:
Isn't it the same with what I said?

I think so but it depends on what is meant exactly by executing by one
thread at a time. I think the important thing is that the instruction (or
piece of code) will be executed while there is a guarantee that nothing else
in the system will be executed during that, that might change the result of
that (atomic) execution.


Regards, Ron AF Greve

http://informationsuperhighway.eu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top