[Development] QBasicMutex::lockInternal() race condition?

Thiago Macieira thiago.macieira at intel.com
Thu Sep 20 17:50:55 CEST 2012


On quinta-feira, 20 de setembro de 2012 17.38.40, Olivier Goffart wrote:
> I have a change to document more the internal, but it is not merged yet.
> https://codereview.qt-project.org/33739

Staged now, thanks :-)

Tony: I'd really appreciate giving the implementation a thorough once-over. 
I've done it once and, after rewriting it, I came up with almost the same 
solutions. My implementation only differed that I added a spinlock, by using 
the lowest bit on the QMutexPrivate pointer.

I don't think my solution is any better than Olivier's. Both need to spin and 
retry: mine with a spinlock, his with that reference-and-recheck you found and 
the increment-from-zero in ref() one. I've given some thought on how to 
improve on this, but I haven't come up with any better solutions.

If you do have any idea, let us know. And please do it quickly :-)

It is also acceptable to increase the size of QMutex by another pointer, if 
that improves the solution considerably.
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120920/0dc2e362/attachment.sig>


More information about the Development mailing list