logo

Crowdly

Browser

Додати до Chrome

For this question, refer to the following code: mutex_t m; int slot = -1; int ...

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

For this question, refer to the following code:

mutex_t m;

int slot = -1;

int array[2] = { 0, 0 }; // initialize to 0, 0 contents

function1() {

mutex_acquire(&m);

slot++;

int tid = get_counter();

array[slot] = tid;

mutex_release(&m);

}

Assume that get_counter() has its own internal locking (not shown), and will return 1 when first called, and 2 when called next, etc. Assume that function1() is called by two threads at roughly the same time. What are the final contents of the array?

0%
0%
0%
0%
0%
Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на moodle31.upei.ca?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!

Browser

Додати до Chrome