Concurrency control Flashcards

1
Q

What is the bounded-buffer/producer-consumer problem?

A

Process produces data, process consumes data.

Production and consumption rates may vary - shared buffer absorbs variations

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

What is the dining philosophers?

A

Share a round table, need two chopsticks to eat. Pick up closest chopstick one at a time, no-one eats = deadlock.

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

What is the Reader and writers problem?

A

DB shared between processes, in which one PS reads and the other writes. Reader may read partially written data.

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

What is a critical section?

A

Part of a program that accesses shared data.

Must ensure that only one process can be executing in a critical section at a given time.

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

How do we avoid race conditions?

A

Design a protocol for process cooperation.

lock
critical section
unlock

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

How can we avoid race conditions?

A
  • Atomic instructions
  • Interrupts
  • Kernel scheduler
  • Concurrency control mechanisms
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do Atomic Instructions help to avoid race conditions?

A

HW support for implementing lock, acquire lock on entry and release lock on exit

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

How do we prevent concurrency?

A

Single processor: Disable interrupts during wait and signal operations

Multiple processors: Secondary mutual exclusion algorithm, involves busy waiting.

Basically, spin when there’s nothing to do

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

What is a semaphore?

A

Used to implement different synchronisation mechanisms.

Can avoid busy-waiting

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

How do binary semaphores work?

A

Integer restricted to 0 or 1.

Known as a mutex

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

How do counting semaphores work?

A

Starts with amount of resources and decrements/increments when they are removed/readded

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

What are the atomic operations

A

Wait: Delays the calling process integer > 0, then decrements it

Signal: Increment integer

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

What is special about a mutex?

A

It is shared between all cooperating processes.

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

How are bounded-buffers used concurrently?

A

Mutual exclusion on the buffer pool, can’t be read & written simultaneously. Synchronised when buffer is empty or full.

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

How do we get R/W concurrency

A

Mutual exclusion for writers, as many readers as wanted.

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

What is a monitor?

A

Implements concurrency control at the language level.

Compiler generates concurrency control code

17
Q

How do condition variables work with monitors?

A

Condition variables allow for tailor-mode synchronisation schemes based on condition X

18
Q

What operations work on monitors?

A

Wait: x.wait() means calling process is suspended

Signal: x.signal() runs waiting process

19
Q

Process Q has called wait on condition x. Process P signals condition X. What are the possible outcomes?

A

Signal and wait : P waits for Q to leave the monitor
Signal and continue: Q waits for P to leave the monitor

P leaves the monitor immediately.

20
Q

Why do we need kernel pre-emption?

A

Kernels have to handle concurrency; interrupts, system calls and multiple CPU’s.

All can leave the kernel in an inconsistent state