Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Synchronization and volatile

Synchronization and volatile

Scheduled Pinned Locked Moved C / C++ / MFC
c++comdiscussion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    George_George
    wrote on last edited by
    #1

    Hello everyone, Through myself study and previous discussion here, I share the conclusion here that, if some object is synchronized (mutex, critical section, etc.), there is no need to add volatile keyword. Here is the reference, (refer to section volatile, Critical Sections, and Race Conditions) http://www.ddj.com/cpp/184403766 if my understanding is wrong or you have any other options, please feel free to add here. thanks in advance, George

    CPalliniC 1 Reply Last reply
    0
    • G George_George

      Hello everyone, Through myself study and previous discussion here, I share the conclusion here that, if some object is synchronized (mutex, critical section, etc.), there is no need to add volatile keyword. Here is the reference, (refer to section volatile, Critical Sections, and Race Conditions) http://www.ddj.com/cpp/184403766 if my understanding is wrong or you have any other options, please feel free to add here. thanks in advance, George

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      Hey George, let me understand what's your issue against the volatile keyword: Did your lineage be victim of a strange anathema? :laugh: By the way, you missed to mention (if I remember well was David Crow to point it out) that main usage of volatile is not synchronization. :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      [my articles]

      In testa che avete, signor di Ceprano?

      G 1 Reply Last reply
      0
      • CPalliniC CPallini

        Hey George, let me understand what's your issue against the volatile keyword: Did your lineage be victim of a strange anathema? :laugh: By the way, you missed to mention (if I remember well was David Crow to point it out) that main usage of volatile is not synchronization. :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        [my articles]

        G Offline
        G Offline
        George_George
        wrote on last edited by
        #3

        Hi CPallini, 1. I have no real issue of volatile in my work, my personal interest to learn it in depth. 2. I understand volatile has nothing directly with synchronization (compared with mutex, critical section, etc.), but it has relationship with sychronization, as mention in the article. If you read it, I think you should have some comments (whether my understanding is correct and whether you are agree with this article's points). regards, George

        F 1 Reply Last reply
        0
        • G George_George

          Hi CPallini, 1. I have no real issue of volatile in my work, my personal interest to learn it in depth. 2. I understand volatile has nothing directly with synchronization (compared with mutex, critical section, etc.), but it has relationship with sychronization, as mention in the article. If you read it, I think you should have some comments (whether my understanding is correct and whether you are agree with this article's points). regards, George

          F Offline
          F Offline
          Florin Crisan
          wrote on last edited by
          #4

          I'm not sure if you got the point, so I'm going to ramble on: The whole idea of volatile is to tell the compiler not to cache the value. On every access, the value should be checked to see if it has been modified by another thread. The old value should not be presumed correct just because the current thread hasn't modified it. Synchronization, on the other hand, is supposed to ensure that no thread is modifying a value while another thread is using it. You wouldn't want the state of an object to change while you are reading it. Hope this helps.

          Florin Crisan

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups