0% found this document useful (0 votes)
53 views9 pages

The Cigarette Smokers Problem:: Os PBL

Uploaded by

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

The Cigarette Smokers Problem:: Os PBL

Uploaded by

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

The Cigarette

Smokers
Problem:
OS PBL
Introduction:

• Proposed by: Suhas Patil


• Nature of the Problem: A variation of the Producer-
Consumer problem.
• Goal: Model a synchronization problem with
resource constraints, simulating a real-world
operating system task of resource management.
Problem Setup
• Ingredients for Smoking:
• 1. Tobacco, Paper, Matches
• 2. Three Smokers: Each has an infinite
supply of one ingredient
• Smoker 1: Infinity supplyTobacco
• Smoker 2: Infinity supply Paper
• Smoker 3: Infinity supply Matches
• Agent’s Role:
Places two random ingredients on the
table
Goal :Smoker with missing ingredient
combines them to smoke
Constraints :
- Uses a condition variable to signal
availability
- Cannot know the needs of smoker
Visual representation of the Cigarette Smokers Problem :
Challenges and Constraints

1. Non-deterministic Selection:
Agent randomly places two
items
2. Smoker's Decision: Smoker
with the missing item smokes
3. Deadlock Risk: Wrong smoker
waking up causes deadlock
Trick of the Problem

If Paper and Matches are placed on the table:


🚬
• The Tobacco smoker needs both to smoke.

• If either the Paper or Matches smoker wakes


up and consumes one, neither can
smoke, causing a deadlock because the
Tobacco smoker can't make progress and
the agent can’t place new items.

• Animation video.
Potential Solutions:
- 1. Using Condition Variables
- Smokers' Logic:
- Each smoker thread waits on a specific condition.
- The condition depends on whether the two resources placed by the agent
match the two they need.
- 2. Semaphore-based Solutions
- Approach:
- Although semaphores alone are not suitable, using a combination of
semaphores and condition variables could solve the synchronization issue.
- When the agent places two ingredients on the table, a semaphore signals the
specific smoker thread that can consume the items.
- 3. Monitors and Mutex Locks
- Monitor Approach:
- Encapsulate the agent and smokers in a monitor.
- Use mutual exclusion to ensure that only the smoker who has the right
ingredients wakes up to consume the resources.
Conclusion

• The Cigarette Smokers Problem is a complex resource-


management challenge that reflects real-world
operating system constraints.

• While semaphores alone cannot solve it, advanced


synchronization mechanisms, like condition variables
and monitors, can handle the constraints effectively.

• Key Takeaways:

• Understanding synchronization problems helps in


designing robust concurrent systems.
• Real-world analogies like this problem highlight the
importance of careful resource management and
avoiding deadlocks
Thankyou!!
M MEHARVANI – 22EG105P38
M MEGHANA – 22EG105P39
M VAMSHI – 22EG105P40
M SRINIJA – 22EG105P41
E BHARATI – 22EG105P42

You might also like