delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/10/11/17:17:39

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Mon, 11 Oct 2004 17:17:26 -0400
From: gmiller AT cfl DOT rr DOT com
Subject: Re: child thread termination causes main thread error termination
To: cygwin AT cygwin DOT com
Reply-to: gmiller AT cfl DOT rr DOT com
Message-id: <848cdb849d84.849d84848cdb@tampabay.rr.com>
MIME-version: 1.0
X-Virus-Scanned: Symantec AntiVirus Scan Engine
Note-from-DJ: This may be spam

Unfortunately the code does not function that way on my machine.  The code 
contrary to Brian's snipe is mine and was used in a demo of pthreads for my
class.  It works fine under multiple version of Unix and Linux but does not
work on my Windows XP Pro machine under cygwin.  What I get is the following
output.


/lab4/ $ lab4_1
waiting do_one_thing
waiting do_another_thing
Ready to start threads ..... 
&Starting ... do_one_thing
Starting ... do_another_thing
+-+-+-+-+-+-+-+-++-++++-++--+-+-+-+-----+--+++-++++++--+-+-+-+-++-+-++-+-+-+-+-+-+-++++-+-+-+-+-+-+-+-+--+--+++++-+-+-+++-+-+-+-++-+-+++-+-+-+-++++++-+-++-+-+-+-+-+-+-+-++-++@(!(/lab4/ $ 

If I uncomment the sleeps in the two threads and comment out the pthread_join
calls I get the following out as I would expect.

/lab4/ $ lab4_1
waiting do_one_thing
waiting do_another_thing
Ready to start threads ..... 
&Starting ... do_one_thing
Starting ... do_another_thing
+-+-+-+-+-+-+-+-+-+-+-+++-+++-+-++-++-++-+-+-++++--++---+--+-++---++-+-+-++-+-+-+++++-++++--+-+-++-+-++-+--+-+-+-+-+-+-+++++-+-++++-++--+-+-+-++-+-++-+++-+----++-+--+-+-++-++@(!(#&--------------------------@)#^
All threads complete

wrap up: doing another 100, another 100, total 200
!)
/lab4/ $ 


As noted the code as attached does not compile but the missing header file
only contained the  following code:

/*

    Common Local Header File: local_mutex.h

*/

#ifndef LOCAL_MUTEX_H
#define LOCAL_MUTEX_H
#define _REENTRANT
#include    <pthread.h>
#include    <stdio.h>
#include    <stdlib.h>
#include    <unistd.h>
#include    <sys/types.h>
#include    <sys/time.h>
#include    <sys/wait.h>

#endif


So adding pthread.h was all that was needed.  Since others have added the output
as I would expect I am assuming that the problem is in my cygwin environment. To
confirm that nothing I had added was causing this issue I removed my local_mutex.h
include and just used pthread.h.  The following is the output:

/labs/lab4/ $ make lab4_1
gcc -c -pg -g -Dcygwin -I ./inc/ lab4_1.c
gcc -pg -o lab4_1 lab4_1.o 
/labs/lab4/ $ lab4_1
waiting do_one_thing
waiting do_another_thing
Ready to start threads ..... 
&Starting ... do_one_thing
Starting ... do_another_thing
+-+-+-+--+-+-+-+-+-+--+-+-------+++++--+-+-+-+-+-+-----+---+--++-+-+-+-+-+-+-+-+--------+-+-+-+-+-+-+-++++-+-+-+--+-+-+-+-----+++++++--++++-++-----+---+-+-+-++--+-+-++-+-----+--+-@)!)+/labs/lab4/

Running this application in the Unix (AIX, Solaris, HP/UX, SCO, DigitalUnix) and
Linux (Red Hat 7.3, Slackware, Debian, Fedora Core 2) produces the correct output
so I am trying to find out what in my environment produces the incorrect
behavior.  I had made the rash assumtion that others testing this code in a basic
cygwin environment would encounter the same errors as I was seeing but the output
So far shows that is not the case.



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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