0% found this document useful (0 votes)
4 views

OS_Assignment_2_Answers

The document outlines key terms related to inter-process communication (IPC) such as race condition, critical section, and semaphores. It also discusses problems like the bounded buffer producer-consumer, readers-writers, dining philosophers, and deadlock, along with the Banker's algorithm for deadlock avoidance. Each section provides an overview of synchronization techniques and challenges in process management.

Uploaded by

dicepo5475
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

OS_Assignment_2_Answers

The document outlines key terms related to inter-process communication (IPC) such as race condition, critical section, and semaphores. It also discusses problems like the bounded buffer producer-consumer, readers-writers, dining philosophers, and deadlock, along with the Banker's algorithm for deadlock avoidance. Each section provides an overview of synchronization techniques and challenges in process management.

Uploaded by

dicepo5475
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

Terms related to IPC

- Race condition: Occurs when multiple processes access and manipulate shared data

concurrently, and the outcome depends on the order of execution.

- Critical section: A section of code where shared resources are accessed and only one

process should execute at a time.

- Mutual exclusion: Ensures that only one process can enter the critical section at any given

time.

- Semaphores: A synchronization tool used to control access to shared resources. It can be

binary or counting.

- Bounded waiting: A limit on the number of times a process can be bypassed by others while

waiting to enter the critical section.

- Mutex: A binary semaphore used specifically to achieve mutual exclusion.

- Pipe: A unidirectional communication channel used for inter-process communication.

- Message passing: A method of communication where processes exchange messages to

share information.

2. Bounded Buffer Producer Consumer Problem using Semaphore

- Shared buffer of fixed size.

- Semaphores used: mutex (binary), empty (counting), full (counting).

- Initialization:

- - mutex = 1 (for critical section)

- - empty = N (buffer size)

- - full = 0 (initially no items)

- Producer Process:

- wait(empty);

- wait(mutex);

- // add item to buffer

- signal(mutex);
- signal(full);

- Consumer Process:

- wait(full);

- wait(mutex);

- // remove item from buffer

- signal(mutex);

- signal(empty);

3. Readers and Writers Problem

- Deals with synchronization when multiple readers and writers access shared data.

- Constraints:

- - Multiple readers can read simultaneously.

- - Writers need exclusive access.

- Solution should avoid starvation and ensure fairness.

4. Dining-philosophers Problem

- Five philosophers sit around a table with one fork between each pair.

- Each needs two forks to eat (left and right).

- Problem illustrates deadlock and resource contention.

- Solutions involve limiting resource acquisition or using asymmetric strategies.

5. Deadlock and its Conditions

- Deadlock: A situation where a set of processes are blocked, each waiting for resources held

by the others.

- Conditions for deadlock:

- - Mutual Exclusion

- - Hold and Wait

- - No Preemption

- - Circular Wait

6. Banker's Algorithm for Deadlock Avoidance


- Used to allocate resources safely without causing deadlock.

- Each process declares max resources needed.

- System checks for safe state before allocation.

- Example:

- - Resources: A(10), B(5), C(7)

- - Available: A(3), B(2), C(2)

- - Processes with Allocation and Max requirements

- - System simulates allocation and checks if all processes can finish.

- - If yes, it's a safe state.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy