Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

implement using the fork() and pipe() a program that will parallelize the process of multiplying two of two-dimensional integer arrays. A parent process will create

implement using the fork() and pipe() a program that will parallelize the process of multiplying two of two-dimensional integer arrays.

A parent process will create two two-dimensional arrays, the dimensions of which will be given as parameters from the command line. Attention: The dimensions given should be such that the two tables can be multiplied, i.e. (n x m) and (m x k) should hold where (n x m) are the dimensions of the first panel and (m x k) the dimensions of the second panel. The tables will are initialized via a rand() function which will assign random numbers to range from 1 to 20, thereby filling the arrays. The multiplication of two matrices is done as follows: Let panel A be of dimensions 2 X 3 and panel B be of dimensions 3 X 4, the multiplication of these two matrices will result in matrix C with dimensions 2 X 4

The parent process will spawn as many processes (child processes) as there are elements of the final table, e.g. if we multiply a 2 x 3 matrix by a matrix 3 x 4 the number of elements of the final table will be 2 x 4 = 8 (to find the number of the elements of the final table we multiply the rows of the first by the columns of the second table). The parent process will create the necessary pipelines for communicating with child processes with the pipe() command. Specifically, in each child-process the parent process will assign the line number and its number column that the child process will take over to calculate the result of an item of the final table. Each child process will calculate and return to the parent process the result of the above calculation which should place it in the final table, e.g. in the example above if a child process is assigned 1st row of the first table and the 1st column of the second table then you should calculate the result for element 11 of the final table. In the implementation will need two pipes for communication between each child process and the parent process. One pipe will be used to write (write) the parent process and the child-process to read (read) and the second so that the child-process writes (write) and the parent process to read (read). At the end the parent process will print the final table on the screen.

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

Data And Information Quality Dimensions, Principles And Techniques

Authors: Carlo Batini, Monica Scannapieco

1st Edition

3319241060, 9783319241067

More Books

Students also viewed these Databases questions

Question

Bachelors degree in Information Systems or Statistics

Answered: 1 week ago