Lock convoy

Lock convoy

In computer science, a lock convoy is a performance problem that can occur when using locks for concurrency control in a multithreaded application.

A lock convoy occurs when multiple threads of equal priority contend repeatedly for the same lock. Unlike deadlock and livelock situations, the threads in a lock convoy do progress; however, each time a thread attempts to acquire the lock and fails, it relinquishes the remainder of its scheduling quantum and forcing a context switch. The overhead of repeated context switches and underutilization of scheduling quanta degrade overall performance.

Lock convoys often occur when concurrency control primitives such as critical sections serialize access to a commonly used resource, such as a memory heap or a thread pool. They can sometimes be addressed by using non-locking alternatives such as lock-free algorithms or by altering the relative priorities of the contending threads.


Critical sections as implemented in Microsoft Windows operating systems provide a good example of how lock convoys can occur. In Windows, critical sections use a combination of a spinlock and a kernel synchronization object called an "event" to ensure mutual exclusion. For low-contention critical sections, the spinlock will provide mutual exclusion most of the time, falling back on the event only when a thread fails to acquire the spinlock within a certain amount of time. When contention is high, however, it is possible for many threads to fail to acquire the spinlock and enter a waiting state, all waiting on the same event.

When the event is signalled, all threads that are waiting on the event are woken, but only one will be allowed to acquire the critical section and continue execution; the remaining threads will each block again.

As of Windows 2003, a thread waiting on an event is boosted to 1 priority level more than the thread which "set" (ie: signaled) the event associated to the critical section (aka, the thread releasing the critical section, which notifies other waiters by signaling the event). On the other hand, the setting thread will also lose the boost it may have requested while calling the "Set Event" API, which takes such a boost as a parameter.

These two improvements help against a lock convoy, because now, each waiting thread should be able to run its full quantum, while the thread releasing the lock will probably have to wait more before being able to acquire the resource again.

Wikimedia Foundation. 2010.

Look at other dictionaries:

  • Convoy (disambiguation) — A convoy is a group of vehicles or ships traveling together for mutual support. Convoy may also refer to: In transport LDV Convoy A cargo/passenger van manufactured by LDV In popular culture Convoy (song), a 1975 trucker s song by C. W. McCall… …   Wikipedia

  • Lock (computer science) — In computer science, a lock is a synchronization mechanism for enforcing limits on access to a resource in an environment where there are many threads of execution. Locks are one way of enforcing concurrency control policies. Contents 1 Types 2… …   Wikipedia

  • Lock (water transport) — Canal lock and lock keeper s cottage on the Aylesbury Arm of the Grand Union Canal at Marsworth in Hertfordshire, England …   Wikipedia

  • Guard lock — Guard Guard, n. [OF. guarde, F. garde; of German origin; cf. OHG. wart, warto, one who watches, warta a watching, Goth. wardja watchman. See {Guard}, v. t.] [1913 Webster] 1. One who, or that which, guards from injury, danger, exposure, or… …   The Collaborative International Dictionary of English

  • Thread (computer science) — This article is about the concurrency concept. For the multithreading in hardware, see Multithreading (computer architecture). For the form of code consisting entirely of subroutine calls, see Threaded code. For other uses, see Thread… …   Wikipedia

  • List of Transformers: Cybertron characters — Principal cast from Transformers: Cybertron. This article lists characters that appear in Transformers: Cybertron, the third chapter of the Unicron Trilogy series of the Transformers franchise. The series features the entirety of planet Cybertron …   Wikipedia

  • St Nazaire Raid — Operation Chariot redirects here. For the proposed construction of a harbour by nuclear weapons, see Operation Chariot (1958). St Nazaire Raid Operation Chariot Part of North West Europe Campaign …   Wikipedia

  • List of National Historic Sites of Canada — This is a complete list of the National Historic Sites of Canada. All such designations are made by the federal Minister of the Environment on the advice of the Historic Sites and Monuments Board of Canada . As of March 2008, there are 935 sites …   Wikipedia

  • Optimus Prime — is a fictional character from the Transformers franchise. Prime is the leader of the autobots, a faction of transforming robots from the planet Cybertron. The autobots are constantly waging war against a rival faction of transforming robots… …   Wikipedia

  • Matrix of Leadership — Plot element from the Transformers franchise Publisher Marvel Comics (introduction only) First appearance Transformers issue 10 (November 1985) Created by Bob Budiansky …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”

We are using cookies for the best presentation of our site. Continuing to use this site, you agree with this.