[libvirt] [RFC] Atomic Operations

Tucker DiNapoli t.dinapoli42 at gmail.com
Wed Jun 4 12:16:16 UTC 2014


I'm working on job control which involves a lot of locking and unlocking,
often for operations that could be done atomically. I use the existing
atomic integer operations in viratomic.h where possible, but there are a
lot of parameters involved in jobs (such as time, thread id's, progress
information, etc) which don't fit in an integer.

I have several ideas of ways to update the existing integer atomic
operations to support more types. The easiest way (at least regarding code)
would be to use an existing atomic operations library. My suggestion would
be the libatomic_ops library, which is licensed under an MIT style license
and could be added to the source tree as a git submodule (similar to the
way gnulib is) or a specific version could be used and the library source
itself added to the git repository. The library can be found at
https://github.com/ivmai/libatomic_ops/ .

The other way of augmenting atomic operations would be to extend the
existing viratomic.h file to support additional types. Personally I have
experience working with GCC atomic operations and could implement that
myself, but I wouldn't be able to implement the windows versions.

Again I think the easiest and most maintainable way of supporting atomic
operations is via an external library, but I am not sure of the feasibility
of adding another dependency to libvirt. In general atomic operations are
an optimization, but they can help make multithreaded programming easier
and I think libvirt would be enhanced by having more comprehensive support
for atomic operations.

Tucker DiNapoli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140604/2eb7709c/attachment-0001.htm>


More information about the libvir-list mailing list