Thread: Forcing release of CriticalSection/Mutex

  1. #1
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195

    Forcing release of CriticalSection/Mutex

    I have a system service that will use a mutex to control access to shared memory. Now what I need to do is have some mechanism so that I can foreably release the mutex object in case some application that acquires it then crashes without releasing it. This service will be used by multiple applications, so failing to release the mutex would effectivly deadlock the service and all the applications that access it. Any ideas, complaints, recipes for disaster?

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    If it's really crashing (and exiting) then you should be getting WAIT_ABANDONED. Make sure all your wait function calls on that mutext handle it.

    If it's "hung", then I don't know of much you can do - other than track down the owning thread/process and kill with prejudice But that's kind of extreme.

    gg

  3. #3
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Im thinking have it set soem variable to its threadID and KillThread()

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    But how do you determine that the thread is "ready to be killed" rather than just "taking a long time to do something"?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. debug release conf problem
    By fighter92 in forum Game Programming
    Replies: 6
    Last Post: 03-20-2009, 04:39 PM
  2. assembly code for release code?
    By George2 in forum Windows Programming
    Replies: 4
    Last Post: 07-09-2008, 11:17 AM
  3. smart pointer release
    By George2 in forum C++ Programming
    Replies: 24
    Last Post: 02-13-2008, 08:51 AM
  4. AddRef and Release
    By George2 in forum C++ Programming
    Replies: 20
    Last Post: 02-07-2008, 01:19 AM
  5. Results in Debug and Release mode are different
    By jaro in forum C Programming
    Replies: 11
    Last Post: 05-27-2006, 11:08 AM