Alexander Leidinger wrote:
> Hi,
>
> (14) netchild@ttyp2% uname -a
> FreeBSD Magelan.Leidinger.net 5.0-CURRENT FreeBSD 5.0-CURRENT #14: Fri Apr 21
>17:28:37 CEST 2000 root@:/big/usr/src/sys/compile/WORK i386
>
> I've an application which uses pthread_cond_{wait,broadcast}() and
> the debug output gives me the impression that the broadcast did not get
> delivered anymore.
>
> I run this program only occasionally, but with 4-current (last year) it
> worked, and I haven't changed anything mutex-/cond-related in it since
> then.
>
> I've attached a short test-prog (1.7k) which shows the same behavior,
> compile it with "cc -D_THREAD_SAFE -pthread test.c" and run "./a.out".
If you want it to work correctly, you have to make the second thread
release the mutex. Look at it more closely:
void *
second_thread(void *arg)
{
/* syncronize */
fprintf(stderr, "Second: lock.\n");
pthread_mutex_lock(main_mutex);
fprintf(stderr, "Second: broadcast.\n");
pthread_cond_broadcast(main_cond);
fprintf(stderr, "Second: unlock.\n");
pthread_mutex_lock(main_mutex);
^^^^^^^^^^^^^^^^^^
fprintf(stderr, "Second: sleep.\n");
sleep(10);
fprintf(stderr, "Second: exit.\n");
pthread_exit(0);
}
--
Dan Eischen
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message