Is variable++ 1 atomic action?

Please support our Computer Science advertiser: Learn about neural networks and artificial intelligence.
Reply

Join Date: May 2005
Posts: 2
Reputation: bigbrother2000 is an unknown quantity at this point 
Solved Threads: 0
bigbrother2000 bigbrother2000 is offline Offline
Newbie Poster

Is variable++ 1 atomic action?

 
0
  #1
May 26th, 2005
Hi everyone, just wondering if anyone knows if any variable++ would be classed as 1 atomic action? Thanks guys
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: Dogtree is an unknown quantity at this point 
Solved Threads: 3
Dogtree's Avatar
Dogtree Dogtree is offline Offline
Posting Whiz in Training

Re: Is variable++ 1 atomic action?

 
0
  #2
May 27th, 2005
In general, no.
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 2
Reputation: bigbrother2000 is an unknown quantity at this point 
Solved Threads: 0
bigbrother2000 bigbrother2000 is offline Offline
Newbie Poster

Re: Is variable++ 1 atomic action?

 
0
  #3
May 27th, 2005
Thanks Dogtree for replying, I had this question in an exam, true or false, I don't know anything about it though, would you be able to explain why it is false, that would be great
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 232
Reputation: Dogtree is an unknown quantity at this point 
Solved Threads: 3
Dogtree's Avatar
Dogtree Dogtree is offline Offline
Posting Whiz in Training

Re: Is variable++ 1 atomic action?

 
0
  #4
May 27th, 2005
By its definition, the postfix increment operator has to use temporary storage so that it can return the pre-incremented value. You can think of it like this:
operator++
  temp = self;
  self = self + 1;
  return temp;
Optimizations can make it close to atomic for all cases of built-in types, or atomic for some cases of some built-in types, but in the general case, it's not gonna happen.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC