Forcing release of CriticalSection/Mutex

This is a discussion on Forcing release of CriticalSection/Mutex within the Windows Programming forums, part of the Platform Specific Boards category; I have a system service that will use a mutex to control access to shared memory. Now what I need ...

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

    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?
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,671
    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,189
    Im thinking have it set soem variable to its threadID and KillThread()
    Until you can build a working general purpose reprogrammable computer out of basic components from radio shack, you are not fit to call yourself a programmer in my presence. This is cwhizard, signing off.

  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, 07:51 AM
  4. AddRef and Release
    By George2 in forum C++ Programming
    Replies: 20
    Last Post: 02-07-2008, 12: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21