Click here to Skip to main content
15,918,193 members

Bugs and Suggestions

   

General discussions, site bug reports and suggestions about the site.

For general questions check out the CodeProject FAQs. To report spam and abuse Head to the Spam and abuse watch. If you wish to report a bug privately, especially those related to security, please email webmaster@codeproject.com

 
GeneralRe: Problem in Weekly Vote Pin
Chris Maunder31-Jul-08 13:22
cofounderChris Maunder31-Jul-08 13:22 
GeneralCMPXHG8 Pin
Luc Pattyn28-Jul-08 6:54
sitebuilderLuc Pattyn28-Jul-08 6:54 
GeneralRe: CMPXHG8 Pin
Chris Maunder28-Jul-08 6:57
cofounderChris Maunder28-Jul-08 6:57 
GeneralRe: CMPXHG8 Pin
Luc Pattyn28-Jul-08 7:02
sitebuilderLuc Pattyn28-Jul-08 7:02 
JokeRe: CMPXHG8 Pin
Mladen Janković28-Jul-08 9:49
Mladen Janković28-Jul-08 9:49 
GeneralRe: CMPXHG8 Pin
Luc Pattyn28-Jul-08 10:00
sitebuilderLuc Pattyn28-Jul-08 10:00 
GeneralRe: CMPXHG8 Pin
Paul Conrad28-Jul-08 9:50
professionalPaul Conrad28-Jul-08 9:50 
GeneralRe: CMPXHG8 Pin
supercat928-Jul-08 15:35
supercat928-Jul-08 15:35 
//Me neither. I've seen the instruction years ago, never have actually found a real use for it.//

Not sure if I should continue this thread in the wrong forum, but anyway...

The double-length compare-exchange would be very handy if vb.net would allow it to be used on a structure containing an object reference and a counter. Among other things, it would make it much more practical to use pooled objects while operating on lock-free data structures.

As a simple example (and this is one that .net actually will facilitate) suppose that you have a 64-bit number in memory and you wish to perform bitwise 'and' and 'xor' operations upon it. Even though multiple threads may attempt to perform operations simultaneously, you want to guarantee that the number will not be corrupted. If in one thread you wrote var = var or 1 and in another thread var = var or 2 there would be no guarantee as to what var would end up containing.

CompareExchange allows a solution.
Sub BitMaskLong(ByRef Dest as Long, ByVal AndMask as Long, Byval XorMask as Long)
  Dim OldVal, NewVal as Long

  Do
    OldVal = Dest
    NewVal = (OldVal and AndMask) xor XorMask
  Loop While Threading.Interlocked.CompareExchange(Dest, NewVal, OldVal) <> OldVal
End Sub
The compare-exchange performed in the last statement will write the newly-computed value to the destination variable unless something else has change it since it was first read. If it has been changed, it will be reread and the new value recomputed. Provided that the computation between the read and the compare-exchange is shorter than a timeslice, the compare-exchange is unlikely to fail more than once for each processor in the system (indeed, most of the time it will succeed on the first try).
GeneralRe: CMPXHG8 Pin
Paul Conrad28-Jul-08 18:04
professionalPaul Conrad28-Jul-08 18:04 
GeneralBookmark Question Pin
Thomas Stockwell28-Jul-08 4:32
professionalThomas Stockwell28-Jul-08 4:32 
GeneralRe: Bookmark Question Pin
Chris Maunder28-Jul-08 7:00
cofounderChris Maunder28-Jul-08 7:00 
GeneralRe: Bookmark Question Pin
Thomas Stockwell28-Jul-08 7:07
professionalThomas Stockwell28-Jul-08 7:07 
GeneralRe: Bookmark Question Pin
Chris Maunder28-Jul-08 8:23
cofounderChris Maunder28-Jul-08 8:23 
GeneralRe: Bookmark Question Pin
Thomas Stockwell28-Jul-08 9:11
professionalThomas Stockwell28-Jul-08 9:11 
GeneralRe: Bookmark Question Pin
Paul Conrad28-Jul-08 9:51
professionalPaul Conrad28-Jul-08 9:51 
GeneralSpammer Pin
Shog927-Jul-08 7:23
sitebuilderShog927-Jul-08 7:23 
GeneralRe: Spammer Pin
Leslie Sanford27-Jul-08 7:34
Leslie Sanford27-Jul-08 7:34 
GeneralRe: Spammer Pin
Shog927-Jul-08 7:52
sitebuilderShog927-Jul-08 7:52 
GeneralRe: Spammer Pin
Paul Conrad27-Jul-08 9:18
professionalPaul Conrad27-Jul-08 9:18 
GeneralRe: Spammer Pin
Chris Maunder27-Jul-08 10:25
cofounderChris Maunder27-Jul-08 10:25 
GeneralRe: Spammer Pin
Paul Conrad27-Jul-08 10:45
professionalPaul Conrad27-Jul-08 10:45 
GeneralRe: Spammer Pin
Shog927-Jul-08 13:23
sitebuilderShog927-Jul-08 13:23 
GeneralLimit the number of threads started by a user in an X length of time per forum. Pin
Oakman27-Jul-08 6:02
Oakman27-Jul-08 6:02 
GeneralRe: Limit the number of threads started by a user in an X length of time per forum. Pin
Luc Pattyn27-Jul-08 6:12
sitebuilderLuc Pattyn27-Jul-08 6:12 
GeneralRe: Limit the number of threads started by a user in an X length of time per forum. Pin
Oakman27-Jul-08 6:26
Oakman27-Jul-08 6:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.