none
what happens if EnterCriticalSection times out?

    Question

  • Hi,

    What happens if EnterCriticalSection() raises EXCEPTION_POSSIBLE_DEADLOCK if a wait operation on the critical section times out. To be specific, the code between EnterCriticalSection() and LeaveCriticalSection() is executed or not?

    For Example

    DWORD WINAPI ThreadProc( LPVOID lpParameter )
    {
        ...
    
        // Request ownership of the critical section.
        EnterCriticalSection(&CriticalSection); 
    
        // Access the shared resource.
    
        // Release ownership of the critical section.
        LeaveCriticalSection(&CriticalSection);
    
        ...
    return 1;
    }
    

     In this example, will the code to be executed in critical section be executed, if EnterCriticalSection times out.

     

    Dhanyawaad (Thanks)

    Wednesday, February 01, 2012 6:14 AM

Answers

  • Should that occur, it will be thrown as an SEH exception.  In your example above, nothing else in ThreadProc will be executed at that point.  The process will likely be torn down as the exception is unhandled.

    • Marked as answer by Optimus22 Monday, February 13, 2012 5:29 AM
    Wednesday, February 01, 2012 3:12 PM

All replies

  • Should that occur, it will be thrown as an SEH exception.  In your example above, nothing else in ThreadProc will be executed at that point.  The process will likely be torn down as the exception is unhandled.

    • Marked as answer by Optimus22 Monday, February 13, 2012 5:29 AM
    Wednesday, February 01, 2012 3:12 PM
  • Thanks Bill, 

    This was helpful.

    Dhanyawaad (Thanks)

    Monday, February 13, 2012 5:29 AM