Question: b . Consider the program below, where represents code that updates a shared data structure. ` ` ` void * thread _ func

b. Consider the program below, where "" represents code that updates a shared data structure.
```
void *thread_func(void *arg){
pthread_mutex_t mymutex;
int rv = pthread_mutex_init(&mymutex,NULL); // default attributes
...
rv = pthread_mutex_lock(&mymutex);
assert(!rv);
// critical section
rv = pthread_mutex_unlock(&mymutex);
assert(!rv);
...
return NULL;
}
```
The main program creates and executes 4 threads running thread_func(). What is wrong with the above code? (Hint: it has nothing to do with the variable rv or the call to assert.)
b . Consider the program below, where " "

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 Programming Questions!