8 - Concurrent Programming Flashcards

1
Q

What happens when a process calls for, and there are multiple threads?

A

Only the calling thread survives, other threads are not duplicated.

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

Is it safe to use fork in a program with multiple threads?

A

General advice: avoid using fork() in programs with multiple threads.

Some usages are safe, eg.:
• fork() is immediately followed by execve() to execute external
program, or
• fork() is executed before creating any threads

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

What is asynchronous thread cancellation?

A

One thread manually terminates the target thread

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

What is Deferred / Synchronous Thread Cancellation?

A

The controlling thread somehow indicates it wishes to cancel a thread

Target thread periodically checks whether it should terminate
• Checking done only at cancellation points at which it can be canceled safely.

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

What is a race condition?

A

A behavior where the output is dependent on

the sequence or timing of other uncontrollable events (eg. context switching, scheduling on multiple CPUs)

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

What is a Critical Section?

A

Part of the program that accesses the shared resource in a way that could lead to races or other
undefined/unpredictable/unwanted behavior

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

What is Mutual Exclusion?

A

Arranging tasks such that no two processes or threads will ever be in their critical sections at the same time.

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

What is a Shared Resource?

A

A resource available to more than one thread.

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

What are the requirements for a good race free solution?

A

1.Mutual exclusion: No two processes/threads may be simultaneously inside their critical sections (CS).
2.Progress: No process/threads running outside its CS may block other processes/threads.
3.Bounded waiting: No process/thread should have
to wait forever to enter its CS.
4.Speed: No assumptions may be made about the speed or the number of CPUs.

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