Re: [RFT PATCH 2/2] win32: optimize pthread_cond_broadcast

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

 



Am 07.06.2010 15:38, schrieb Paolo Bonzini:
@@ -172,9 +172,10 @@ int pthread_cond_broadcast(pthread_cond_t *cond)
  	 * As in pthread_cond_signal, access to cond->waiters and
  	 * cond->was_broadcast is locked via the external mutex.
  	 */
-
-	if ((cond->was_broadcast = cond->waiters>  0)) {
+	if (cond->waiters>  0) {
  		BOOLEAN result;
+		cond->was_broadcast = cond->waiters>  1;
+

It is possible that you set was_broadcast to 1 here, while another thread still sees was_broadcast == 0 in cond_wait. As a consequence, this thread WaitsForSingleObject(), which will never arrive because the other thread does not call SetEvent(). But this is more a problem of your first patch, not of this one, so you better fix the first one first before you go further into this one.

That said, as long as this series buys performance only at the expense of clarity, I'm rather opposed to it because we do not call cond_wait and cond_broadcast in time-critical paths.

-- Hannes
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]