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

CASE 1:-If The Philosopher Were Come in Serial Manner Than This Code Is Perfectly Work

The document discusses solutions to dining philosophers and reader-writer problems using semaphores. It presents 4 cases: 1) the philosopher code works correctly if philosophers arrive serially; 2) a race condition can occur if two philosophers arrive at the same time; 3) a deadlock situation can arise; and 4) allowing only 4 philosophers does not provide an appropriate solution and the philosopher code can be changed. It also mentions 3 types of code for entry and exit in the reader-writer problem.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

CASE 1:-If The Philosopher Were Come in Serial Manner Than This Code Is Perfectly Work

The document discusses solutions to dining philosophers and reader-writer problems using semaphores. It presents 4 cases: 1) the philosopher code works correctly if philosophers arrive serially; 2) a race condition can occur if two philosophers arrive at the same time; 3) a deadlock situation can arise; and 4) allowing only 4 philosophers does not provide an appropriate solution and the philosopher code can be changed. It also mentions 3 types of code for entry and exit in the reader-writer problem.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

CASE 1:-If the philosopher were come in serial manner than this code is perfectly work

CASE 2:- po is pick fo and p1 pick f1 than po is waiting for f1 also so when p1 finishes his work then
po start executing if two or more than two philosopher come at same time there may be a problem
than race condition occur

So we used array of semaphores here

Independent philosopher can easily enter in to critical section


Case 3:- deadlock situation

Case 4: remove this deadlock only four philosopher can sit but this is not an appropriate solution

(We can change any philosopher code)


Case 1 if the philosopher comes in serial manner

Void philosopher(void)

While (true)

Thinking()

Take_fork(i); //i= left fork

Take_fork(i+1%N)

EAT()

Put_fork(i);

Put_fork(i+1%N)

READER WRITER PROBLEM:-


THREE TYPE OF CODE ENTRY EXIT

CASE 1:
QUESTION

You might also like