Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Writing the code in C language, the program is in the objective also there's information about which solution to use . AND SHOW OUTPUT!! Objnetives

Writing the code in C language, the program is in the objective also there's information about which solution to use . AND SHOW OUTPUT!! image text in transcribed
Objnetives Write a program to simulate the Dinning Philosophers Problem with random waiting time per philosopher. modify the problem by making the philosopher wait for a random amount of time instead of same time after failing to acquire right hand fork THEORY Five philosophers are seated around a circular table. Each philosopher has a place of spaghetti and he need two forks to eat. Between each plate there is a fork. The life of a philosopher consists of alternate period of eating& thinking. When a philosopher gets hungry he tries to acquire his left fork, if he gets it, it tries to acquire right fork In this solution, we check after picking the left fork whether the right fork is available or not If not, then philosopher puts down the left fork & continues to think. Even this can fail if all the philosophers pick the left fork simultaneously & no right forks available &putting the lef fork down again. This repeats& leads to starvation. Now, we can modify the problem by making the philosopher wait for a random amount of time instead of same time after failing to acquire right hand fork. This will reduce the problem of starvatkn VAR me: semaphore, initially 1: s[5]: semaphore s|5]. initially 0 pflagl5]: (THINK, HUNGRY, EAT, initially THINK: philosopher flag * for mutual exclusion As before, each philosopher is an endless cycle of thinking and eating procedure philosopheri) while TRUE do THINKING take chopsticksi) EATING drop chopsticks()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Heikki Topi, Jeffrey A Hoffer, Ramesh Venkataraman

13th Edition

0134773659, 978-0134773650

More Books

Students also viewed these Databases questions