-----Original Message-----
From: Thomas Weidenmueller [mailto:w3seek@reactos.com]
Sent: 18 November 2005 12:03
To: ReactOS Development List
Subject: Re: [ros-dev] Re: [ros-diffs] [gedmurphy] 19312:
Improve stopping control of the service
Murphy, Ged (Bolton) wrote:
This function is new to me.
Now that
you're writing multithreaded code it's about time to learn
about these functions ;)
I'm just doing a bit of research on it now to
better
understand it, but
could you just give me a bit of background of the
difference between this,
and using something like a mutex or CS, and why
it's better in this
scenario?
Of course you can use mutexes or critical sections, but for
this purpose
interlocked operations are much more lightweight because with
mutexes or
critical sections you'd have to protect the read operation as
well. The
Interlocked* functions basically guarantee that a certain
operation on a
variable shared by multiple threads is performed in an atomic
matter. I
probably should mention that reads are always atomic, so reading a
variable with the size smaller or equal as the size of a
general purpose
register does not need to be protected, writes however have
to be protected.
You should read the following articles:
http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/dllproc/base/interlocked_variable_access.asp
http://blogs.msdn.com/oldnewthing/archive/2004/09/15/229915.aspx
Thanks for the info, much appreciated.
I've been reading up on Interlocked Variable Access this morning and have
now implemented it into the code.
Ged.
************************************************************************
The information contained in this message or any of its
attachments is confidential and is intended for the exclusive
use of the addressee. The information may also be legally
privileged. The views expressed may not be company policy,
but the personal views of the originator. If you are not the
addressee, any disclosure, reproduction, distribution or other
dissemination or use of this communication is strictly prohibited.
If you have received this message in error, please contact
postmaster(a)exideuk.co.uk
<mailto:postmaster@exideuk.co.uk> and then delete this message.
Exide Technologies is an industrial and transportation battery
producer and recycler with operations in 89 countries.
Further information can be found at