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 semaphore is accessed through a set of operations known as wait (P) and signal (V) operations.
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
Unlike other lock mechanisms, such as mutexes or semaphores, spinlocks do not cause the waiting thread to block or sleep when it encounters a locked state. Instead, the thread repeatedly checks the lock in a tight loop (known as spinning) until it becomes available.
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
Primitives are typically atomic and have well-defined behavior and representation. They are often implemented at a low level in the hardware or as built-in features in programming languages.
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
A monitor is a synchronization construct in concurrent programming that provides mutual exclusion for a set of programmer-defined operations. It ensures that only one thread can execute the critical section of code within the monitor at any given time, preventing concurrent access and potential race conditions.
Mutual exclusion is a concept in computer science and concurrent programming that ensures that only one process or thread can access a shared resource or critical section at a time.
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
This is done to ensure that no interrupt handler interrupts the access to the global variable, maintaining data consistency and preventing race conditions.
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 transaction is a logical unit of work that consists of one or more database operations. It represents a sequence of operations that should be treated as a single, indivisible entity.
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
An execution order in which transactions are executed one after another, without any overlap or concurrency. In a serial schedule, each transaction is executed in its entirety before the next transaction begins.
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. If no process is currently executing in the critical section and some processes are requesting access to it, the selection of the process that will enter the critical section next should be determined in a fair and non-biased manner. This condition ensures that processes are not indefinitely blocked from entering the critical section and that progress is made.
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. There must be an upper limit or bound on the number of times other processes can enter the critical section after a process has made a request to enter it. This condition guarantees that no process is indefinitely postponed from entering the critical section, preventing starvation or indefinite blocking
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.