Question
Implement matrix multiplication using processes and pipes in Ubuntu C. Please make sure your program complies and runs without any error. You can use two
Implement matrix multiplication using processes and pipes in Ubuntu C. Please make sure your program complies and runs without any error. You can use two sample files to write the program but it should accept any two matrices.
Implement the matrix multiplication using processes by having on process obtaining one element of the product matrix. Your program will read two matrices from two files called A.txt and B.txt. The soultion will be output into a text file called AB.txt The file will contain on the first for the number of rows followed by the number of columns separated by space. The next rows will contain the row s of the matrix like this:
Text file A:
4 3
8 5 3
1 45 5
19 2 6
9 0 1
Text File B:
6 5 2 9 21 8 0 1
Write the result in the same format in the file called AB.txt
Implementation steps:
-read matrix A from file A.txt
-read matrix B from file B.txt
-check if the two matrices can be multiplied
-create the communication pipes between the parent and the n*p processes
-create n*p processes and corresponding input and output queues
-send from the parent to the child processes m values for the corresponding row from A followed by m values for the corresponding column in B
-each process will multiply element by element and then sum up to obtain one value in AB
-send the computed value from the child processes to the parent
-the parent waits for all values to be computed
-parent writes the resulted matrix to file in the same format A and B were read
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