logo

Crowdly

2025W Operating Systems (CS-3520-01)

Looking for 2025W Operating Systems (CS-3520-01) test answers and solutions? Browse our comprehensive collection of verified answers for 2025W Operating Systems (CS-3520-01) at moodle31.upei.ca.

Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!

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?

View this question

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?

View this question

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?

View this question

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?

View this question
Consider a system that has a 30-bit address space and 512 byte pages (assume PTEs and PDEs are each 4 bytes). Why should we use more than two levels for the page table?
View this question

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

0%
0%
0%
0%
View this question
Which of the following is not an advantage of multi-level page tables over linear page tables?
View this question

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?

0%
0%
0%
0%
View this question
What page is the virtual address 110110 (in binary) in if we assume the address space is divided into four 16 byte pages (page 0 to page 3)?
View this question
Consider a system that has a 16KB address space and 64 byte pages. How many pages are required to store the address space?
View this question

Want instant access to all verified answers on moodle31.upei.ca?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!