I'm currently reading C++ Concurrency in Action by Anthony Williams and I'm facing an obstacle in thought.
First he describes deadlocks as when two threads lock simultaneously (at least, that's how I understood it), which makes sense.
However, he goes on to explain how you can lock two mutexes at the same time. Obviously this has a function, but with the above (assumingly wrong) understanding that would instantly deadlock both threads.
From that obstacle arises a new one; obviously it won't deadlock, which means the mutexes must have a more advanced use than just allowing a single thread to do work in a process. In the book, mutexes are given to particular objects.
This leads me to my overall question(s): Are mutexes assigned to specific memory regions, such as objects? If so, how?
The book does a great job at explaining how mutexes can be used but never really describes what mutexes are at a low level. I realize they're implementation specific but I never really grasped what exactly they do or how the locking functions use them.