PLC Tom 22-23 Flashcards

(14 cards)

1
Q

What is granularity?

A

Size of code blocks you’re protecting

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

What is fine grained? What protection is typically used?

A

Smaller blocks of code, protected by lock free approach

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

What is coarse grained? What protection is typically used?

A

Larger blocks of code, protect by mutex lock

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

Name two types of concurrency

A

Message passing concurrency, shared memory concurrency

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

What 3 advantages are there for message passing over shared memory/variable?

A

1) Lower risk of deadlock 2) Avoid problems with cache visibility 3) Don’t need to think about mutex locks

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

What 2 disadvantages are there for message passing over shared memory/variable?

A

1) slower 2) hard to ensure global consensus

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

Why was Peterson’s algorithm introduced?

A

Give mutual exclusion

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

What sort of architecture is Peterson’s thread safe on?

A

Single processor architecture, there’s no instruction reordering

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

What sort of architecture is Peterson’s NOT thread safe on?

A

Modern architecture, there’s instruction reordering

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

If flag(process) comes before turn = process, Peterson’s is thread safe. What if it was switched?

A

IF these two lines were swaped and context switched between them, it would no longer be thread safe

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

If turn = process comes before flag(process), it is not thread safe. What could be added to fix this?

A

A memory barrier after these two lines would ensure mutex. It would ensure both happen and flush memory.

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

What is compare and set?

A

It’s an atomic expression (comparing and setting are done in one instruction)

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

What are the 3 inputs for compare and set?

A

1) An address to look at 2) Old value you’re expecting at address 3) New value for the address

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

What does compare and set do? 5 steps

A

1) Check value at address 2) Compare with expected value 3) If valid (they match) replace 4) if not valid (don’t match) do not replace 5) Return boolean depending on operation success

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