Question: Homework C programming Given a list of size 20 consisting of natural numbers, write a multithreaded program for adding all the numbers in the list
Homework C programming
Given a list of size 20 consisting of natural numbers, write a multithreaded program for adding all the numbers in the list that works as follows: The list of numbers is divided into two smaller lists of equal size. A separate thread (which we will term as summing thread) adds numbers in each sublist.
Because global data are shared across all threads, the easiest way to set up the data is to create a global array. Each summing thread will work on one half of this array. This lab will require passing parameters to each of the summing threads. In particular, it will be necessary to identify the starting index from which each thread is to begin adding numbers.
- Refer to figure 4.11 on page 170 in the textbook 10th edition (chapter 4 Threads).
- The parent thread will output the sum once all summing threads have exited.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
