A mutual exclusion object, or MUTEX, is an object created for use in computer programs. The essential function of MUTEX is to make it possible for a multiple program thread to make use of a single resource. Generally, the functionality of mutual exclusion objects is to allow this use of a single resource by creating an environment where the access to the resource is continually passed back and forth between the various aspects of the program.
The process of activating and creating a MUTEX takes place when the computer program application is opened. Essentially, the program will create the MUTEX and relate it to a specific resource that is needed for the efficient function of the open program. As the resources is called forth, the operating system will assign a unique name to the MUTEX and use it to identify the process for as long as the program remains open.
Once the MUTEX is activated and named for the session, any other thread of the program that requires this resource can have access, even though the resource is already in active use by another thread. By indicating a need for the resource, the MUTEX function will begin to alternate access of the resource back and forth between the threads. To the end user, this process is transparent. For all practical intents and purposes, it appears that two users or two threads are making us of the same resource simultaneously.
While the speed of the transfer of access is so quick that it is not even noticeable to the end user, it should be noted that whenever a resource is in use, it is effectively locked to the one thread in the sequence. Another thread requiring the use of the resource will issue a request that will go into a queue and remain there until the first thread has finished with the active use. At that point, the resource is unlocked and the MUTEX function allows the next thread in the queue active access. If a third thread is active and needs the resource, MUTEX will also line this thread into the queue and grant access on a rotating basis.