26. Concurrency. An introduction Flashcards

1
Q

What does thread have its own and what does it share?

A

Thread has own program counter, stack and private set of registers, but they share a single address space.

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

Does context switch occur for threads?

A

Yes, but there is no need in switching page table with threads. The state is also saved to TCB instead of PCB.

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

How is stack for thread sometimes called?

A

Thread-local storage.

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

What is race condition?

A

It’s when multiple threads are updating the same shared data, but in a way that is not atomic and indeterministic

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

What is critical section?

A

Piece of code that accesses a shared variable and can be run only by 1 thread at a time

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

How to avoid race condition?

A

With atomic operations which can be atomic either by design (pre-made hardware instruction) or that can be atomic with help of some synchronization primitives

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