Concurrency Flashcards

1
Q

Why is concurrency difficult for programmers to reason about?

A

Because it breaks our expectations of how code works ie,

Instructions are atomic

The order in which instructions are executed are fixed

These two assumptions are broken by concurrency

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

What is concurrency?

A

Running parts of the same computation at the same time

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

What are Threads?

A

Independent streams of computation

Implicit Interactions - Shared memory between threads, can read and write the same data

More co-ordination required

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

What are Processes?

A

Each process has its own internal state

Explicit Interactions: message passing

Less co-ordination needed

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

What is compiler based concurrency?

A

Don’t implement any concurrent operations yourself, and let the compiler figure it out for you :)

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

What is a pre-protocol?

A

Making sure that no-one else is using the critical section

before a thread enters it,

and marking the critical section as in use

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

What does a Lock do?

A

Controls access to the critical section

Lock() - Asks for access to a critical section
Goes to sleep if CR occupied

Unlock() - Leaves Critical Section
Wakes up thread sleeping on this lock

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

What is one benifit of Sleep in Locks?

A

Avoids starvation

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

What is a Remote Procedure Call?

A

When the Sender waits for the Receiver to REPLY

i.e. Solidity

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

What are Synchronous Messages?

A

This is where the Sender waits for the Receiver to GET the message

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

What are Asynchronous Messages?

A

This is where the Sender sends the message and continues execution immediately

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

What are the properties of Remote Procedure Call (RPC)?

A

Simpler to reason about

Little concurrency

Send and Reply are atomic

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

What are the properties of Synchronous Messaging?

A

Lot of communication overhead

When send() returns we know the message was received

Send and reply are atomic, but the state may have changed between them

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

What are the properties of Asynchronous Messaging?

A

Not easy to reason about

Little Communication overhead

No guarantee the message will be received

Buffers needed for managing messages

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

Why is Automatic Concurrency easy for Functional Programming?

A

Functions have no explicit ordering

Functions have no state

Data flow is explicit

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