Re: pingpong, etc. programs
Ulrich Drepper <[email protected]>
| Newsgroups | gmane.comp.lib.phil |
|---|---|
| Organization | Red Hat, Inc. |
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Saurabh Desai wrote: > The pthread_cond_broadcast wakes up 200+ threads and they all contend > for > an internal condvar lock. And again they wait in kernel using futex. > To verify this I tried adding this patch in the library and that made a > hugh difference. This is just what I described earlier. But the solution is not to aritificially serialize the wakeup. This won't help either; the wakeup happens in the condvar function while the contended lock is freed by a pthread_mutex_unlock call (or inside the next pthread_cond_wait call). The fact that your patch has good effects is noteworthy but still a hack. The correct solution is to have the kernel handle the wakeup correctly. Our current thinking is to wake up only one thread. All the other threads are moved from the wait-queue of the condvar to the wait-queue of the mutex. Since there is exactly one mutex involved with every condvar at any one time the pthread_cond_broadcast function knows where the mutex wait list is. I just have to wait for Ingo to have some time to implement this. - -- - --------------. ,-. 444 Castro Street Ulrich Drepper \ ,-----------------' \ Mountain View, CA 94041 USA Red Hat `--' drepper at redhat.com `--------------------------- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE+sG/m2ijCOnn/RHQRAlxDAJ98J6DHF1mgHTj0m83ZZovhUr++OgCguai2 2f+Dt6rH/rg5yxtyLMbgLjs= =818N -----END PGP SIGNATURE-----