Test 3 Review Quiz 2 - APUE Ch11 Sec6 IPC (100% correct)

Ace your homework & exams now with Quizwiz!

[APUE11.6] When multiple threads of control share the same memory, each thread should see a consistent view of its data. Which one of the following statements is NOT correct?

A variable which is read-only could create a consistency problem with more than one thread reading its value at the same time.

[APUE11.6] The condition is the state of the work queue. We protect the condition with a mutex and evaluate the condition in a while loop. When we put a message on the work queue, we need to hold the mutex, but we don't need to hold the mutex when we signal the waiting threads. As long as it is okay for a thread to pull the message off the queue before we call a signal, we can do this after releasing the mutex. Since we check the condition in a while loop, this doesn't present a problem; a thread will wake up, find that the queue is still empty, and go back to waiting again. If the code couldn't tolerate this race, we would need to hold the mutex when we signal the threads. This is about ____ mechanism.

conditional variable?

[APUE11.6] We can protect our data and ensure access by only one thread at a time by using the pthreads mutual-exclusion interfaces. A(n) ____ is basically a lock that we set (lock) before accessing a shared resource and release (unlock) when we're done.

mutex

[APUE11.6] A typical UNIX _____ can be thought of as having a single thread of control (that is, doing only one thing at a time).

process

[APUE11.6] One additional mutex primitive allows us to bound the time that a thread blocks when a mutex it is trying to acquire is already locked. The ____ function is equivalent to pthread_mutex_lock, but if the timeout value is reached, it will return the error code ETIMEDOUT without locking the mutex.

pthread_mutex_timedlock

[APUE11.6] A reader-writer lock is initialized by calling ____.

pthread_rwlock_init

[APUE11.6] To lock a reader-writer lock in read mode, we call ____.

pthread_rwlock_rdlock

[APUE11.6] Just as with mutexes, the Single UNIX Specification provides functions to lock reader-writer locks with a timeout to give applications a way to avoid blocking indefinitely while trying to acquire a reader-writer lock. One of these functions is _____.

pthread_rwlock_timedwrlock

[APUE11.6] _____ is called shared-exclusive lock. When it is read locked, it is said to be locked in shared mode. When it is write locked, it is said to be locked in exclusive mode.

reader-writer lock

[APUE11.6] At user level, ____ is not as useful unless you are running in a real-time scheduling class that doesn't allow preemption. User-level threads running in a time-sharing scheduling class can be descheduled when their time quantum expires or when a thread with a higher scheduling priority becomes runnable. In these cases, if a thread is holding ____, it will be put to sleep and other threads blocked on the lock will continue waiting longer than intended.

spinlock

[APUE11.6] ____ is useful when used in a nonpreemptive kernel: besides providing a mutual exclusion mechanism, they block interrupts so an interrupt handler can't deadlock the system by trying to acquire a spin lock that is already locked (think of interrupts as another type of preemption). In these types of kernels, interrupt handlers can't sleep, so the only synchronization primitives they can use are ____.

spinlock

[APUE11.6] Although implementations vary, reader-writer locks usually block additional readers if a lock is already held in read mode and a thread is blocked trying to acquire the lock in write mode. This prevents a constant stream of readers from ____ waiting writers.

starving


Related study sets

als, parkinsons, huntington disease, alzheimers practice questions

View Set

MTA Windows Server Administrator Study Guide

View Set

Research Methods Test #2 Chapters 6-9

View Set

Cognition-Chapter 10 Quiz-Visual Imagery

View Set

function and location of the veins and arteries

View Set

Biology- Prokaryotic and Eukaryotic Cells

View Set

Chapter 13: Retirement Plans and Education Savings Plans

View Set