0% found this document useful (0 votes)
59 views2 pages

MUTEX

Mutual exclusion (mutex) algorithms are used to avoid simultaneous access to shared resources like variables or data structures by pieces of code called critical sections. A critical section accesses a shared resource without any mechanism for mutual exclusion. Examples of shared resources are flags, counters, or queues used for communication between concurrently running code. A mutex negotiates mutual exclusion among threads, also called a lock. A mutex can only be unlocked by the thread that locked it, giving it an owner concept.

Uploaded by

anumay001
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views2 pages

MUTEX

Mutual exclusion (mutex) algorithms are used to avoid simultaneous access to shared resources like variables or data structures by pieces of code called critical sections. A critical section accesses a shared resource without any mechanism for mutual exclusion. Examples of shared resources are flags, counters, or queues used for communication between concurrently running code. A mutex negotiates mutual exclusion among threads, also called a lock. A mutex can only be unlocked by the thread that locked it, giving it an owner concept.

Uploaded by

anumay001
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

MUTEX

Mutual exclusion (often abbreviated to mutex) algorithms are used in concurrent programming to avoid


the simultaneous use of a common resource, such as a global variable, by pieces of computer code
called critical sections. A critical section is a piece of code in which aprocess or thread accesses a
common resource. The critical section by itself is not a mechanism or algorithm for mutual exclusion. A
program, process, or thread can have the critical section in it without any mechanism or algorithm which
implements mutual exclusion.

Examples of such resources are fine-grained flags, counters or queues, used to communicate between
code that runs concurrently, such as an application and its interrupt handlers. The synchronization of
access to those resources is an acute problem because a thread can be stopped or started at any time.
A mutex is also a common name for a program object that negotiates mutual exclusion among threads,
also called a lock.

A mutex and the binary semaphore are essentially the same. Both can take values: 0 or 1. However, there is a
significant difference between them that makes mutexes more efficient than binary semaphores.

A mutex can be unlocked only by the thread that locked it. Thus a mutex has an owner concept

THREAD

In computer science, a thread of execution is the smallest unit of processing that can bescheduled by
an operating system.  The implementation of threads and processes differs from oneoperating system to
another, but in most cases, a thread is contained inside a process. Multiple threads can exist within the
same process and share resources such as memory, while differentprocesses do not share these
resources. In particular, the threads of a process share the latter's instructions (its code) and its context
(the values that its variables reference at any given momen

On a single processor, multithreading generally occurs by time-division multiplexing (as inmultitasking):


the processor switches between different threads. This context switching generally happens frequently
enough that the user perceives the threads or tasks as running at the same time. On
a multiprocessor or multi-core system, the threads or tasks will actually run at the same time, with each
processor or core running a particular thread or task.

Many modern operating systems directly support both time-sliced and multiprocessor threading with a
process scheduler. The kernel of an operating system allows programmers to manipulate threads via
the system call interface. Some implementations are called a kernel thread, whereas a lightweight
process (LWP) is a specific type of kernel thread that shares the same state and information.

Programs can have user-space threads when threading with timers, signals, or other methods to interrupt
their own execution, performing a sort of ad-hoc time-slicing.

You might also like