www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/2001/09/11/21:56:19

Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-developers-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-developers/>
List-Post: <mailto:cygwin-developers AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-developers-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-developers-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin-developers AT sources DOT redhat DOT com
content-class: urn:content-classes:message
MIME-Version: 1.0
Subject: RE: Quick testfeedback...
X-MimeOLE: Produced By Microsoft Exchange V6.0.4417.0
Date: Wed, 12 Sep 2001 11:43:31 +1000
Message-ID: <EA18B9FA0FE4194AA2B4CDB91F73C0EF08F163@itdomain002.itdomain.net.au>
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
Thread-Topic: Quick testfeedback...
Thread-Index: AcE7Kp2UNBfHgpuISvukKJeY0+rkbAAAXgXQ
From: "Robert Collins" <robert DOT collins AT itdomain DOT com DOT au>
To: <cygwin-developers AT cygwin DOT com>
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id VAA11298

This is broadcast.c:

===
/* broadcast.c: Testing cond_broadcast
 *
 * Copyright 2001 Robert Collins
 *
 * This file is part of pthreadtest.
 *
 * This software is a copyrighted work licensed under the terms of the
 * GNU GPL.  Please consult the file "COPYING" for details.
 */

#include <stdio.h>
#include <pthread.h>
#include <string.h>

void *baby();

pthread_cond_t  cond;
pthread_mutex_t lock;
pthread_attr_t  attr;
pthread_t       tid;

int main ()
{
int i;

   if (i = pthread_cond_init(&cond, NULL)) {
        printf("error on cond_init %d:%s\n", i,strerror(i));
        return 1;
   }

   if (pthread_attr_init(&attr)) {
        printf("error on attr_init %d\n", i);
        return 1;
   }
   if(pthread_mutex_init(&lock, NULL)) {
        printf("error on mutex_init %d\n", i);
        return 1;
   }

   pthread_mutex_lock(&lock);
   pthread_create(&tid, &attr, baby, NULL);

   for (i=0; i<10; i++)
   {  sleep(1);
#if DEBUG
      printf("before cond wait\n");
#endif
      pthread_cond_wait(&cond, &lock);
#if DEBUG
      printf("after  cond wait\n");
#endif
   }
   pthread_mutex_unlock(&lock);
   return 0;
}

void *baby()
{
   while (1)
   {  sleep(2);
      pthread_mutex_lock(&lock);
#if DEBUG
      printf("before cond broadcast\n");
#endif
      pthread_cond_broadcast(&cond);
#if DEBUG
      printf("after  cond broadcast\n");
#endif
      pthread_mutex_unlock(&lock);
   }
}
===

> -----Original Message-----
> From: Christopher Faylor [mailto:cgf AT redhat DOT com]
> Sent: Wednesday, September 12, 2001 11:44 AM
> To: cygwin-developers AT cygwin DOT com
> Cc: Robert Collins
> Subject: Re: Quick testfeedback...
> 
> 
> On Tue, Sep 11, 2001 at 09:15:23PM -0400, Jason Tishler wrote:
> >On Tue, Sep 11, 2001 at 08:40:19PM -0400, Jason Tishler wrote:
> >> On Wed, Sep 12, 2001 at 09:19:19AM +1000, Robert Collins wrote:
> >> > If it was after the bugfix commit, I'd like to see if we 
> can track this
> >> > asap...
> >> 
> >> I can reproduce it frequently but not every time.  I will 
> debug it first
> >> thing tomorrow morning.  FYI, it seems to occur right near 
> the end of
> >> the test and the test still passes.
> >
> >Doh!  My first shot running broadcast from gdb caused the SIGSEGV:
> 
> Thanks.  This shows me exactly what is going on.
> 
> I assume that sleep() is being called from a thread, right?
> 
> cgf
> 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019