✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.
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++;
mutex_release(&m);
int tid = get_counter();
mutex_acquire(&m);
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?
Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!