Question: need help please Please explain what this code is doing by answering the following questions. a. How many threads are created in total, which statement



Please explain what this code is doing by answering the following questions. a. How many threads are created in total, which statement tells you this information? b. What resources/variables do these threads share in this program? c. what is the purpose of creating struct type v and pass to runner function? d. Why do we need to wait until all threads are terminated before printing out the C[M][N] ? e. What does code line 69 to line 74 do in the runner function? f. Why mutex is not used here to protect the critical section? 8. Explain the overall purpose of this code. Note: ignore line 41 pthread join0 statement and treat it as a blank line. 1 \#include h 2 \#include 3 \#include h> 4 5 \#define M 3 6 \#define K2 7 \#define N3 8 \#define NUM_THREADS MN 9 10 /* Global variables for threads to share */ 11 int A[M][K]={{{1,4},{2,5},{3,6}} : int A[M][K]={{1,4},{2,5},{3,6}}; int B[K][N]={{8,7,6},{5,4,3}}; int C[M][N]; /* Structure for passing data to threads */ struct v \{ int i;/ row / int j;/column/ \} ; void runner(void ptr) ;/ the thread / int main(int argc, char **argv) \{ int i,j; int thread_counter =0; pthread_t workers [NUM_THREADS] ; 1* We have to create MN worker threads */ for (i=0;1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
