This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author kristjan.jonsson
Recipients kristjan.jonsson, loewis, pitrou, ronaldoussoren, ysj.ray
Date 2010-04-19.11:48:48
SpamBayes Score 1.2578981e-08
Marked as misclassified No
Message-id <1271677730.95.0.995774606962.issue8410@psf.upfronthosting.co.za>
In-reply-to
Content
In 2), B is indeed signaled and the OS makes it "runnable".  But it doesn´t run immediately. A is still running.  There is no need for A to stop running until it runs out of timeslice.  Meanwhile the OS has to put B on a separate core (which makes this problem more significant on multicore), putting it at the end of the runnable queue where it has to percolate to the top for it to actually start execution some time later.

In effect, B has has to 'race' with A (and any other threads) to get the lock and since A is already running, it is likely to win the race.

Having threads 'race' to get synchronization primitives is a valid technique to reduce lock convoying problems, but it also can cause thread starvation, and is not approppriate when you want to ensure fair use of the resource.  To ensure fairness, lock "handoff" must be used.
History
Date User Action Args
2010-04-19 11:48:51kristjan.jonssonsetrecipients: + kristjan.jonsson, loewis, ronaldoussoren, pitrou, ysj.ray
2010-04-19 11:48:50kristjan.jonssonsetmessageid: <1271677730.95.0.995774606962.issue8410@psf.upfronthosting.co.za>
2010-04-19 11:48:49kristjan.jonssonlinkissue8410 messages
2010-04-19 11:48:48kristjan.jonssoncreate