Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q1 (12,5 points). We want you to write a multithreaded program in C to do some simple matrix arithmetic. The requirement is very simple; your

image text in transcribed

Q1 (12,5 points). We want you to write a multithreaded program in C to do some simple matrix arithmetic. The requirement is very simple; your program should read a square matrix of some integers from a text file (an example file given below), populate it into a proper data structure, and calculate the sum of all the numbers present in the matrix. But the calculation process should be carried out by 4 different worker threads in parallel. You can think of your matrix equally divided into 4 sections (northwest, northeast, southwest, southeast). You can also assume that the number of rows, hence the number of columns since it is a square matrix, is an integral power of 2. The results of the worker threads should be assembled, i.e. added up, to get the overall result of the program. In the meantime, the main thread should also calculate the same summation, and compare its own results with the assembled results of the worker threads. Finally, it should produce a simple output indicating whether the resulting cooperative calculation by the worker threads is correct, or not. You should take care of any synchronization requirements of the threads, and implement the proper synchronization solution whenever needed. On the other hand, you should not overly constrain the running of your threads by some unnecessary synchronizations. Possible parallelism in the hardware you will use to run your program should be exploited as much as possible. What type of parallelism you employed in your program to get the result? And at which points do you need to synchronize your threads, including the main thread? An example input file for a 4x4 matrix: 23 99 21 56 4 1 22 67 876 0 9 43 126 100 999 86

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

Professional SQL Server 2000 Database Design

Authors: Louis Davidson

1st Edition

1861004761, 978-1861004765

More Books

Students also viewed these Databases questions

Question

Explain how cultural differences affect business communication.

Answered: 1 week ago

Question

List and explain the goals of business communication.

Answered: 1 week ago