Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Theory And Applications 27th Australasian Database Conference Adc 20 Sydney Nsw September 28 29 20 Proceedings Lncs 9877

Authors: Muhammad Aamir Cheema ,Wenjie Zhang ,Lijun Chang

1st Edition

3319469215, 978-3319469218

More Books

Students also viewed these Databases questions