Thread synchronization


Question:

Thread Synchronization

C program that runs under cygwin which again declares three pthreads. The main program prompts the user for the values x, y, z all integers.

It then starts the threads. Thread1 calculates the average of x, y and z and puts the value into a shared variable w.

Thread2 calculates the product and puts the value into v.

Thread3 finds the largest value and puts the value into u. Each thread waits for the other threads to finish writing using a join statement.

Then threard1 computes the sum of u,v and w and puts the result into x.

Thread2 computes the product and puts it in y. Thread3 computes the largest value and puts it in z.

The main program waits for each thread to complete and outputs x, y and z.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Thread synchronization
Reference No:- TGS01937462

Now Priced at $20 (50% Discount)

Recommended (90%)

Rated (4.3/5)