Question
Note:I Want to use a POSIX Threads in the following code as mentioned in the Question *You will implement a multithreaded version of your work
Note:I Want to use a POSIX Threads in the following code as mentioned in the 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 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 -1.
CODE:
#include
using namespace std;
// multiplies corresponding elements of matrices a and b int correspondingMultiplication(vector
// generates an overlapping region for matrix M2 in matrix M1 vector
for(int i = 0; i < len2; ++i) { for(int j = 0; j < brd2; ++j) { if(row + i < len1 && col + j < brd1) mat[i][j] = m1[row + i][col + j]; else mat[i][j] = 0; } } return mat; }
int main() { // M1 and M2 given in the sample vector
int len1 = m1.size(), brd1 = m1[0].size(); int len2 = m2.size(), brd2 = m2[0].size(); vector
for(int row = 0; row < len1; ++row) { for(int col = 0; col < brd1; ++col) { vector
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started