subject
Computers and Technology, 20.02.2020 02:03 Yuii

A file named pthread-data-sharing-mutex. cpp
has been provided to you in the same project.

Compile the program and execute it several times, at least 10. Make sure to pay close attention to the output that the program produces.

Create a Word or Google Docs document.

In this document, answer the following questions about the program’s behavior:

1. What does it do?

2. What output does it produce?

3. Examine the program code carefully. Is the program functioning correctly?

4. If you do not think that the program is working correctly, describe why?

Include one screenshot of the program’s output. Your choice.

#include
#include

int count;

void* myFunction(void* arg)
{
int actual_arg = *((int*) arg);

for(unsigned int i = 0; i < 10; ++i) {
count++;
std::cout << "Thread #" << actual_arg << " count = " << count << std::endl;
}

pthread_exit(NULL);
}

int main()
{
int rc[2];
pthread_t ids[2];
int args[2];

count = 0;
for(unsigned int i = 0; i < 2; ++i) {
args[i] = i;
rc[i] = pthread_create(&ids[i], NULL, myFunction, (void*) &args[i]);
}

for(unsigned int i = 0; i < 2; ++i) {
pthread_join(ids[i], NULL);
}

std::cout << "Final count = " << count << std::endl;
pthread_exit(NULL);
}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 01:00, kmsg2000
Program description: a c# app is to be created to produce morse code. the morse code assigns a series of dots and dashes to each letter of the alphabet, each digit, and a few special characters (such as period, comma, colon, and semicolon). in sound-oriented systems, the dot represents a short sound and the dash represents a long sound. separation between words is indicated by a space, or, quite simply, the absence of a dot or dash. in a sound-oriented system, a space is indicated by a short period of time during which no sound is transmitted. the international version of the morse code is stored in the data file morse. txt.
Answers: 3
image
Computers and Technology, 23.06.2019 09:00, vetterk1400
Design a class tictactoe that: holds the following information about the game: two-dimensional array (3 by 3), and winner. add additional variables as needed. includes the functions to perform the various operations on objects. for example, function to print the board, getting the move, checking if move is valid, determining if there is a winner after each move. add additional operations as needed. includes constructor(s). write the functions of the class, and write a program that uses the class. the program should declare an object of type tictactoe. the program will create the board and store it in the array. the program will allow two players to play the tic-tac-toe game. after every valid move update the array, check if there is a winner. if there is no winner and no tie, then print the board again to continue.
Answers: 2
image
Computers and Technology, 23.06.2019 11:00, jolleyrancher78
What are the possible consequences of computer hacking? what is computer piracy? describe some examples. what are the effects of computer piracy? what are the possible consequences of computer piracy? what is intentional virus setting? describe some examples. what are the effects of intentional virus setting? what are the possible consequences of intentional virus setting? what is invasion of privacy? describe some examples. what are the effects of invasion of privacy? what are the possible consequences of invasion of privacy? what is an acceptable use policy and what is the purpose of the acceptable use policy what is intellectual property and how can you use it?
Answers: 1
image
Computers and Technology, 23.06.2019 11:30, kyraj21
Which excel file extension stores automated steps for repetitive tasks?
Answers: 1