TL;DR – Kill the Mutex!
Have you ever tried opening up 2 instances of Windows media player (WMP)?
Did you ever wonder how come you are able to open as many instances of Chrome as you like but you can open only 1 WMP? Question no more – this is the post for you!
Yesterday i went to a meetup in my city, and the presenter wanted to play a video while pausing another video in WMP. He tried to open the 2nd instance, but to no avail. Nothing helped. Seeing his frustration i decided to step in (well, after all all attendees were developers, i knew they’d appreciate this).
In parallel processing there is this concept of locks. A lock is sort of a single access right to a piece of data, if 1 thread is holding the lock for data X then another thread will not be able to access X until the 1st thread releases that lock.
Mutex is a lock, but a peripheral one, meaning it is not only shared across multiple threads but can also be used by different processes. Mutex is a inter-process lock.
So, back to WMP. When you start an instance of WMP, it automatically creates a Mutex lock indicating that no more instances can be created.
I went up to the presenter, opened up a process explorer on his machine, found that Mutex responsible for WMP instances and killed it. After that he was able to play 2 instances of WMP at the same time.
Here how this lock looks like in Process Explorer:
This was a pretty cool hack, don’t you think?
If you are angry, mad or happy about this post and want to share it with me – leave a comment.
Alway Be Coding (ABC)