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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. __sync_synchronize stops processor ?

__sync_synchronize stops processor ?

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++performance
5 Posts 2 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.
  • V Offline
    V Offline
    Vaclav_
    wrote on last edited by
    #1

    I am "porting" C code into C++, mainly to gain an experience. Run into this , undocumented , piece of code. Did some reading and have basic understanding WHAT is suppose to do. Preventing multiprocessors to clobber each other or multiple access to shared devices / memory. So far my software is for single CPU and no sharing of I/O , not yet. That is NOT my concern. What I would like to know why it stops running the process PAST the first usage of __sync_synchronize(); It compiles just fine.

    	\_\_sync\_synchronize();
                 STOPS HERE 
    	ret = \*paddr;
    	\_\_sync\_synchronize();
    

    Thanks Cheers Vaclav

    L 1 Reply Last reply
    0
    • V Vaclav_

      I am "porting" C code into C++, mainly to gain an experience. Run into this , undocumented , piece of code. Did some reading and have basic understanding WHAT is suppose to do. Preventing multiprocessors to clobber each other or multiple access to shared devices / memory. So far my software is for single CPU and no sharing of I/O , not yet. That is NOT my concern. What I would like to know why it stops running the process PAST the first usage of __sync_synchronize(); It compiles just fine.

      	\_\_sync\_synchronize();
                   STOPS HERE 
      	ret = \*paddr;
      	\_\_sync\_synchronize();
      

      Thanks Cheers Vaclav

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Hi, You obviously have a race condition somewhere in your code. As you have probably discovered... that intrinsic function is a memory barrier. There's no way to fix this without learning how to debug your code. If you are developing on the Windows platform then fire up WinDbg and attach it to the process and type '!locks' Debugging a Deadlock[^] Best Wishes, -David Delaune

      V 1 Reply Last reply
      0
      • L Lost User

        Hi, You obviously have a race condition somewhere in your code. As you have probably discovered... that intrinsic function is a memory barrier. There's no way to fix this without learning how to debug your code. If you are developing on the Windows platform then fire up WinDbg and attach it to the process and type '!locks' Debugging a Deadlock[^] Best Wishes, -David Delaune

        V Offline
        V Offline
        Vaclav_
        wrote on last edited by
        #3

        David, thanks for reply. Upon further invetsigation I believe "my problem" is elsewhere in code since it stops on the line between the calls to the __sync_synchronize. Vaclav

        L 1 Reply Last reply
        0
        • V Vaclav_

          David, thanks for reply. Upon further invetsigation I believe "my problem" is elsewhere in code since it stops on the line between the calls to the __sync_synchronize. Vaclav

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Well, Yes; deadlocks, race conditions by the very definition means "somewhere else" is holding a lock. You are looking at the code not me. But I wouldn't recommend using the "Current Line" in the source-view as my error indicator. You need to be looking at the callstack and instructions. My recommendations remain: Attach a debugger to the process. If you want an automated analysis of the deadlock you can attach WinDbg and do: analyze -v -hang Are you developing on Windows? My mind reading skills are not working today. Best Wishes, -David Delaune

          V 1 Reply Last reply
          0
          • L Lost User

            Well, Yes; deadlocks, race conditions by the very definition means "somewhere else" is holding a lock. You are looking at the code not me. But I wouldn't recommend using the "Current Line" in the source-view as my error indicator. You need to be looking at the callstack and instructions. My recommendations remain: Attach a debugger to the process. If you want an automated analysis of the deadlock you can attach WinDbg and do: analyze -v -hang Are you developing on Windows? My mind reading skills are not working today. Best Wishes, -David Delaune

            V Offline
            V Offline
            Vaclav_
            wrote on last edited by
            #5

            David, I have "discovered" the real problem - nothing to do with synchronization. ( see my recent "volatile misbehaves " post. ) I am sorry for wasting your time on this, my apology.

            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