delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT sources DOT redhat DOT com> |
List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
List-Post: | <mailto:cygwin AT sources DOT redhat DOT com> |
List-Help: | <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs> |
Sender: | cygwin-owner AT sources DOT redhat DOT com |
Delivered-To: | mailing list cygwin AT sources DOT redhat DOT com |
Message-ID: | <020201c0d289$81655c30$0200a8c0@lifelesswks> |
From: | "Robert Collins" <robert DOT collins AT itdomain DOT com DOT au> |
To: | "Greg Smith" <rys AT epaibm DOT rtpnc DOT epa DOT gov>, "greg smith" <cygwin AT cygwin DOT com> |
References: | <3AEF04AC DOT 62D56B1B AT trex DOT rtpnc DOT epa DOT gov> |
Subject: | Re: loop in pthread_cond_broadcast |
Date: | Wed, 2 May 2001 07:55:56 +1000 |
MIME-Version: | 1.0 |
X-Priority: | 3 |
X-MSMail-Priority: | Normal |
X-Mailer: | Microsoft Outlook Express 5.50.4133.2400 |
X-MimeOLE: | Produced By Microsoft MimeOLE V5.50.4133.2400 |
X-OriginalArrivalTime: | 01 May 2001 21:50:55.0365 (UTC) FILETIME=[CC6FFB50:01C0D288] |
Thanks Greg, I'll look into a fix for this. Rob ----- Original Message ----- From: "Greg Smith" <rys AT epaibm DOT rtpnc DOT epa DOT gov> To: "greg smith" <cygwin AT cygwin DOT com> Sent: Wednesday, May 02, 2001 4:47 AM Subject: loop in pthread_cond_broadcast > Below is a sample program that illustrates a loop in pthread_cond_broadcast() > when called the second time. CPU utilization goes to 100% and the function > never returns. > > Thanks, Greg > > gsmith AT GREG ~ > $ cat ptbarf.c > #include <stdio.h> > #include <pthread.h> > > void *baby(); > > pthread_cond_t cond; > pthread_mutex_t lock; > pthread_attr_t attr; > pthread_t tid; > > int main () > { > int i; > > pthread_cond_init(&cond, NULL); > pthread_attr_init(&attr); > pthread_mutex_init(&lock, NULL); > > pthread_mutex_lock(&lock); > pthread_create(&tid, &attr, baby, NULL); > > for (i=0; i<10; i++) > { sleep(1); > printf("before cond wait\n"); > pthread_cond_wait(&cond, &lock); > printf("after cond wait\n"); > } > pthread_mutex_unlock(&lock); > } > > void *baby() > { > while (1) > { sleep(2); > pthread_mutex_lock(&lock); > printf("before cond broadcast\n"); > pthread_cond_broadcast(&cond); > printf("after cond broadcast\n"); > pthread_mutex_unlock(&lock); > } > } > > gsmith AT GREG ~ > $ gcc -o ptbarf ptbarf.c > > gsmith AT GREG ~ > $ ./ptbarf > before cond wait > before cond broadcast > after cond broadcast > after cond wait > before cond wait > before cond broadcast > > -- > Want to unsubscribe from this list? > Check out: http://cygwin.com/ml/#unsubscribe-simple > > -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |