RE: [boost] Re: Boost.Threads: Do we need all those mutexes?

10 Jul
2004
10 Jul
'04
9:48 p.m.
From: Howard Hinnant [mailto:hinnant@twcny.rr.com] On Jul 9, 2004, at 11:00 PM, Glen Knowles wrote:
<nod> I just implemented lock_both::lock two ways: Once just keep try-locking both ways, and once locking in the order of the addresses of the locks (with only two locks in the test, this was a safe operator<). My test looks like:
The problem case for spinning is when one thread gets the locks and the holds them for a non-trivial length of time. During that time the other, spinning thread, just wastes cpu as fast as it can. This just gets magnified as more threads are involved.
You are describing a spin-lock, but not lock_both (except for a theoretical and unlikely scenario).
Yes, I didn't think it through all the way. Glen
7644
Age (days ago)
7644
Last active (days ago)
0 comments
1 participants
participants (1)
-
Glen Knowles