CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2004
    Posts
    561

    How come there isn't a thread safe way to read an int?

    I was investigating using the ::InterlockedXXX family of functions but how come there isn't a thread safe way to read an int? What should be done if I want to read an int safely? Thank you

  2. #2
    Join Date
    Jul 2008
    Location
    Be'er Sheva, Israel
    Posts
    69

    Re: How come there isn't a thread safe way to read an int?

    If you want to do anything safe with integers you should use mutexes or condition variables or monitors or any other means of synchronization.
    The only method provided by the processor for synchronizing data is TSL, which can be used to implement the above methods (just think of the complication in implementing what you're requesting in hardware...)
    Hope this helps,
    Ishay Peled.
    --How often do you look at a man's shoes?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured