Question: Programming Part 1: Write a program in C or Java that takes the integer 1 billion (1,000,000,000) from the command line or from user input.
Programming Part 1:
Write a program in C or Java that takes the integer 1 billion (1,000,000,000) from the command line or from user input. Once the data is input program three threads to:
- Child Thread 1:
- Displays its ID
- Find incremental sum of all the numbers until and including 1,000,000,000
- Exit itself once completed the operation
- Child Thread 2:
- Displays its ID
- Find incremental sum of all the even numbers until and including 1,000,000,000
- Exit itself once completed the operation
- Parent / Main Thread:
- Displays its ID
- Creates Child Threads 1 and 2
- Merges Child Thread 1 and 2
- Displays the sum of all the numbers returned by Child Thread 1
- Displays the sum of all the numbers returned by Child Thread 2
- Calculates the following:
- sum of all the numbers returned by Child Thread 1 / sum of all the numbers returned by Child Thread 2
- Displays the result of above calculation
Analysis Part 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, please make sure the calculations made by the program are correct and accurate.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
