Shared File and Shared Memory IPC Flashcards

1
Q

What are locks?

A

Locks are used to control access to a shared file to prevent data corruption.

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

What is an exclusive lock?

A

Only one process can acquire the lock at a time.
Used for write operations to ensure no other process reads or writes to the file simultaneously.

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

What are shared locks?

A

Multiple processes can acquire the lock simultaneously.
Used for read-only access since multiple readers won’t interfere with each other.

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

What is a mutex and what does it do? (mutual exclusion)

A

Ensures that only one process or thread can access the shared resource at a time.
Typically binary (locked/unlocked).
Simpler and lightweight when compared to semaphores.
Use Case: Protect critical sections in shared memory.

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

What are semaphores and what do they do?

A

Can allow multiple processes/threads to access a resource up to a set limit.
Two main operations:
Wait/Decrement (P): Decreases the semaphore’s value. Blocks if the value is 0.
Signal/Increment (V): Increases the semaphore’s value, potentially unblocking waiting processes.
Use Case: Limiting access to a shared resource (e.g., database connections)

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