M7: Concurrency Control and Synchronization Flashcards

1
Q

Test-and-set lock:

A

a hardware instruction that locks memory locations while they are being accessed by a process.

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

Race condition

A

the system attempts to perform two or more operations at the same time, but due to the underlying context switching and scheduling implementations by the OS, the ordering of these operations is not guaranteed. The result of the operations changes as a function of changes in ordering.

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

Semaphore

A

a semaphore is a kernel object with an integer value. It supports two operations, P and V, which modify the integer value.
○ P : One of the operations of a semaphore. If the semaphore’s value is greater than zero, decrement. Otherwise, wait until the value is greater than zero and then decrement. Sometimes it is also called wait.
○ V : One of the operations of a semaphore. Increment the value of the semaphore. Sometimes it is also called signal or post.

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

Binary semaphore

A

a semaphore that saturates at an integer value of

1 -> Mutex

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

Counting semaphore:

A

semaphore that saturates as an integer value

of N, for N greater than or equal to 1.

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

Waiting queue

A

processes or threads waiting to enter the critical section are notified, or “woken up”, when the process currently using the critical section exits. This strategy helps eliminate the need for busy waiting in the
semaphore implementation.

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

Deadlock :

A

two or more processes are waiting indefinitely for an event that can be caused by only one of the waiting processes.

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

Monitors

A

a high-level abstraction that provides a convenient and effective mechanism for process synchronization. Only one process may be active within the monitor at a time.

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

Condition variables

A

a primitive with two functions, wait and signal.
○ Wait : a condition variable function called by a process that waits for a condition to be true
○ Signal : a condition variable function that wakes up a process waiting on the condition to be true

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

Why is Busy Waiting Bad

A

1) Consume CPU resources
2) can lead to starvation if waiting process has higher prior in scheduler. Constantly running high prio process that just waits and consumes CPU time

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

Why does lost wake up problem arise

A

Race Condition. Going to sleep vs. wakeup signal

The buffer is empty and the consumer has just read count to see if it is 0. At that instant, the scheduler decides to stop running the consumer temporarily and start running the producer. The producer inserts an item in the buffer, increments count, and notices that it is now 1. Reasoning that count was just 0, and thus the consumer must be sleeping, the producer calls wakeup to wake the consumer up.
Unfortunately, the consumer is not yet logically asleep, so the wakeup signal is lost. When the consumer next runs, it will test the value of count it previously read, find it to be 0, and go to sleep. Sooner or later the producer will fill up the buffer and also go to sleep. Both will sleep forever

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

For what are binary semaphores/mutexes used

A

manage mutual exclusion, handle access to Critical Section

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

Potential approach to solve deadlock with semaphores

A

Impose hierarchy between resources. e.g. always pick resources in alphabetical order.

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

How is it possible that no context switch happens with semaphores given that involves several steps

A

operating system briefly disables all interrupts while it is testing the semaphore, updating it, and putting the process to sleep/waking up

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

How can Semaphores be protected if we are using multiple CPUs

A

each semaphore should be protected by a lock variable, to make sure that only one CPU at a time examines the semaphore

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