This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: pthread & its bug


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]