Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will implement a multithreaded version of this matrix code using POSIX Threads . The Matrix Code : #include #include int main(int argc, char *argv[])

You will implement a multithreaded version of this matrix code using POSIX Threads.

The Matrix Code :

#include #include

int main(int argc, char *argv[]) { int result; int counter = 0; int rowCounter = 0; int total = 0;

int m1[10][10] = {{17, 11, 17, 1, 14, 17, 16, 0, 0, 0}, {19, 20, 3, 17, 4, 14, 16, 0, 0, 0}, {3, 20, 9, 19, 15, 7, 4, 0, 0, 0}, {19, 4, 19, 14, 1, 20, 10, 0, 0, 0}, {13, 20, 16, 16, 6, 1, 9, 0, 0, 0}, {2, 20, 20, 15, 1, 9, 13, 0, 0, 0}, {6, 10, 14, 8, 2, 8, 15, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};

int m2[4][4] = {{1, 0, 0, 0}, {0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1}};

int i, j, x, y;

for (x = 0; x < 7; x++) { for (y = 0; y < 7; y++) { for (i = 0; i < 4; i++) { for (j = 0; j < 4; j++) { result = m1[i + x][j + y] * m2[i][j]; total += result; counter = counter + 1;

if (counter == 16) { printf("%d ", total); printf(" "); rowCounter = rowCounter + 1; if (rowCounter == 7) { printf(" "); rowCounter = 0; } total = 0; counter = 0; } } } } } return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Constraint Databases

Authors: Peter Revesz

1st Edition

1441931554, 978-1441931559

More Books

Students also viewed these Databases questions

Question

list at least 4 advantages of the waterfall process model

Answered: 1 week ago