Sign in to follow this  

mutex dead lock

This topic is 4204 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

seems my app is getting stuck in a mutex dead lock. And its being a pain the ass to debug. Now im rather new to multithreaded programming, when i create a mutex: mHandle = CreateMutex(0, false, 0); and lock it: WaitForSingleObject(mHandle, INFINITE); will this mutex only block if this handle has already been locked or will it also block if there is any other locked mutex?

Share this post


Link to post
Share on other sites
huh? how can it be acquired multiple times? i thought if you attempt to aquire a second time it blocks until the other frees it. Then obviously you will get a new lock which you must release when done...

Share this post


Link to post
Share on other sites
You can acquire the same mutex twice in the same thread. Think about what would happen if this was not allowed, and the second attempt to acquire "blocks until the other frees it".

Share this post


Link to post
Share on other sites
The only ways deadlock can be caused by using mutexes are:

1. You have some situation which acquires the mutex but never frees it.

2. You use more than 1 mutex, and you attempt to acquire them in inconsistent orders. (this is really just a special / common case of item 1).

Share this post


Link to post
Share on other sites

This topic is 4204 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this