[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCHv2] threads: add one-time initialization support



On 04/24/2011 04:14 AM, Matthias Bolte wrote:
> 
> Compared to the gnulib lock module version, this one is less complex
> and I don't get why gnulib uses 3 states for the init and complete
> variables and an additional lock object. The only reason could be to
> minimize the time busy waiting in the while loop.

It may also be that the gnulib module was trying to worry about
cancellation points, but libvirt isn't (yet) using cancellation points.
 That does indeed require more complexity to handle an init callback
that gets cancelled, where another thread then has to take over the
one-shot initiailization.

> 
>> +
>> +struct virOnceControl {
>> +    long init; /* 0 at startup, > 0 if init has started */
>> +    volatile long complete; /* 0 until first thread completes callback */
>> +};
> 
> MSDN docs about InterlockedIncrement suggest that init should be volatile too.
> 
> ACK, with init marked volatile.

Thanks, and pushed with that modification.  I guess that also means that
the virObject patches should also be marking its reference-counter
variable as volatile.

-- 
Eric Blake   eblake redhat com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]