Concurrency Flashcards

(22 cards)

1
Q

What’s the main difference between threads and processes?

A

Threads of the same process share the same address space

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

Allowing multiple threads within the same process to share the same address space allows the threads to be…

A

independent of each other

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

What do the threads within a process share?

A

Process ID
Address space
Open files
Other resources

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

What does each thread within a process have, that it doesn’t share?

A

Thread ID
Set of registers - including PC
Stack

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

Give the definition:
A thread based on the POSIX library where an API specifies the behaviour of its library

A

POSIX thread - Pthread

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

What sort of results can concurrency lead to?

A

Non-deterministic results - different results despite the same input

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

⭐️ Give the definition:
When multiple threads of execution update the shared data structure, and the final result depends on the execution order

A

Race condition

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

⭐️ Give the definition:
An operation that completes in its entirety without worrying about interruption by any other potentially conflict-causing threads

A

Atomic operation

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

⭐️ What do we call the problem that is to ensure that when one thread is executing in its critical section, no other thread is allowed to execute in that critical section?

A

The critical section problem

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

⭐️ Give the definition:
A piece of code that accesses a shared resource, usually a variable or data structure

A

Critical section

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

⭐️ What are the three parts of the solution to the critical section problem?

A
  1. Mutual exclusion
  2. Progress
  3. Bounded
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

⭐️ Give the definition:
A part of the solution to the critical section problem where only one thread is allowed in the critical section at a time

A

Mutual exclusion

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

⭐️ Give the definition:
The part of the solution to the critical section problem that ensures that no deadlock occurs; where if there are several simultaneous requests from threads, one must be allowed to proceed

A

Progress

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

⭐️ Give the definition:
The part of the solution to the critical section problem that ensures that no starvation happens; where one must eventually allow each waiting thread to enter

A

Bounded

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

⭐️ What are the 3 concurrency problems?

A
  1. Race conditions
  2. Critical section problem
  3. Deadlocks
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

⭐️ Give the definition:
Threads waiting forever for each other to release resources

17
Q

⭐️ What 3 techniques can be used to solve the concurrency problems?

A
  1. Locks (mutexes)
  2. Condition variables
  3. Atomic operations
18
Q

⭐️ Give the definition:
Mutual exclusion primitives to protect critical sections. Only one thread can hold them at once.

19
Q

⭐️ Give the definition: allow threads to wait for certain conditions to be true

A

Condition variables

20
Q

⭐️ A critical section is a piece of code in a process / thread that accesses shared data (T/F)

21
Q

⭐️ What is a race condition?
1. A mechanism to ensure mutual exclusion in critical sections.
2. A type of deadlock where threads are waiting indefinitely
3. A synchronisation primitive used to lock resources
4. Two or more threads accessing shared data, lading to unpredictable results

22
Q

⭐️ What are the 3 requirements for a solution to the critical-section problem?

A

Mutual Exclusion, Progress, Bounded Waiting