chapter 5: Process Synchronization Flashcards
A race condition ____.
A) results when several threads try to access the same data concurrently
B) results when several threads try to access and modify the same data concurrently
C) will result only if the outcome of execution does not depend on the order in which instructions are executed
D) None of the above
B- RESULTS WHEN SEVERAL THREADS TRY TO ACCESS AND MODIFY THE SAME DATA CONCURRENTLY
An instruction that executes atomically ____.
A) must consist of only one machine instruction
B) executes as a single, uninterruptible unit
C) cannot be used to solve the critical section problem
D) All of the above
B- EXECUTES AS A SINGLE, UNINTERRUPTIBLE UNIT
A semaphore ____.
A) is essentially an integer variable
B) is accessed through only one standard operation
C) can be modified simultaneously by multiple threads
D) cannot be used to control access to a thread’s critical sections
A- IS ESSENTIALLY AN INTEGER VARIABLE
A spinlock ____.
A) is never advantageous
B) will ultimately result in a context switch when a process must wait on a lock
C) does not require a context switch when a process must wait on a lock
D) is useful when locks are expected to be held for long amounts of time
C- DOES NOT REQUIRE A CONTEXT SWITCH WHEN A PROCESS MUST WAIT ON A LOCK
In Peterson’s solution, the \_\_\_\_ variable indicates if a process is ready to enter its critical section. A) turn B) lock C) flag[i] D) turn[i]
C- flag[i]
The first readers-writers problem ____.
A) requires that, once a writer is ready, that writer performs its write as soon as possible.
B) is not used to test synchronization primitives.
C) requires that no reader will be kept waiting unless a writer has already obtained permission to use the shared database.
D) requires that no reader will be kept waiting unless a reader has already obtained permission to use the shared database
C- REQUIRES THAT NO READER WILL BE KEPT WAITING UNLESS A WRITER HAS ALREADY OBTAINED PERMISSION TO USE THE SHARED DATABASE
A(n) \_\_\_ type presents a set of programmer-defined operations that are provided mutual exclusion within it. A) transaction B) signal C) binary D) monitor
D- MONITOR
Windows XP, when accessing a global variable on a uniprocessor system, ____.
A) masks interrupts for all interrupt handlers that may also access the variable
B) uses spinlocks
C) uses an adaptive mutex scheme
D) uses mutex locks
A- MASKS INTERRUPTS FOR ALL INTERRUPT HANDLERS THAT MAY ALSO ACCESS THE VARIABLE
A transaction \_\_\_\_. A) performs multiple logical functions B) is a single instruction C) is a single operation D) performs a single logical function
D- PERFORMS A SINGLE LOGICAL FUNCTION
A schedule in which each transaction is executed atomically is called a(n) \_\_\_\_. A) exclusive schedule B) conflicting operation C) nonserial schedule D) serial schedule
D- SERIAL SCHEDULE
What three conditions must be satisfied in order to solve the critical section problem?
1- No thread may be executing in its critical section if a thread is currently executing in its critical section.
2- Only those threads that are not executing in their critical sections can participate in the decision on which process will enter its critical section next.
3- A bound must exist on the number of times that other threads are allowed to enter their critical state after a thread has made a request to enter its critical state.
Explain two general approaches to handle critical sections in operating systems
Critical sections may use preemptive or nonpreemptive kernels. A preemptive kernel allows a process to be preempted while it is running in kernel mode. A nonpreemptive kernel does not allow a process running in kernel mode to be preempted; a kernel-mode process will run until it exits kernel mode, blocks, or voluntarily yields control of the CPU. A nonpreemptive kernel is essentially free from race conditions on kernel data structures, as the contents of this register will be saved and restored by the interrupt handler.
Explain what has to happen for a set of processes to achieve a deadlocked state
For a set of processes to exist in a deadlocked state, every process in the set must be waiting for an event that can be caused only be another process in the set. Thus, the processes cannot ever exit this state without manual intervention.
Explain the difference between the first readers-writers problem and the second readers-writers problem
The first readers-writers problem requires that no reader will be kept waiting unless a writer has already obtained permission to use the shared database whereas the second readers-writers problem requires that, once a writer is ready, that writer performs its write as soon as possible.
Describe the dining-philosophers problem and how it relates to operating systems.
The scenario involves five philosophers sitting at a round table with a bowl of food and five chopsticks. Each chopstick sits between two adjacent philosophers. The philosophers are allowed to think and eat. Since two chopsticks are required for each philosopher to eat and only five chopsticks exist at the table, no two adjacent philosophers may be eating at the same time. A scheduling problem arises as to who gets to eat at what time. This problem is similar to the problem of scheduling processes that require a limited number of resources.