Question
Write a C/C++ program that performs the tasks described below. If there is just 1 command-line argument and it is -hw you should simply print
Write a C/C++ program that performs the tasks described below.
If there is just 1 command-line argument and it is -hw you should simply print hello world and then exit(0).
Use pthreads to examine a range of integers *inclusive*. For each integer, compute its square root and then determine if the first digit after the decimal point is 7. For example: 127.677 # would NOT be counted 123.766 # would be counted ****
The program should accept 3 command-line arguments: low value (inclusive) high value (inclusive) number of pthreads *to create* to perform the computation
The mainline program should NOT participate in examining the range of integers. Instead, it should create the required number of threads and wait for them to complete the computation. It should then compute any final sum and print the results (see required format below).
--------
./p3 0 9000000000 2 ## sample run: 0 to 9 Billion (INCLUSIVE); 2 threads
alarm(90); // <--- **** make this the first executable line of your program// after 90 s the process will die
cc -Ofast -o p3 p3.c -lm -lpthread ## have the makefile use -Ofast
0long int // use long ints in place of normal ints at all places in the code
time1 // copy this function from the timedemo.c file to get the time
sample output (required format) from the above run: THREAD 0: 450006181// how many value 1st thread found THREAD 1: 449997048// 2nd thread value TOTAL 900003229// total of
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