Question: # include # include sthread .h static void go( int n); # define NTHREADS 10 static sthread_t threads [ NTHREADS ]; int main (
# include
long exitValue; for (i = 0; i < NTHREADS ; i ++){ sthread create(&( threads [i ]), &go , i ); } for (i = 0; i < NTHREADS ; i ++){ long ret = sthread join( threads [i ]); printf (" Thread %d returned %ld ", i , ret ); } printf (" Main thread done . "); return 0; } void go( int n) { printf (" Hello from thread %d ", n); sthread exit (100 + n);
}
The procedure main() has local variables such as I and exitValue. Are these variables per thread or shared state? Where does the compiler store these variables' states?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
