Ch. 4 - Synchronization Flashcards

(27 cards)

1
Q

Hardware Parallelism

A

CPU computing, one or more I/O devices are running at the same time.

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

Pseudo Parallelism

A

Rapid switching back and forth of the CPU among processes, pretending that those processes run concurrently.

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

What are the properties of cooperating processes?

A

Processes share a common object
Non-deterministic results
May be irreproducible
Subject to race conditions

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

Why is cooperation between processes desirable?

A

Allows for resource sharing
Faster execution time
Allows for systems to be constructed in a modular fashion

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

Why do cooperating processes run faster than competing processes?

A

Jobs can be divided into smaller pieces and executed concurrently (since the processes will synchronize)

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

Race Condition

A

Situation where two or more processes access shared data concurrently and correctness is not guaranteed due to different results from different orderings of operations.

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

Mutual Exclusion

A

Ensures that only one process can modify shared data at a time. Other processes cannot modify shared data until the current process finishes

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

Critical Section (CS)

A

A section of code where only one process may be executing at a given time. This code is executed sequentially.

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

True or False: It does not hurt to have a long critical section as long as the critical section is guaranteed to finish.

A

False. A critical section should be as short as possible to minimize runtime of the program. Reaching the end of a critical section cannot be guaranteed due to interrupts.

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

What fundamental requirements must be met by concurrent processes in order to cooperate correctly and efficiently?

A

Mutual Exclusion
Progress
Fault Tolerance
No assumptions made about speed or number of processors
Efficiency (short CS, no blocking)

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

Progress (Fundamental Requirement)

A

A process wishing to enter its CS will eventually do so in finite time.

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

Fault Tolerance (Fundamental Requirement)

A

Processes failing outside their CS should not interfere with others accessing their own CS

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

Semaphore

A

Synchronization variable that takes on a non-negative integer with only two atomic operations: P(semaphore), V(semaphore)

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

Why is disabling interrupts a bad solution to preventing a process being interrupted in its critical section?

A

Users cannot disable interrupts (privileged instruction) and the CPU cannot service mission critical tasks if interrupts are disabled. This leads to a system that is unreliable and lower system performance.

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

Why is a test and set (TAS) instruction desirable to use to achieve mutual exclusion? Are there any drawback(s)?

A

Since TAS can read, write, and store a word atomically, it is not interruptible.
Only 1 guard variable is needed per critical section
Works for n processes

Yes, a drawback is that there is busy waiting

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

P(semaphore)

A

while (semaphore) == 0); //wait until semaphore incremented
decrement semaphore

17
Q

V(semaphore)

A

Increment semaphore

18
Q

What are 3 possible uses for semaphores?

A
  1. Mutual Exclusion (initialize semaphore to 1)
  2. Signalling (initialize semaphore to 0)
  3. Counting (initialize semaphore to n >= 2)
19
Q

Log-based Recovery

A

Record transaction to service in log file before the transaction actually happens. Not practical for large databases (huge log file would be the result).

20
Q

Checkpoints

A

Save the state before the transaction. In the case of a crash, restore the state before the transaction. However, this adds extra overhead if transaction is complex.

21
Q

What are some properties that make semaphores an attractive implementation of synchronization?

A

Single Resource Serialization
Can have many different CS’s with different semaphores
Can permit multiple processes into 1 CS if desirable (counting semaphores)

22
Q

What is a drawback of using semaphores?

A

They are unstructured (i.e. the programmer is responsible for using P and V correctly)

23
Q

Monitor

A

High-level abstraction that combines and hides:
shared data
operations on the data
synchronization with condition variables

24
Q

Serializability

A

The outcome of the concurrent execution of atomic transactions is equivalent to the sequential execution of the same transactions in any arbitrary order.

25
Monitor Equivalent to V() (for condition variable x)
x.signal()
26
Monitor Equivalent to P() (for condition variable x)
x.wait()
27
If a transaction is aborted (terminated unsuccessfully), what must occur?
The transaction must be rolled back to its state before the transaction started.