development efforts on the Solaris side.
Theo Schlossnagle
theo at omniti.com
Thu Feb 14 13:32:19 CET 2008
On Feb 14, 2008, at 5:48 AM, Dag-Erling Smørgrav wrote:
> Theo Schlossnagle <theo at omniti.com> writes:
>> [re: stv = stevedores = stevedores->next;]
>>
>> [...] Was worried that the assumption that both assignments were
>> atomic. One is, then the next is. Perhaps that doesn't matter. It
>> does seem like a hard to trigger race condition to me because while
>> the assignment is atomic, the access to stevedores->next is not
>> guaranteed to be view consistent in that assignment:
>>
>> T1: get stevedores->next in R(T1,a)
>> T2: get stevedores->next in R(T2,a)
>> T1: set stevedores to R(T1,a)
>> T2: set stevedores to T(T2,a)
>>
>> Now T1 and T2 both "advanced the pointer" but they did the same work
>> and the stv they have is the same. Is that not a problem? Perhaps
>> I don't understand the impact of that scenario correctly.
>
> There is a race, but it's irrelevant. The point of this code is to
> spread the load between the stevedores. It doesn't matter if two
> simultaneours allocations go to the same stevedore as long as *all*
> allocations don't go to the same stevedore. It will balance out in
> the long run.
The comment made me think that the code was relying on different
threads getting different stevedores for safety reasons -- not
efficiency. Thanks for clearing that up.
--
Theo Schlossnagle
Esoteric Curio -- http://lethargy.org/
OmniTI Computer Consulting, Inc. -- http://omniti.com/
More information about the varnish-dev
mailing list