Web Images Videos Maps News Groups Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Atomic operations
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Armin Zingler  
View profile  
 More options Oct 30, 3:20 am
Newsgroups: microsoft.public.dotnet.framework
From: Armin Zingler <az.nos...@freenet.de>
Date: Thu, 29 Oct 2009 17:20:33 +0100
Local: Fri, Oct 30 2009 3:20 am
Subject: Atomic operations
Hi,

is there a documentation out there that tells me which operations are atomic?

I currently have to know if increasing a System.Decimal value is an atomic operation. I guess it is
not. The value is increased in one thread and read from another thread. I think I have to use a
lock. Right?

--
Armin


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Duniho  
View profile  
 More options Oct 30, 4:37 am
Newsgroups: microsoft.public.dotnet.framework
From: Peter Duniho <no.peted.s...@no.nwlink.spam.com>
Date: Thu, 29 Oct 2009 10:37:58 -0700
Local: Fri, Oct 30 2009 4:37 am
Subject: Re: Atomic operations

Armin Zingler wrote:
> Hi,

> is there a documentation out there that tells me which operations are atomic?

Depends on what you mean.  The C# specification, for example, is clear
about what operations within the language are atomic (certain
assignments and reads, specifically).

But of course it doesn't mention any of the System.Threading.Interlocked
class, for example, which also provides for certain atomic operations.
In that sense, no...there's not a single place that all atomic
operations are documented.

> I currently have to know if increasing a System.Decimal value is an atomic operation.

An increment of any value is not guaranteed to be atomic unless you use
the Interlocked class, and the System.Decimal type is too wide to be
supported by the Interlocked class in any case.

> I guess it is not. The value is increased in one thread and read from another thread. I think I have to use a
> lock. Right?

You have to use some kind of synchronization, yes.  And because it's so
wide, the System.Decimal type isn't even among those in C# that even has
atomic assignment.

There are a wide variety of possibilities, but a "lock" statement is
definitely the way to go, until you have some reason to believe you need
something cleverer and more efficient.

Pete


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Armin Zingler  
View profile  
 More options Oct 30, 7:46 am
Newsgroups: microsoft.public.dotnet.framework
From: Armin Zingler <az.nos...@freenet.de>
Date: Thu, 29 Oct 2009 21:46:57 +0100
Local: Fri, Oct 30 2009 7:46 am
Subject: Re: Atomic operations
Peter Duniho schrieb:

> Armin Zingler wrote:
>> Hi,

>> is there a documentation out there that tells me which operations are atomic?

> Depends on what you mean.

Atomic operations are operations on objects that are performed completely without
the possibility that another thread reads the object or a part of it in the meantime.

> The C# specification, for example, is clear about what operations within the language
> are atomic (certain assignments and reads, specifically).

I'm using VB (2008). I didn't know it's a language specific issue, therefore I posted here.
Didn't find something specific to VB.

Anyway, I've put reading/writing the value inside a Synclock-EndSynclock statement.

--
Armin


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Duniho  
View profile  
 More options Oct 30, 10:11 am
Newsgroups: microsoft.public.dotnet.framework
From: Peter Duniho <no.peted.s...@no.nwlink.spam.com>
Date: Thu, 29 Oct 2009 16:11:37 -0700
Local: Fri, Oct 30 2009 10:11 am
Subject: Re: Atomic operations

Armin Zingler wrote:
> Peter Duniho schrieb:
>> Armin Zingler wrote:
>>> Hi,

>>> is there a documentation out there that tells me which operations are atomic?
>> Depends on what you mean.

> Atomic operations are operations on objects that are performed completely without
> the possibility that another thread reads the object or a part of it in the meantime.

I know what "atomic operation" means.  I was referring to your question
about "is there a documentation out there", and the answer depends on
what you mean by _that_.  Atomic operations certainly are documented, so
the answer to your question is trivially "yes".  But it might not really
be the question you meant to ask, thus my "it depends".

>> The C# specification, for example, is clear about what operations within the language
>> are atomic (certain assignments and reads, specifically).

> I'm using VB (2008). I didn't know it's a language specific issue, therefore I posted here.
> Didn't find something specific to VB.

I'm less familiar with VB.NET, but I would hope it would have some
similar atomic guarantees for smaller data types (e.g. System.Int32,
System.Boolean, etc.).  Still, I doubt any of those would apply to
System.Decimal.

> Anyway, I've put reading/writing the value inside a Synclock-EndSynclock statement.

Should be fine.  :)

Pete


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google