RE: pthread & its bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux