linux-sysprog · advanced · ~15 min
Pass an argument into a thread safely.
Implement long double_in_thread(long v) that starts one thread, passes v to it (by pointer), has the thread double it, joins, and returns the doubled value.
#include <pthread.h>
long double_in_thread(long v) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.