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. Computer freezing up on wait

Computer freezing up on wait

Scheduled Pinned Locked Moved C / C++ / MFC
csharpvisual-studiohelpquestionworkspace
7 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.
  • T Offline
    T Offline
    theFrenchHornet
    wrote on last edited by
    #1

    The application I am working on, call it Main, starts up another executable, call it Sub, and the two share an event. The event is created in Main before Sub starts, and then opened in Sub. The problem I am having in debugging them is that if Main hasn't reset the event, Sub freezes the computer, to the point where the only way I can recover is to power-down. The freeze happens here: while (WaitForSingleObject(hAcquireActive, 100)==WAIT_OBJECT_0) { Sleep(1000); } I tried something slightly different by creating an event to use in place of the Sleep, but it freezes the computer in the same way. That code is: HANDLE waitForeverEvent; waitForeverEvent = CreateEvent(NULL, FALSE, FALSE, "forever"); while (WaitForSingleObject(hAcquireActive, 100)==WAIT_OBJECT_0) { WaitForSingleObject(waitForeverEvent, 1000); } Environment is : Windows XP Professional, Visual Studio 2003. Any explanation for why the computer is freezing, and/or a better way to wait for the hAcquireActive event to be reset while I am debugging? Thanks.

    J B 2 Replies Last reply
    0
    • T theFrenchHornet

      The application I am working on, call it Main, starts up another executable, call it Sub, and the two share an event. The event is created in Main before Sub starts, and then opened in Sub. The problem I am having in debugging them is that if Main hasn't reset the event, Sub freezes the computer, to the point where the only way I can recover is to power-down. The freeze happens here: while (WaitForSingleObject(hAcquireActive, 100)==WAIT_OBJECT_0) { Sleep(1000); } I tried something slightly different by creating an event to use in place of the Sleep, but it freezes the computer in the same way. That code is: HANDLE waitForeverEvent; waitForeverEvent = CreateEvent(NULL, FALSE, FALSE, "forever"); while (WaitForSingleObject(hAcquireActive, 100)==WAIT_OBJECT_0) { WaitForSingleObject(waitForeverEvent, 1000); } Environment is : Windows XP Professional, Visual Studio 2003. Any explanation for why the computer is freezing, and/or a better way to wait for the hAcquireActive event to be reset while I am debugging? Thanks.

      J Offline
      J Offline
      Jack Puppy
      wrote on last edited by
      #2

      Does this describe your problem? PRB: Synchronization Failure When Debugging

      :suss: Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!

      T B 3 Replies Last reply
      0
      • J Jack Puppy

        Does this describe your problem? PRB: Synchronization Failure When Debugging

        :suss: Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!

        T Offline
        T Offline
        theFrenchHornet
        wrote on last edited by
        #3

        Thank you for finding that. Somewhat, but the same thing happens when running a release version outside of Debug. I am looking into the possibility that it is a bus problem caused by one of the cards in the system.

        1 Reply Last reply
        0
        • T theFrenchHornet

          The application I am working on, call it Main, starts up another executable, call it Sub, and the two share an event. The event is created in Main before Sub starts, and then opened in Sub. The problem I am having in debugging them is that if Main hasn't reset the event, Sub freezes the computer, to the point where the only way I can recover is to power-down. The freeze happens here: while (WaitForSingleObject(hAcquireActive, 100)==WAIT_OBJECT_0) { Sleep(1000); } I tried something slightly different by creating an event to use in place of the Sleep, but it freezes the computer in the same way. That code is: HANDLE waitForeverEvent; waitForeverEvent = CreateEvent(NULL, FALSE, FALSE, "forever"); while (WaitForSingleObject(hAcquireActive, 100)==WAIT_OBJECT_0) { WaitForSingleObject(waitForeverEvent, 1000); } Environment is : Windows XP Professional, Visual Studio 2003. Any explanation for why the computer is freezing, and/or a better way to wait for the hAcquireActive event to be reset while I am debugging? Thanks.

          B Offline
          B Offline
          Blake Miller
          wrote on last edited by
          #4

          What happens in your main program AFTER the while loop? Since you only check for WAIT_OBJECT_0, if the hAcquireActive is not signaled within 100ms then your wait will return with WAIT_TIMEOUT and oyu will not enter your while loop. Could this be your problem?

          T 1 Reply Last reply
          0
          • B Blake Miller

            What happens in your main program AFTER the while loop? Since you only check for WAIT_OBJECT_0, if the hAcquireActive is not signaled within 100ms then your wait will return with WAIT_TIMEOUT and oyu will not enter your while loop. Could this be your problem?

            T Offline
            T Offline
            theFrenchHornet
            wrote on last edited by
            #5

            Blake, Good thinking, based on the amount of code I posted. I probably should have put more of the preceding code. The way the 2 interact, the Sub code - which is the one that was hanging on the sleep - has just set the event and checked that it is indeed set. Then comes the code I posted which is waiting for it to be reset by Main. If it has been reset, then there is no need to go into the loop. During the debugging process, I took main out of the picture - created the event in Sub - and added some other lines inside the loop to guarantee things were for sure freezing on the Sleep or WaitForSingleObject, and they were. The problem turned out to be a bad hotlink receiver card. It was replaced and now the problem is gone. The specifics of why it manifested that way I don't know. Since it works now, move on ... In hindsight, since it was freezing to the extent the system had to be powered down, I might have more quickly ruled out that it was a coding problem. Thanks for your help.

            1 Reply Last reply
            0
            • J Jack Puppy

              Does this describe your problem? PRB: Synchronization Failure When Debugging

              :suss: Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!

              T Offline
              T Offline
              theFrenchHornet
              wrote on last edited by
              #6

              Jack, Turned out to be bad hotlink receiver card. Thanks again for your help.

              1 Reply Last reply
              0
              • J Jack Puppy

                Does this describe your problem? PRB: Synchronization Failure When Debugging

                :suss: Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!

                B Offline
                B Offline
                Blake Miller
                wrote on last edited by
                #7

                Now that was SERIOUSY cool to know. Thanks a ton :cool:

                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