Given the following environment

#include

int data;
pthread_mutex_t mutex;

int main()
{
data = 0;
pthread_mutex_init(&mutex, NULL);

// Code Fragment Goes Here

return 0;
}

Write a code fragment that locks the mutex, increments the value of data by 1 and then unlocks the mutex.


pthread_mutex_lock(&mutex);
data++;
pthread_mutex_unlock(&mutex);

Computer Science & Information Technology

You might also like to view...

The Notes pane is located above the Slide pane and is an area where you can type notes and additional information.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Mixing red and green color shades in an incorrect way can cause color-blind people to struggle with the text.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

?Instead of using a password that you have to type in, Windows allows you to use a ____ password instead.

A. ?linked B. ?picture C. ?static D. ?dynamic

Computer Science & Information Technology

The concept of _________ allows for the limited use of copyrighted material without obtaining permission from the copyright holder.

A. fair use B. open source C. public domain D. Creative Commons

Computer Science & Information Technology