MUTEX
MUTEX
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
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.