chapter 5: Process Synchronization Flashcards

1
Q

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

A

B- RESULTS WHEN SEVERAL THREADS TRY TO ACCESS AND MODIFY THE SAME DATA CONCURRENTLY

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

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

A

B- EXECUTES AS A SINGLE, UNINTERRUPTIBLE UNIT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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

A- IS ESSENTIALLY AN INTEGER VARIABLE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A

C- DOES NOT REQUIRE A CONTEXT SWITCH WHEN A PROCESS MUST WAIT ON A LOCK

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
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]
A

C- flag[i]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A

C- REQUIRES THAT NO READER WILL BE KEPT WAITING UNLESS A WRITER HAS ALREADY OBTAINED PERMISSION TO USE THE SHARED DATABASE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
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
A

D- MONITOR

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

A- MASKS INTERRUPTS FOR ALL INTERRUPT HANDLERS THAT MAY ALSO ACCESS THE VARIABLE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
A transaction \_\_\_\_.
A) performs multiple logical functions 
B) is a single instruction 
C) is a single operation
D) performs a single logical function
A

D- PERFORMS A SINGLE LOGICAL FUNCTION

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
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
A

D- SERIAL SCHEDULE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What three conditions must be satisfied in order to solve the critical section problem?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Explain two general approaches to handle critical sections in operating systems

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Explain what has to happen for a set of processes to achieve a deadlocked state

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Explain the difference between the first readers-writers problem and the second readers-writers problem

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Describe the dining-philosophers problem and how it relates to operating systems.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How can write-ahead logging ensure atomicity despite the possibility of failures within a computer system?

A

Write-ahead logging records information describing all the modifications made by the transaction to the various data it accessed. Each log record describes a single operation of a transaction write. Upon a failure of the computer system, the log can be used to recover using both undo and redo procedures

17
Q

What overheads are reduced by the introduction of checkpoints in the log recovery system?

A

Whenever a system failure occurs, the log, if checkpoints are not included, must be consulted in its entirety to determine those transactions that need to be redone and undone. The entire log must be processed to make these determinations. This is time consuming. Most of the transactions that are redone are also not necessary due to idempotency. Checkpoints reduce both of these overheads.

18
Q

Describe the turnstile structure used by Solaris for synchronization.

A

Solaris uses turnstiles to order the list of threads waiting to acquire either an adaptive mutex or a reader-writer lock. The turnstile is a queue structure containing threads blocked on a lock. Each synchronized object with at least one thread blocked on the object’s lock requires a separate turnstile. However, rather than associating a turnstile with each synchronized object, Solaris gives each kernel thread its own turnstile.

19
Q

Define the two-phase locking protocol.

A

This protocol ensures serializability through requiring that each transaction issue lock and unlock requests in two phases: a growing phase and a shrinking phase. In the growing phase a transaction may obtain locks but not release a lock whereas the shrinking phase allows the release of locks but not the obtaining of new locks. Initially, a transaction is in the growing phase.

20
Q

T OR F:

Race conditions are prevented by requiring that critical regions be protected by locks

A

TRUE

21
Q

T OR F:

The value of a counting semaphore can range only between 0 and 1

A

FALSE

22
Q

T OR F:

A deadlock-free solution eliminates the possibility of starvation.

A

FALSE

23
Q

T OR F:

The local variables of a monitor can be accessed by only the local procedures.

A

TRUE

24
Q

T OR F:

Every object in Java has associated with it a single lock.

A

TRUE