Tech moves fast! Stay ahead of the curve with Techopedia!
Join nearly 200,000 subscribers who receive actionable tech insights from Techopedia.
A lock is a mechanism used to synchronize different processing threads, with set limits to avoid unlimited accessibility of a certain resource within a computing environment. It is a method meant to arrange access by applying simultaneous control policies.
Locks are typically advisory, which means that a thread works collaboratively with other threads to acquire the lock before it is given accessibility to the data it queries. Mandatory locks are also applied by some systems, where an exception occurs as a result of unauthorized access to a source in a locked status.
Also known as locking.
A lock has a simple form called a semaphore, where there is no solid difference between a shared, read only mode and an exclusive read/write mode. Shared mode has many forms including exclusive, intend-to-exclude and intend-to-upgrade. These forms are implemented in many computing systems.
There is also another method of classifying locks, which depends on the lock technique used to avoid accessing the unintended thread. A common locking technique blocks the execution of a thread entirely until the thread acquires the lock, while a spinlock tells the thread to freeze access attempts until it acquires the lock.