Question: You will implement a multithreaded version of your work in phase 1 using POSIX Threads. You will compute each number in the output matrix with
You will implement a multithreaded version of your work in phase using POSIX Threads.
You will compute each number in the output matrix with a separate thread.
You will display the contents of the output matrix whenever a thread sets a value in the
output matrix.
Initially, all the values in the output matrix will be equal to
this is my phase code :
#include
#define MROWS
#define MCOLS
#define MROWS
#define MCOLS
Function to multiply matrices based on the given criteria
void multiplyMatricesint mMROWSMCOLS int mMROWSMCOLS int resultMROWSMCOLS
int i j k l;
for i ; i MROWS; i
for j ; j MCOLS; j
resultij; Initializing result matrix element to
for k ; k MROWS; k
for l ; l MCOLS; l
Multiplying corresponding elements and summing the result
if i k MROWS && j l MCOLS
resultij mi kj l mkl;
Function to display the matrix
void displayMatrixint matrixMROWSMCOLS
int i j;
for i ; i MROWS; i
for j ; j MCOLS; j
printfdt matrixij;
printf
;
int main
int mMROWSMCOLS
;
int mMROWSMCOLS
;
int resultMROWSMCOLS;
multiplyMatricesm m result;
Displaying the result matrix
displayMatrixresult;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
