Concurrency and Synchronization Flashcards

1
Q

What is concurrency in operating systems?

A

Concurrency is the execution of multiple processes or threads at the same time, either by interleaving on a single CPU or overlapping on multiple CPUs.

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

What is the main benefit of concurrent execution?

A

It allows efficient utilization of resources and faster execution of multiple tasks.

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

What are shared resources in the context of concurrency?

A

Shared resources are data or devices that multiple threads or processes can access, such as variables, memory, or files.

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

What is a race condition?

A

A race condition occurs when multiple threads/processes access and modify shared data concurrently, leading to unpredictable outcomes.

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

What is required for a race condition to occur?

A

At least one access must be a write, and the accesses are not mutually exclusive.

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

What is a critical section?

A

A critical section is a part of the program that accesses shared resources and must not be executed by more than one thread/process at a time.

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

What is mutual exclusion?

A

Mutual exclusion ensures that only one thread/process can access the critical section at a time.

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

List the three requirements for mutual exclusion.

A

Mutual Exclusion, Progress, and Bounded Waiting.

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

What is a deadlock?

A

A deadlock is a situation where two or more processes are each waiting for the other to release a resource, and thus none proceed.

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

What are the four necessary conditions for a deadlock?

A

Mutual Exclusion, Hold and Wait, No Preemption, Circular Wait.

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

What is livelock?

A

Livelock is when two or more processes continuously change state in response to each other without making progress.

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

What is starvation in operating systems?

A

Starvation occurs when a process waits indefinitely to access a resource because others with higher priority keep getting access.

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

How can starvation be avoided?

A

By using aging and fair scheduling algorithms like priority queues.

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

What is the Dining Philosophers Problem?

A

A classic synchronization problem where philosophers must share limited forks (resources) and avoid deadlock and starvation while eating and thinking.

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

What is the N-1 resource allocation solution for the Dining Philosophers Problem?

A

Only allow N-1 philosophers to pick up forks at a time to ensure at least one can eat.

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

What is the resource hierarchy solution for the Dining Philosophers Problem?

A

Assign numbers to forks and require philosophers to pick them up in order, preventing circular wait.

17
Q

What is a semaphore?

A

A semaphore is a synchronization primitive used to control access to a shared resource via an integer counter.

18
Q

What are the key operations of a semaphore?

A

Initialize, SemWait (decrement, may block), SemSignal (increment, may unblock).

19
Q

What is a binary semaphore?

A

A semaphore with an initial value of 1, also known as a mutex, allowing only one thread/process access at a time.

20
Q

How does SemWait work?

A

It decrements the semaphore. If the value becomes 0, the process blocks until it’s incremented.

21
Q

How does SemSignal work?

A

It increments the semaphore and unblocks a waiting process, if any.