Hello,
consider a bunch of threads which want to execute a while
loop in parallel but after each iteration of while loop,
we need a synchornization.That is, we have a global
count varibale which is equal to zero at beginig of each iteration
and at the end of each iterartion this variable should be equal to number
of threads before satrting the next iteration of while loop
(this helps us to be sure that all threads has already finished the iteration),
so I decided that at the end of while loop all threads will increment
the counter value and then one of threads(for example thread 0)
checks if the value of counter is equal to number of threads.As soon as the counter value becomes equal to numberOfthreads it signals this change to the other threads which are waiting for this condition ,so they can start the next while loop iterartion.
My question is how should I reset the value of counter variable
to zero?that should be done once(in one of threads) and just before
the next iterartion of while loop,I am also wondering
if the code below is logicaly correct.
Hello,
I am writing a threaded program using the pthread library in linux. I have a master thread that needs to control worker threads, in particular, it has to be able to ensure that none of the worker threads will be running for a specified amount of time, even if the worker threads are... (7 Replies)
Situation:
i have multiple pthread_create calls like this:
pthread_create(...., ThreadFunc1,.....);
pthread_create(...., ThreadFunc2,.....);
.
.
which i am using to create multiple threads.All the "ThreadFunc<i>" functions are actually calling same function "Receive" of a class using same... (3 Replies)
Hi!
I'm linking my hpux code using -lpthread (gcc), yet it references libpthread_tr.1,
the debug version of the pthread lib. How do I force it to use pthreads?
Thanks, :) (3 Replies)
I have a doubt .. ( maybe I don't know ..)
Let's say , we got the folowing example ( to understand better what I mean ).
We got two POSIX threads ( pthreads ) , one receives some strings and creates a menu ( for that strings , scrollable menu ) , and another one check's to see if it has to... (2 Replies)
Hi All,
I ve written a small program to get started off with pthreads. I somehow feel the program doesnt meet the purpose. Please find the code and the output below. Please find my question at the bottom.
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
void *PrintThread1(void... (4 Replies)
I have created a thread program, it is attached. My problem is that I need to loop this program multiple times, and basically reset everything including the threads created previously. I try to loop the program, the first run is fine, as always, but the second run of the program, the initialize... (0 Replies)
howcome that pthtreads spawn 2 extra processes?
I'm kind of new with pthreads but fork() did not act like this.
Anyone who can give me a technical explanation of what happends with mother / daughter processes?
Best regards Esaia. (2 Replies)
Can anyone explain me how to use pthread_key_create() , pthread_setspecific(), pthread_getspecific() and pthread_key_delete () routines in pthreads.
Kindly state by an example. (3 Replies)