Question
Demonstrate the use of threading and provide an evidence of performance boost of the program using the built-in threading libraries. The task is two-folds. Below
Demonstrate the use of threading and provide an evidence of performance boost of the program using the built-in threading libraries. The task is two-folds. Below are the requirements for the task:
FOLD 1:
Write a program in C that takes (1,000,000,000) as an input (you are free to take this input from command line arguments or from the user). Once the input is taken, there should be 3 threads in your program performing the following operations:
1. Child Thread 1: a. Displays its ID b. Find incremental sum of all the numbers until and including 1,000,000,000 c. Exit itself once completed the operation 2. Child Thread 2: a. Displays its ID b. Find incremental sum of all the even numbers until and including 1,000,000,000 c. Exit itself once completed the operation 3. Parent / Main Thread: a. Displays its ID b. Creates Child Threads 1 and 2 c. Merges Child Thread 1 and 2 d. Displays the sum of all the numbers returned by Child Thread 1 e. Displays the sum of all the numbers returned by Child Thread 2 f. Calculates the following: -> sum of all the numbers returned by Child Thread 1 / sum of all the numbers returned by Child Thread 2 g. Displays the result of above calculation
Requirement 1: Analyze the time taken by the program to complete, e.g., review the usage of cores using Activity Monitor program in Ubuntu and find a way to monitor the time taken by the program to complete its execution. Furthermore, make sure, the calculations made by the program are correct and accurate. Do NOT forget to take a screenshot of the Activity Monitor.
FOLD 2:
Fold 2: Write a program in C that takes (1,000,000,000) as an input (you are free to take this input from command line arguments or from the user). Once the input is taken, the program should perform the following operations: A. Find incremental sum of all the numbers until and including 1,000,000,000 B. Find incremental sum of all the even numbers until and including 1,000,000,000 C. Display the sum of all the numbers until and including 1,000,000,000 D. Displays the sum of all the even numbers until and including 1,000,000,000 E. Calculates the following: -> sum of all the numbers in Step 1 / sum of all the numbers in Step 2 6. Displays the result of above calculation
Requirement 2: Analyze the time taken by the program to complete, e.g., review the usage of cores using Activity Monitor program in Ubuntu and find a way to monitor the time taken by the program to complete its execution. Do NOT forget to take a screenshot of the Activity Monitor.
Note: Compare the results obtained by the analysis of Requirement 1 and Requirement 2.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored 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