----- Original Message ----- From: "Evan Pollan" <[EMAIL PROTECTED]> To: "Lassi A. Tuura" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> 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" <[EMAIL PROTECTED]> 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/