linux-sysprog · advanced · ~15 min
Split work across pthreads and combine with join.
Implement long parallel_sum(const int *a, int n) that sums the array using two POSIX threads (each summing half), joins them, and returns the total.
#include <pthread.h>
long parallel_sum(const int *a, int n) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.