This is the mail archive of the cygwin-developers@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Quick testfeedback...


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@redhat.com]
> Sent: Wednesday, September 12, 2001 11:44 AM
> To: cygwin-developers@cygwin.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
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]