0% found this document useful (0 votes)
8 views4 pages

Exp8 102 JayeshRuchandani

The document outlines an experiment for a course on Operating Systems, specifically focusing on the Dining Philosopher's Problem. It describes the scenario involving five philosophers who share chopsticks and the use of semaphores to manage their access to these resources. The conclusion states that the concept has been studied and implemented successfully.
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)
8 views4 pages

Exp8 102 JayeshRuchandani

The document outlines an experiment for a course on Operating Systems, specifically focusing on the Dining Philosopher's Problem. It describes the scenario involving five philosophers who share chopsticks and the use of semaphores to manage their access to these resources. The conclusion states that the concept has been studied and implemented successfully.
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/ 4

S22-102 Jayesh Ruchandani

------------------------------------------------------------------------------------------------------------
Course Code: CSL403 Name: Operating System Lab

Class: SE Semester: IV

EXPERIMENT NO 8

Aim: Write a program to demonstrate the concept of Dining Philosopher’s Problem.

Theory:
Consider five philosophers who spend their lives thinking and eating. The
philosophers share a circular table surrounded by five chairs, each belonging to one
philosopher. In the center of the table is a bowl of rice, and the table is laid with
five single chopsticks.

Figure. The situation of the dining philosophers.

When a philosopher thinks, she does not interact with her colleagues. From time to
time, a philosopher gets hungry and tries to pick up the two chopsticks that are closest
to her (the chopsticks that are between her and her left and right neighbors). A
philosopher may pick up only one chopstick at a time. Obviously, she cannot pick up
a chopstick that is already in the hand of a neighbor. When a hungry philosopher has
both her chopsticks at the same time, she eats without releasing her chopsticks. When
she is finished eating, she puts down both of her chopsticks and starts thinking again.
The solution is to represent each chopstick with a semaphore. A philosopher tries to
grab a chopstick by executing a wait () operation on that semaphore; she releases her
chopsticks by executing the signal() operation on the appropriate semaphores. Thus,
the shared data are
S22-102 Jayesh Ruchandani
semaphore chopstick[5];
where all the elements of chopstick are initialized to 1.

The structure of philosopher i is shown in Figure:

Figure. The structure of philosopher i.

Program:
S22-102 Jayesh Ruchandani

+
S22-102 Jayesh Ruchandani

OUTPUT:

Conclusion: Hence, we have studied and implemented the the concept of Dining
Philosopher’s Problem.

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