Week 2 Flashcards

1
Q

IPC Challenges:

A

Processes must exchange information, avoid conflicts, and handle dependencies, often over shared memory.

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

IPC Mechanisms:

A

Processes require synchronization for safe communication. The OS offers features to handle shared resources safely, such as using shell pipelines for chaining commands (e.g., history | grep export).

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

Shared Memory Communication:

A

Example: Multiple processes printing files by adding them to a spooler directory managed by a printer daemon. The OS uses variables like next_free_slot to avoid overwriting data, ensuring organized access to shared memory.

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

Critical Region and Mutual Exclusion:

A

Critical Region: Code accessing shared memory, where only one process is allowed at a time to prevent conflicts.

Mutual Exclusion Techniques:
Disable Interrupts: Useful in single-CPU systems where process disables interrupts to maintain exclusive access.
Lock Variables: Creates a “lock” that processes check before entering the critical region.
Strict Alternation: Uses a “spin lock” where processes take turns accessing the critical region.

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

Producer-Consumer Model:

A

Often used in distributed systems (e.g., Apache Kafka). A producer and consumer share a fixed-size buffer. If the buffer is full, the producer waits (sleeps) until there is space—an example of the “sleep and wakeup” IPC model.

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

Semaphores:

A

Semaphores are similar to mutexes but act as a queue for waiting processes. A semaphore is an integer counting waiting processes. When it reaches 0, additional processes are put to sleep until woken up by another process incrementing the semaphore.

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

Reader-Writer Problem:

A

Example: Databases with simultaneous read and write access, like an airline reservation system.

Solution:
Readers: Use a semaphore (db) and a counter (rc) to control entry to the critical section. Multiple readers can access simultaneously if no writer is active.
Writers: Writers require exclusive access through the same semaphore, allowing only one writer at a time in the critical section.

Problem: A writer may face indefinite delays if a continuous stream of readers enters first, causing writer starvation.

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

Mutex (Mutual Exclusion):

A

Function: Simplifies exclusive access, especially useful in user-space threads. A shared variable with “locked” or “unlocked” states prevents concurrent access.

Thread Yield: In user-space, a locked mutex allows a thread to yield execution, letting other threads run while waiting to recheck access.

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

Monitors:

A

Purpose: A higher-level synchronization structure containing procedures, variables, and data structures. Only one process can be active in a monitor at a time.

Automatic Mutual Exclusion: The compiler ensures that calls to monitor procedures don’t cause race conditions, simplifying synchronization.

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

Message Passing:

A

Function: Allows processes to communicate through system calls (e.g., send and receive).

Challenges: Distributed systems face issues like lost messages, naming, authentication, and message retransmission with sequence numbers.

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

Conditional Variables:

A

Purpose: Used in synchronization to block threads until specific conditions are met.

Use with Mutexes: A thread locks a mutex and waits on a condition variable if the condition isn’t met; other threads signal or broadcast to wake them.

Signal Loss: Condition variables don’t store memory, so if a signal is sent without waiting threads, it’s lost. Careful programming is required to ensure no signals are missed

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