public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Evan Pollan <evan_pollan@yahoo.com>
To: "Lassi A. Tuura" <lassi.tuura@cern.ch>
Cc: cygwin@cygwin.com
Subject: Re: pthread_create -- no callback?
Date: Sun, 11 Nov 2001 08:26:00 -0000	[thread overview]
Message-ID: <20011114141805.42346.qmail@web21009.mail.yahoo.com> (raw)
In-Reply-To: <3BF23A9A.5A9F35E0@cern.ch>

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?

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.tuura@cern.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/

  reply	other threads:[~2001-11-14 14:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-01 21:42 Evan Pollan
2001-11-02  0:09 ` Lassi A. Tuura
2001-11-02  4:47   ` Evan Pollan
2001-11-11  8:26     ` Evan Pollan
2001-11-11  8:26     ` Lassi A. Tuura
2001-11-11  8:26       ` Evan Pollan [this message]
2001-11-11  8:26         ` Lassi A. Tuura
2001-11-11  8:26           ` Gareth Pearce
2001-11-11  8:26             ` Lassi A. Tuura
2001-11-11  8:26           ` Robert Collins
2001-11-11  8:26             ` Evan Pollan
2001-11-11  8:26               ` Lassi A. Tuura
2001-11-11  8:26                 ` Robert Collins
2001-11-11  8:26         ` Gareth Pearce
2001-11-11  8:26           ` David Starks-Browning
2001-11-11  8:26   ` Lassi A. Tuura
2001-11-11  8:26 ` Evan Pollan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20011114141805.42346.qmail@web21009.mail.yahoo.com \
    --to=evan_pollan@yahoo.com \
    --cc=cygwin@cygwin.com \
    --cc=lassi.tuura@cern.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).