Global Sources
EE Times-India
 
EE Times-India > EDA/IP
 
 
EDA/IP  

Common problems in multi-core programming, Part 2: Heavily contended locks

Posted: 03 Mar 2009     Print Version  Bookmark and Share

Keywords:thread  time-slicing  deadlocks 

Proper use of lock to avoid race conditions can invite performance problems if the lock becomes highly contended. The lock becomes like a tollgate on a highway. If cars arrive at the tollgate faster than the toll taker can process them, the cars will queue up in a traffic jam behind the tollgate.

Similarly, if threads try to acquire a lock faster than the rate at which a thread can execute the corresponding critical section, then program performance will suffer as threads will form a "convoy" waiting to acquire the lock. Indeed, this behaviour is sometimes referred to as convoying.

As mentioned in the discussion of time-slicing woes, convoying becomes even worse for fair locks, because if a thread falls asleep, all threads behind it have to wait for it to wake up. Imagine that software threads are cars and hardware threads are the drivers in those cars. This might seem like a backwards analogy, but from a car's perspective, people exist solely to move cars between parking places. If the cars form a convoy, and a driver leaves his or her car, everyone else behind is stuck.

Part 1 of this series discusses threads, data races, deadlocks and live locks. This second instalment will focus on heavily contended locks.

View the PDF document for more information.





Comment on "Common problems in multi-core progra..."
Comments:  
*  You can enter [0] more charecters.
*Verify code:
 
 
Webinars

Seminars

Visit Asia Webinars to learn about the latest in technology and get practical design tips.

 

Go to top             Connect on Facebook      Follow us on Twitter      Follow us on Orkut

 
Back to Top