Modify this code to use multiple threads with the same data
1. Modify the main function to imp...
![Computers and Technology](/tpl/images/cats/informatica.png)
Computers and Technology, 11.02.2020 22:07, dianasmygova
Modify this code to use multiple threads with the same data
1. 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.
2. 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
3.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).
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.
#include
#include
using namespace std;
void *routineName(void *arg)
{
// TODO: Add code that implements
// the thread's functionality
cout << "Thread is running..." << endl;
return 0;
}
int main()
{
pthread_t id;
int rc;
int ints;
for(int x; x<10; x++)
{
cout << "Enter Integer: " < cin >>
}
rc = pthread_create(&id, NULL, routineName, NULL);
if (rc){
cout << "ERROR; return code from pthread_create() is " << rc << endl;
return -1;
}
pthread_exit(0);
}
![answer](/tpl/images/cats/otvet.png)
Answers: 2
Other questions on the subject: Computers and Technology
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 22.06.2019 15:10, AleciaCassidy
Consider a direct-mapped cache with 216 words in main memory. the cache has 16 blocks of 8 words each. it is a word-addressable computer (rather than a byte-addressable computer which we normally discuss). (a) how many blocks of main memory are there? (b) what is the format of a memory address as seen by the cache, that is, what are the sizes of the tag, cache block, and block offset fields (if they apply)? (c) to which cache block will the memory reference db6316 map?
Answers: 1
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 11:20, tiffanibell71
Colby works as a shipping clerk for a major package delivery service. some of his daily tasks include tracking shipments and entering orders. which aspect of the information technology cluster would he most likely be trained in? a. networkingb. databasesc. hardwared. software
Answers: 2
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 20:20, isaiahromero15
Write python code that prompts the user to enter his or her favorite color and assigns the userβs input to a variable named color.
Answers: 1
Do you know the correct answer?
Questions in other subjects:
![Konu](/tpl/images/cats/istoriya.png)
History, 09.01.2020 23:31
![Konu](/tpl/images/cats/mat.png)
![Konu](/tpl/images/cats/mat.png)
Mathematics, 09.01.2020 23:31
![Konu](/tpl/images/cats/mat.png)
Mathematics, 09.01.2020 23:31
![Konu](/tpl/images/cats/en.png)
English, 09.01.2020 23:31
![Konu](/tpl/images/cats/obshestvoznanie.png)
Social Studies, 09.01.2020 23:31
![Konu](/tpl/images/cats/en.png)
![Konu](/tpl/images/cats/fizika.png)
Physics, 09.01.2020 23:31
![Konu](/tpl/images/cats/istoriya.png)
History, 09.01.2020 23:31