logo

Crowdly

2025W Operating Systems (CS-3520-01)

Шукаєте відповіді та рішення тестів для 2025W Operating Systems (CS-3520-01)? Перегляньте нашу велику колекцію перевірених відповідей для 2025W Operating Systems (CS-3520-01) в moodle31.upei.ca.

Отримайте миттєвий доступ до точних відповідей та детальних пояснень для питань вашого курсу. Наша платформа, створена спільнотою, допомагає студентам досягати успіху!

In our working producer and consumer solutions with a single buffer slot using condition variables, we used two condition variables. Why was the second condition variable necessary?

Переглянути це питання
In our working producer and consumer solutions with a single buffer slot using condition variables, we made the producer check that count was 0 in a while loop and the consumer similarly check that it was 1 in a while loop. Why is a while loop necessary here instead of an if statement?
Переглянути це питання
Which of the following is NOT one of the four conditions that must be met for deadlock to occur?
Переглянути це питання

When using a semaphore as a lock as in the code snippet below, what value should the semaphore be initialized too (i.e., what should X be)?

1 sem_t m;

2 sem_init(&m, 0, X);

3

4 sem_wait(&m);

5 //critical section here

6 sem_post(&m);

Переглянути це питання

The code for our reader-writer lock from class/the textbook is shown below. What is the main disadvantage of this code?

typedef struct _rwlock_t {

sem_t lock; // binary semaphore (basic lock)

sem_t writelock; // used to allow ONE writer or MANY readers

int readers; // count of readers reading in critical section

} rwlock_t;

void rwlock_init(rwlock_t *rw) {

rw->readers = 0;

sem_init(&rw->lock, 0, 1);

sem_init(&rw->writelock, 0, 1);

}

void rwlock_acquire_readlock(rwlock_t *rw) {

sem_wait(&rw->lock);

rw->readers++;

if (rw->readers == 1)

sem_wait(&rw->writelock); // first reader acquires writelock

sem_post(&rw->lock);

}

void rwlock_release_readlock(rwlock_t *rw) {

sem_wait(&rw->lock);

rw->readers--;

if (rw->readers == 0)

sem_post(&rw->writelock); // last reader releases writelock

sem_post(&rw->lock);

}

void rwlock_acquire_writelock(rwlock_t *rw) {

sem_wait(&rw->writelock);

}

void rwlock_release_writelock(rwlock_t *rw) {

sem_post(&rw->writelock);

}

Переглянути це питання

When the value of a semaphore is negative what does this number indicate?

Переглянути це питання

Which of the following is true about the advantages and disadvantages of using pthread_cond_broadcast() over pthread_cond_signal()?

Переглянути це питання

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

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