Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C language. First part. Answer with proof. Attach screenshot otherwise I will not accept it. We want you to write a multi-theard program in C

C language. First part. Answer with proof. Attach screenshot otherwise I will not accept it.

image text in transcribed

We want you to write a multi-theard program in C to perform a simple matrix operation. The requirement is very simple; your program should read a square matrix of integers from a text file (here is an example file), place it in an appropriate data structure, and calculate the sum of all the numbers contained in the matrix. However, the calculation must be done in parallel by 4 different worker threads. You can think of your matrix as evenly divided into 4 sections (northwest, northeast, southwest, southeast). You can also assume that the number of rows and, since it's a square matrix, the number of columns is an integer power of 2. In order to get the final result in your program, the results of each of the worker threads must be combined, ie aggregated. Meanwhile, the main thread should calculate the same sum and compare its own result with the total result from the threads. Finally, it should produce a simple output that indicates whether the result is correct. You should implement an appropriate synchronization mechanism where necessary. On the other hand, you should not unnecessarily restrict the running of your threads with unnecessary synchronizations. The possible parallelism in the hardware you will use to run your program should be utilized as much as possible. What kind of parallelism did you use in your program to achieve the result? And at what points did you need to synchronize your threads, including the main thread? Example of input file for a 4x4 matrix: 23 21 43 126 56 48 1 22 67 76 0 9 99 1004 999 86 a Let's say that the slightly changed version of the program given in the above question is very important for a company and is run continuously. The only difference is that the main thread is not expected to check the sum, it just prints the sum resulting from the running of the worker threads. Due to some legal requirements that are beyond your scope and you cannot change, you only have to run one instance of this program at a time. Another run of the app can only be started after the previous run has finished its job. That is, your application is not allowed to run parallel on two or more separate terminals. You can always assume there is some matrix data to process, no shortage of matrix. There are too many matrices to keep your program busy all the time and are waiting on disk. The firm only wants to purchase a dedicated physical (or virtual) server to run this program. You are requested to make a suggestion on the number of cores required in the server to be purchased and the user to kernel thread mapping strategy from the user to be used in the operating system that will run on it. They want the solution to be optimized as much as possible, all purchased CPU cores should be kept as busy as possible. If they are convinced that each CPU will be busy doing useful work throughout the day, they are willing to increase the number of CPU cores. The stage of reading the matrices from the disk will not take much time compared to the calculation phase, as they already have an SSD-type ultra-high-speed disk that they will connect to the server and use. The matrices are huge and doing the calculations will take much more time than reading them from the SSD unit. (You might think that the calculation for this question is a much more comprehensive statistical operation, not simple addition). a. How many cores CPU would you recommend on a server that will be used to run this application? Why? b. What kind of user-to-core thread mapping strategy would you recommend within the OS to be installed on this server? Why

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_2

Step: 3

blur-text-image_3

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

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

Explain the factors that determine the degree of decentralisation

Answered: 1 week ago

Question

What Is acidity?

Answered: 1 week ago

Question

Explain the principles of delegation

Answered: 1 week ago

Question

State the importance of motivation

Answered: 1 week ago

Question

Discuss the various steps involved in the process of planning

Answered: 1 week ago