Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Kindly Program this question by using only C Language ASAP. Thanks Put any space or anything else besides your SID in the file name. Q1)

image text in transcribedimage text in transcribedKindly Program this question by using only C Language ASAP. Thanks

Put any space or anything else besides your SID in the file name. Q1) [20 Marks] [CLO9-PLO5]You implemented Dinning philosopher problem with 5 philosophers and 5 chopsticks as one of your LabTasks. Now consider a simpler situation with only two philosophers and two chopsticks. Both philosophers think for random 100.unt of 100,000 micro seconds) to eat. You may find following lines helpful. static pthread_mutext mutex1 = PTHREAD MUTEX INITIALIZER; pthread_mutex_lock (&mutex1) usleep(int); Because they think more, so it is possible, as shown in sample run below, that one philosopher might go into a long thinking phase and the other philosopher might eat mor than once during this time. But at no time there will be a deadlock. nadeem@nadeem-VirtualBox: ~/FA21/code/FinalLab$ /TwoPhilos.exe Philosopher#1 wants to eat Philosopher#1 going to eat Philosopher#2 wants to eat Philosopher#1 done eating, now thinking.... Philosopher#2 going to eat Philosopher#2 done eating, now thinking.... hilosopher#1 wants to eat hilosopher#1 going to eat ilosopher#1 done eating, now thinking..... Philosopher#2 wants to eat Philosopher#2 going to eat Philosopher#2 done eating, now thinking.... Philosopher#1 wants to eat Philosopher#1 going to eat Philosopher#1 done eating, now thinking.... Philosopher#2 wants to eat Philosopher#2 going to eat Philosopher#2 done eating, now thinking.... Philosopher#1 wants to eat Philosopher#1 going to eat Philosopher#1 done eating, now thinking.... Philosopher#1 wants to eat Philosopher#1 going to eat Philosopher#1 done eating, now thinking.... Philosopher#1 wants to eat Philosopher#1 going to eat Philosopher#1 done eating, now thinking.... Philosopher#2 wants to eat Put any space or anything else besides your SID in the file name. Q1) [20 Marks] [CLO9-PLO5]You implemented Dinning philosopher problem with 5 philosophers and 5 chopsticks as one of your LabTasks. Now consider a simpler situation with only two philosophers and two chopsticks. Both philosophers think for random 100.unt of 100,000 micro seconds) to eat. You may find following lines helpful. static pthread_mutext mutex1 = PTHREAD MUTEX INITIALIZER; pthread_mutex_lock (&mutex1) usleep(int); Because they think more, so it is possible, as shown in sample run below, that one philosopher might go into a long thinking phase and the other philosopher might eat mor than once during this time. But at no time there will be a deadlock. nadeem@nadeem-VirtualBox: ~/FA21/code/FinalLab$ /TwoPhilos.exe Philosopher#1 wants to eat Philosopher#1 going to eat Philosopher#2 wants to eat Philosopher#1 done eating, now thinking.... Philosopher#2 going to eat Philosopher#2 done eating, now thinking.... hilosopher#1 wants to eat hilosopher#1 going to eat ilosopher#1 done eating, now thinking..... Philosopher#2 wants to eat Philosopher#2 going to eat Philosopher#2 done eating, now thinking.... Philosopher#1 wants to eat Philosopher#1 going to eat Philosopher#1 done eating, now thinking.... Philosopher#2 wants to eat Philosopher#2 going to eat Philosopher#2 done eating, now thinking.... Philosopher#1 wants to eat Philosopher#1 going to eat Philosopher#1 done eating, now thinking.... Philosopher#1 wants to eat Philosopher#1 going to eat Philosopher#1 done eating, now thinking.... Philosopher#1 wants to eat Philosopher#1 going to eat Philosopher#1 done eating, now thinking.... Philosopher#2 wants to eat

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

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions