Question: Given the content of a C source file named code.c 1 #include 2 #include 3 void 4 5 } hello (void tid) { printf(Hello

Given the content of a C source file named "code.c" 1 #include 2 #include 3 void 4 5 } hello (void tid) { printf("Hello from thread %d ", (int) tid); 6 int main() { 7 9 10 11 12 13 } pthread_t tid [10]; int i; for (i=0; i < 10; i++) { } pthread_create(&tid [i], NULL, hello, (void*)i); pthread_exit (NULL); Since threads run concurrently, the output produced by threads will appear randomly and in an unpredictable way. Modify this program to have those threads to print their thread ID in ascending order every time we run the program as follows: 1### ./code 2 Hello from thread 0. 3 Hello from thread 1. 4 Hello from thread 2 5 Hello from thread 3 6 Hello from thread 4. 7 Hello from thread 5 8 Hello from thread 6 9 Hello from thread 7. 10 Hello from thread 8 11 Hello from thread 9
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
