Question: One or more consumer threads work together to perform matrix multiplication. Each consumer thread gets a matrix from the bounded buffer ( M 1 )

One or more consumer threads work together to perform matrix multiplication. Each consumer thread
gets a matrix from the bounded buffer (M1) at first. Then the consumer thread gets a second matrix
from the bounded buffer (M2). Calling the matrix.c routine Matrix * MatrixMultiply(Matrix * m1,
Matrix * m2) will return a pointer with a result of the matrix multiplication (M3), or a NULL if matrix
multiplication fails due to a mismatch of the number of elements. If a NULL is received, then the
consumer thread discards the matrix (i.e., M2) and memory is freed by calling void FreeMatrix(Matrix *
mat)(refer to matrix.h and matrix.c). The consumer thread then grabs the next available matrix from
the bounded buffer as M2. When a valid matrix M2 is found that pairs with M1, the matrix
multiplication operation is performed and the result in M3 is printed using the void
DisplayMatrix(Matrix * mat, FILE *stream) routine (refer to matrix.h and matrix.c). With a successful
multiplication, both M1 and M2 will be freed and a new M1 will be obtained.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!