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

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

 



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@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]