Concurrency (L21) Flashcards

1
Q

Concurrency refers to the concept of separate threads of control/execution within a program.

A

True.

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

Parallelism is a synonym for concurrency.

A

False.

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

What are parallel programs?

A

Programs that support simultaneous execution of distinct instruction streams.

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

By definition, concurrent programs are run on multiple CPUs or cores.

A

False - parallel programs are.

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

What are parallel programs typically used for?

A

Increasing the performance
of a specific algorithm.

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

What is concurrency typically used for?

A

For dividing the logic of a complex programs into distinct units.

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

All concurrent programs provide parallelism, but parallel programs are not necessarily concurrent.

A

False, all parallel programs provide
concurrency, but concurrent programs are not necessarily parallel.

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

Controlling access to shared data is necessarily the primary issue when writing concurrent programs.

A

False - sharing write-able data is a problem, but sharing read-only data is fine.

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

What is a critical region?

A

A block of code in which an update to shared data is made.

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

What is the traditional approach to only allowing one thread to enter/exit the critical region at a time.

A

Locks, which are locked (1) at the start of the critical region and closed (0) at its end.

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

Threads that encounter a lock perform another task and circle back later.

A

False - such threads wait/block until the data is unlocked.

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

It is not possible for multiple threads to think they have the lock for some data, as setting a lock variable is done in a single line of code.

A

False - this single high level language instruction is compiled into multiple
machine level instructions.

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

What is a “test and swap” instruction provided by modern CPUs?

A

An atomic assignment instruction that
always completes - allows languages to close locks “in a single instruction”.

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

What C library allows concurrency that follows the lock model?

A

pthreads

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

What does Java’s synchronized keyword do?

A

A synchronized method is tested such that this method can only be used by one thread at a time.

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

What are two problems encountered when using many threads that share many data structures?

A

Deadlock & livelock.

17
Q

What is deadlock?

A

When separate threads are each waiting for a lock held by the other.

18
Q

What is livelock?

A

When threads are actively trying to resolve a dependency or conflict, but their actions prevent any progress from being made, leading to a perpetual “busy” state.

19
Q

Due to deadlock/livelock, low level thread management doesn’t scale very well.

A

True.

20
Q

What concurrency model is provided by Erlang?

A

Message passing.

21
Q

Messages are placed in a stack belonging to the receiving thread.

A

False - they are placed in queues.

22
Q

A thread always knows where a message comes from.

A

False - this is true only when messages have a sender ID.

23
Q

Messages are viewed as synchronous, since it allows threads to synchronize their tasks.

A

False - they are viewed as asynchronous since sending/receiving threads do not block during transfer.

24
Q

It is impossible for processes to hang using message passing.

A

False - a process may wait wait for a message from a task that has crashed.

25
Q

In message passing, the queue data structures are shared by separate tasks.

A

False.