Question: Question 1 [50 points]: Implement a C solution to the following problem using the Pthreads POSIX Standard. Question 2: [50 points]: Implement a Java solution

Question 1 [50 points]: Implement a C solution to the following problem using the Pthreads POSIX Standard.

Question 2: [50 points]: Implement a Java solution to the following problem by defining a class that implements the Runnable interface.

Problem Description: Your task consists of implementing an efficient adder using threads. You will be given as input a large 2-D array of digits in which each row represents an integer, and asked to add these integers together, column by column. Each column addition will be executed by a different thread. The thread will be responsible for entering the unit value obtained from the addition of the column it is responsible for (say c) in a shared 1-D array, called Units, at position c as well as the carry value in an array called Carries, at position c-1. Once all the threads have completed their work, the digits in Units and integers (note: they can be larger than a single digit!) in Carries will be added from right to left and the final result printed. Here is an example on a small array to illustrate the process:

Question 1 [50 points]: Implement a C solution to the following problem

Note that the addition of Units and Carries in the last step, after all the threads have completed their part of filling the Units and Carries arrays can be tricky since there may be carries that need to be considered as illustrated in the larger example below:

using the Pthreads POSIX Standard. Question 2: [50 points]: Implement a Java

Here are all the instructions.

Input: 6943 9439 8888 9999 Units: 2049 Carries: 3 3 2 2 Final result: 3 5 2 6 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 9 Units: 8 8 8 Carries: 10 10 10 Final Result: 11 9 8 8

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 Databases Questions!