Question: # include # include sthread .h static void go( int n); # define NTHREADS 10 static sthread_t threads [ NTHREADS ]; int main (

# include # include " sthread .h" static void go( int n); # define NTHREADS 10 static sthread_t threads [ NTHREADS ]; int main ( int argc , char ** argv ) { int i;

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!