Question: help on this thank you. (will upvote! ) ------------------------------------------------------------------------------------------------------------------------------------------------------- code: // pthreads_p2.cpp skeleton //C++ #include #include using namespace std; // use this skeleton for any

help on this thank you.

(will upvote!)

-------------------------------------------------------------------------------------------------------------------------------------------------------

 help on this thank you. (will upvote!) ------------------------------------------------------------------------------------------------------------------------------------------------------- code: //pthreads_p2.cpp skeleton

//C++ #include #include using namespace std; // use this skeleton for any

code:

//pthreads_p2.cpp skeleton

//C++

#include #include

using namespace std;

// use this skeleton for any pthread function // you need to define. // In the copy, modify the name of the function // and the function body as needed.

void *routineName(void *arg) { // TODO: Add code that implements // the thread's functionality cout

int main() { // id is used to store a unique thread identifier, // returned by the call to create a new POSIX thread pthread_t id; // rc is used to store the code returned by the // call to create a new POSIX thread. The value is // zero (0) if the call succeeds. int rc; // TODO: Add code to perform any needed initialization // or to process user input

// Create thread(s) // TODO: Modify according to assignment requirements rc = pthread_create(&id, NULL, routineName, NULL);

if (rc){ cout

// NOTE: Using exit here will immediately end execution of all threads pthread_exit(0); }

//end, please follow the skeleton code, and follow instructions. please post your inputs and output picture to show there's no errors and output is correct....

----------------------------------------------------------------------------- thank you!

1. Make a copy of the pthreads_skeleton.cpp program and name it pthreads_p2.cpp 2. Modify the main function to implement a loop that reads 10 integers from the console (user input) and stores these numbers in a one-dimensional (1D) array (this code will go right after the comment that says "Add code to perform any needed initialization or to process user input'). You should use a global array for this. 3. Implement a separate pthread function function for each one of the following operations: a. Count and print out how many of the entered numbers are negative. This function must be named countNegatives b. Calculate and print the average value of all the numbers entered. This function must be named average c. Print the numbers in reverse order from the order in which they were entered. This function must be named reverse 4. Modify the main function to create one pthread for each one of the functions that you implemented in (3) above (this code will go between the comment that says "TODO: Modify according to assignment requirements" and the "if (rc) check). 5. Compile your program and run it several times. If the output of your program is garbled, you may need to add a small delay in between creating the next thread. One simple way to do this is to add a loop that performs a count, such as the one below: for (int count = 0; count

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!