Click to See Complete Forum and Search --> : Multithreading problem


paskari
July 27th, 2005, 03:05 AM
Thanks for the help, I don't want anyone else to dwell on this so I removed the original question

NMTop40
July 27th, 2005, 04:43 AM
This should go into the multithreading forum.

Why pthread_cond_broadcast? (rather than pthread_cond_signal). pthread_cond_broadcast unblocks ALL the threads (might work if you have just one producer and one consumer thread).

Are empty and full declared as volatile?

y is being cast from int to int* (which is bad even for C. If param needs to contain 3 ints followed by a pointer, make it a struct).

printf("\tThread N is waiting to read the buffer\n",tnum);

there is no %d corresponding to tnum, similarly in the printf below it.

paskari
July 27th, 2005, 10:29 AM
This should go into the multithreading forum.

Why pthread_cond_broadcast? (rather than pthread_cond_signal). pthread_cond_broadcast unblocks ALL the threads (might work if you have just one producer and one consumer thread).

cuz I got more than 1 thread to signal, I have n-1 producer threads


Are empty and full declared as volatile?
[/quote[
No
[QUOTE=NMTop40]
y is being cast from int to int* (which is bad even for C. If param needs to contain 3 ints followed by a pointer, make it a struct).

don't worry about that

Bob Davis
July 27th, 2005, 12:19 PM
I think he was referring to your use of pthread_cond_broadcast() in your producer thread. You should only need to signal one thread from your producer.

And, you're probably not going to get anywhere with such a terse tone; we're trying to help.

cvogt61457
July 27th, 2005, 01:24 PM
You don't show the creation and destruction of you mutex.

Do you destroy it correctly?

Can you post the whole project?

Andreas Masur
July 27th, 2005, 05:22 PM
[ Merged threads ]

paskari
July 27th, 2005, 05:43 PM
well everyone thank you for your help, but this is the end of the road, I am off to submit it

wish me luck