CS471/571 - Operating Systems


Exercise #5

Modify the e5.c program to support threads. Make the program launch 4 threads to compute the value of the data section in the same way that compute_value() does. The data section should be divided among the 4 threads, each thread computing the value of each section, then using a mutex to protect the global value variable each thread should add their sub-value to the global value.

Assuming you have 4 CPU cores in your system, the speedup should be almost linear with respect to the number of threads if you implemented it correctly.