Hey folks, I'm having a hard time finding a solution to this problem !! any help would be much appreciated ! PS: This is using C/UNIX You will write a program that uses multiple processes to compute the sum of a set of (small) positive integers. There are two kinds of processes to write this program : A set of ``worker'' processes. Each worker process reads two small integers from its argv, computes its sum and returns the result using exit system call. So, for every sum a worker process is created. A ``coordinator'' process. It is responsible for creating the ``worker'' processes, and coordinating the computation. Note that all the computation is done by the ``worker'' processes. All the numbers are provided in the command line (argv). So basically i have to write two programs : coordinator.c and workers.c Coordinator tells the workers to compute the sum of two numbers ( Example: if there are 8 numbers then there is a need for 4 workers for each pair, then 2 workers for the resulting 4 numbers then 1 worker for the resulting 2 numbers. thanks !!!
Explanation / Answer
You can create worker threads like this: int main(int argc,char *argv[]) { int t; pthread_t thread[2]; int thread_info[2]; create_mutex(); //Creating the mutexes and the condition variables for(t=0;t