Locks
Locks are advisory locks, where each thread cooperates by acquiring the lock before accessing the equivalent data. Some systems also implement mandatory locks, where attempting unauthorized access to a locked resource will force exclusion in the entity attempting to make the access.
In terms of access to the data, no difference is made between shared or exclusive modes. Other schemes provide for a shared mode, where several threads can obtain a shared lock for read-only access to the data. Other modes such as exclusive, intend-to-exclude and intend-to-upgrade are also widely implemented.
Independent of the type of lock chosen above, locks can be confidential by what happens when the lock strategy prevents progress of a thread. Most locking designs block the finishing of the process requesting the lock until it is allowed to access the locked resource. A spin lock is a lock where the thread simply waits until the lock becomes accessible. It is very efficient if threads are only likely to be uncreative for a short period of time, as it avoids the overhead of operating system process re-scheduling. It is wasteful if the padlock is held for a long period of time.