delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/11/14/09:56:46

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
X-Originating-IP: [198.142.164.226]
From: "Gareth Pearce" <tilps AT hotmail DOT com>
To: <cygwin AT cygwin DOT com>
References: <20011114141805 DOT 42346 DOT qmail AT web21009 DOT mail DOT yahoo DOT com>
Subject: Re: pthread_create -- no callback?
Date: Thu, 15 Nov 2001 01:56:01 +1100
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Message-ID: <OE16FSbICCW8Nh63DXM00011320@hotmail.com>
X-OriginalArrivalTime: 14 Nov 2001 14:56:12.0004 (UTC) FILETIME=[802D2A40:01C16D1C]

----- Original Message -----
From: "Evan Pollan" <evan_pollan AT yahoo DOT com>
To: "Lassi A. Tuura" <lassi DOT tuura AT cern DOT ch>
Cc: <cygwin AT cygwin DOT com>
Sent: Thursday, November 15, 2001 1:18 AM
Subject: Re: pthread_create -- no callback?


> Lassi--
>
> The sample I included did check the return value of pthread_join.  I now
have
> it also checking the return value of pthread_create.  So, pthread_create
> returns sucessfully, the callback never gets invoked, and pthread_join
> indicates that the thread exited with an error.
>
> Gareth Pearce seems to recall reading that pthread_join isn't implemented
in
> 1.3.5...  Is this correct?

this time i remember to actually send to the list - that isnt exactly what I
said - the FAQ indicates that pthread_join is not implemented - however a
quick perusal of the source code suggests otherwise. - so I return you to
your guessing... - prehaps the FAQ might update a few of these sometime?

the value your printing out for pthread_join is irrelivent in this case -
since the error is defined by the return value and it returns 3 -
indictating that it couldnt find a process associated witht the thread you
passed it.  I would think this means that the callback has completed...
however it hasnt anyway I fiddle it ... (changing cout for printf ... just
making the function

so I guess I am not much help today... but I thought I should at least
clarify what I had said...

>
> Anyhow, again, here's the (updated) sample code and the resulting output:
>
> #include "pthread.h"
> #include <iostream>
>
> extern "C" void* callbackFunction (void*);
>
> void* callbackFunction (void* arg) {
>     cout << "--> callbackFunction(" << (arg==NULL ? "NULL" : arg) <<
")\n";
>     return NULL;
> }
>
> int main (int numArgs, char** args) {
>
>     pthread_t thread;
>
>     pthread_attr_t pta;
>     pthread_attr_init(&pta);
>
>     cout << "--> pthread_create()\n";
>     int retVal = pthread_create(&thread, &pta, callbackFunction, NULL);
>     cout << "<-- pthread_create():" << retVal << "\n";
>
>     void* threadExitStatus;
>     cout << "--> pthread_join()\n";
>     pthread_join(&thread, &threadExitStatus);
>     cout << "<-- pthread_join():" << (int)threadExitStatus << "\n";
> }
>
>
>
> *******************************
> make.exe: Entering directory `/cygdrive/c/home/src/c++/PThreadTest'
> rm -f  PThreadTest.o PThreadTest
> g++ -W -Wall -Wno-non-virtual-dtor -Wwrite-strings -Wpointer-arith
> -Wnested-externs -Woverloaded-virtual -Wbad-function-cast -ansi -pedantic 
-c
> PThreadTest.cpp -o PThreadTest.o
> PThreadTest.cpp: In function `int main(int, char **)':
> PThreadTest.cpp:11: warning: unused parameter `int numArgs'
> PThreadTest.cpp:11: warning: unused parameter `char ** args'
> g++ -W -Wall -Wno-non-virtual-dtor -Wwrite-strings -Wpointer-arith
> -Wnested-externs -Woverloaded-virtual -Wbad-function-cast -ansi -pedantic
> PThreadTest.o -o PThreadTest
> make.exe: Leaving directory `/cygdrive/c/home/src/c++/PThreadTest'
>
>
>
> Output:
>
> --> pthread_create()
> <-- pthread_create():0
> --> pthread_join()
> <-- pthread_join():1627734452
>
>
>
> Ideas!?!?!  Again, this is Cygwin 1.3.5 (and all other packages as of 2
days
> ago) on a Win2000 Professional box.
>
>
>
> thanks,
> Evan
>
>
>
>
>
>
>
>
>
>
>
>
> --- "Lassi A. Tuura" <lassi DOT tuura AT cern DOT ch> wrote:
> > > Yeah, arg problem noted.  Oversight on my part, thanks.  However, the
> > thread
> > > callback still appears to be a problem.  Here's a more simplified
example:
> >
> > Compile with warnings; on linux I use: g++ -W -Wall
> > -Wno-non-virtual-dtor -Wwrite-strings -Wpointer-arith -Wnested-externs
> > -Woverloaded-virtual -Wbad-function-cast -ansi -pedantic -pthread.
> >
> > Check the pthread return values for errors.
> >
> > Doing either of these will show you exactly where your problem is.  Make
> > both practises a habit.
> >
> > HTH,
> > //lat
> > --
> > This planet has -- or rather had -- a problem, which was this: most
> > of the people living on it were unhappy for pretty much of the time.
> > Many solutions were suggested for this problem, but most of these
> > were largely concerned with the movements of small green pieces of
> > paper, which is odd because on the whole it wasn't the small green
> > pieces of paper that were unhappy.  --Douglas Adams
>
>
> __________________________________________________
> Do You Yahoo!?
> Find the one for you at Yahoo! Personals
> http://personals.yahoo.com
>
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting:         http://cygwin.com/bugs.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/
>
>

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.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