Question
A multi-theard program in C for performing a simple matrix operation we want you to write it down. The requirement is very simple; your program
A multi-theard program in C for performing a simple matrix operation we want you to write it down. The requirement is very simple; your program consists of integers from a text file it should read a square matrix consisting of (there is a sample file below), have a suitable data structure it should be placed and calculate the sum of all the numbers contained in the matrix. But the calculation process it should be done in parallel by 4 different worker threads. Divide your matrix equally into 4 parts you might think that it is divided into (northwest, northeast, southwest, southeast). Also the line the number of columns is an exact force of 2, and because it is a square matrix, the number of columns is you can assume. To achieve the final result in your program, you need to use each of the worker threads their results should be combined, that is, summed up. By the way, the main thread also decouples the same sum he must calculate and compare the result he finds himself with the total result from the threads. Last as a result, it should produce a simple output that indicates whether the result obtained is true or not. Required in places, you must implement an appropriate synchronization mechanism. On the other hand, it is unnecessary you should also not unnecessarily restrict the operation of your threads with synchronizations. Your Program as far as possible from the possible parallelism in the hardware that you will use to run should be used. What kind of parallelism did you use in your program to get the result? And the main thread is also included at what points did you have to synchronize your threads, including? an example of an input file for a 4x4 matrix:
23 21 43 126 56 4 1 22 67 876 0 9 99 100 999 86
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered 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