logo

Crowdly

Browser

Додати до Chrome

Questions Bank (1393117 total)

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 the value of a semaphore is negative what does this number indicate?

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

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

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

Identifique los conectores que le dan sentido al siguiente enunciado:

______ los Homo Sapiens fueron la única especie humana sobreviviente ______ a su capacidad lingüística.

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

Find the determinant of A if A =

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

Given the following matrix, find its transpose.

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

Es la expresión denotativa que se eufemiza en las palabras subrayadas en el siguiente fragmento: “ bien pudiera ser que cuando los sapiens se toparon con los neandertales el resultado fuera la primera y más importante campaña de limpieza étnica de la historia.”

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

Es la expresión con sentido connotativo que podría reemplazar el sentido denotativo de aquella que aparece subrayada en el fragmento “Aunque las diferencias entre ellos no eran suficientemente grandes para impedir por completo la cópula fértil, lo eran lo bastante para hacer que tales contactos fueran muy raros.”

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

En el fragmento “A las mujeres que parían antes, cuando el cerebro y la cabeza del niño eran todavía relativamente pequeños y flexibles, les fue mejor y vivieron para tener más hijos.”, la palabra subrayada se podría reemplazar por

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