logo

Crowdly

Browser

Додати до Chrome

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?

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

When using a semaphore to ensure the child thread runs before the parent executes further as in the code snippet below, what value should the semaphore be initialized too (i.e., what should X be)?

sem_t s;

void *child(void *arg) {

printf("child");

sem_post(&s); // signal here: child is done

return NULL;

}

int main(int argc, char *argv[]) {

sem_init(&s, 0, X); // what should X be?

printf("parent: begin");

pthread_t c;

pthread_create(c, NULL, child, NULL);

sem_wait(&s); // wait here for child

printf("parent: end");

return 0;

}

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

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);

}

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

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

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

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);

Переглянути це питання
Which of the following is NOT one of the four conditions that must be met for deadlock to occur?
0%
0%
0%
0%
0%
Переглянути це питання

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

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

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

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

Browser

Додати до Chrome