From owner-freebsd-current Sun Apr 23 11:10: 4 2000 Delivered-To: freebsd-current@freebsd.org Received: from pcnet1.pcnet.com (pcnet1.pcnet.com [204.213.232.3]) by hub.freebsd.org (Postfix) with ESMTP id 1E5B037B9B4 for ; Sun, 23 Apr 2000 11:10:02 -0700 (PDT) (envelope-from eischen@vigrid.com) Received: (from eischen@localhost) by pcnet1.pcnet.com (8.8.7/PCNet) id OAA29230; Sun, 23 Apr 2000 14:09:40 -0400 (EDT) Date: Sun, 23 Apr 2000 14:09:40 -0400 (EDT) From: Daniel Eischen Message-Id: <200004231809.OAA29230@pcnet1.pcnet.com> To: Alexander@Leidinger.net, current@FreeBSD.ORG Subject: Re: pthread_cond_broadcast() not delivered Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message