Шукаєте відповіді та рішення тестів для 2025W Operating Systems (CS-3520-01)? Перегляньте нашу велику колекцію перевірених відповідей для 2025W Operating Systems (CS-3520-01) в moodle31.upei.ca.
Отримайте миттєвий доступ до точних відповідей та детальних пояснень для питань вашого курсу. Наша платформа, створена спільнотою, допомагає студентам досягати успіху!
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?
The following C code was our first attempt to make a lock using a flag to indicate if the lock was acquired.
typedef struct __lock_t { int flag; } lock_t;
void init(lock_t *mutex) {
mutex->flag = 0;
}
void lock(lock_t *mutex) {
while (mutex->flag == 1) // TEST the flag
; // spin-wait (do nothing)
mutex->flag = 1; // now SET it !
}
void unlock(lock_t *mutex) {
mutex->flag = 0;
}
How will this code perform in terms of correctness and efficiency?
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?
Consider the following code to initialize the concurrent Michael and Scott Queue from class.
void Queue_Init(queue_t *q) {
node_t *tmp = malloc(sizeof(node_t));
tmp->next = NULL;
q->head = q->tail = tmp;
pthread_mutex_init(&q->headLock, NULL);
pthread_mutex_init(&q->tailLock, NULL);
}
Why does an empty queue have a node allocated?
Consider a system that has a 16KB address space and 64 byte pages in a two-level and that the page directory and the page table with entries as in the image below (taken from OSTEP ch. 20, Figure 20.5).
Translate the virtual address 0x0178 to a physical address
Consider a system that has a 16KB address space and 64 byte pages in a two-level and that the page directory and the page table with entries as in the image below (taken from OSTEP ch. 20, Figure 20.5). Suppose also that PTEs and PDEs are 4 bytes each.
How much less memory is used for storing the multi-level page table, compared to a linear page table?
Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!