pthread & its bug
John (Eljay) Love-Jensen
eljay@adobe.com
Fri Mar 23 21:21:00 GMT 2007
Hi Mohsen,
Your inquiry is off topic for this forum. I do not say this to chastize you. I say it because you may get better / faster / more accurate information from a more appropriate forum that is pthread savvy.
There are a whole bunch of errors in your test source code.
For example, the pthread_create's third parameter takes a function pointer to a function that looks like:
void* task(void* ptr);
You are passing in a function pointer to a function that looks like:
void task(int* counter);
And you are casting the function pointer to a data pointer:
(void*)task1
That doesn't fit.
Another example, pthread_create's first parameter takes a pointer to a pthread_t. You are passing in a poiter to a pointer to a pthread_t. (And that pointer-to-a-pointer has not been allocated anywhere.)
That doesn't fit.
Work through all the mismatched data types, and then see where things end up. GCC helps you, by emitting a lot of warnings and errors. Heed them.
Don't forget to:
gcc test.c -lpthread
HTH,
--Eljay
More information about the Gcc-help
mailing list