Mutual Exclusion: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
(added category: Stubs)
(Existing page was virtually non-existent, this is at least a start :¬))
Line 1: Line 1:
{{Stub}}
{{Stub}}


A "mutex", from "mutual exclusion" is a resource used as part of a locking mechanism to ensure that only one thread at a time can access another resource; I.E. to make a code section safe to run on a multi-threaded system.
Mutual Exclusion is the state in which exactly one process has access to a given resource at a time.

An example implementation might be to check for the existence of a specific file, if this file exists then another thread has already 'locked' access and our example must try again later. However, if the file does not exist, our thread immediately creates it, so 'locking' the resource it is about to acces, then it goes ahead with access on the potentially contested resource, safe in the knowledge that no other thread should be able to interfere.


[[Category:Synchronization]]
[[Category:Synchronization]]

Revision as of 19:39, 6 October 2010

This page is a stub.
You can help the wiki by accurately adding more contents to it.

A "mutex", from "mutual exclusion" is a resource used as part of a locking mechanism to ensure that only one thread at a time can access another resource; I.E. to make a code section safe to run on a multi-threaded system.

An example implementation might be to check for the existence of a specific file, if this file exists then another thread has already 'locked' access and our example must try again later. However, if the file does not exist, our thread immediately creates it, so 'locking' the resource it is about to acces, then it goes ahead with access on the potentially contested resource, safe in the knowledge that no other thread should be able to interfere.