Solved

Dining Philosophers problem - easy questions

Posted on 2004-10-13
7
439 Views
Last Modified: 2012-08-14
Could anyone tell me what the pros and cons of the following three solutions to the dining
philosophers problem are?

Algorithm 1:
Wait for left stick to be free.
Pick up left stick.
Wait for right stick to be free.
Pick up right stick.

Algorithm 2:
All philosophers run Algorithm 1,
except philosopher number 5 who runs:

Wait for right stick to be free.
Pick up right stick.
Wait for left stick to be free.
Pick up left stick.

Algorithm 3: Wait for both sticks to be free.
Pick up both sticks (as an atomic operation)
0
Comment
Question by:killer455
7 Comments
 
LVL 1

Expert Comment

by:Feldspar
ID: 12304083
The issues that are generally present in multiprogramming systems like this are:
- Deadlock: it wont get to a state where some threads can never run because they are waiting on each other.
- Starvation: a thread doesnt get blocked 'forever' becaue other threads always have the resources it needs
- Fairness: threads get blocked evenly, and no thread is 'favored' over others.  
And like everything, there is also ease of implementation, memory required, overhead, speed, etc.

this page might give you a good guide
http://www.cs.ucsb.edu/~cs170/notes/dphil/
0
 

Author Comment

by:killer455
ID: 12304627
This is more of a general answer, could be be more specific to my question regarding those algorithms rather than general info.
0
 
LVL 84

Accepted Solution

by:
ozo earned 30 total points
ID: 12305123
Algorithm 1 suffers from deadlock.
Algorithm 3 can suffer from starvation.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:killer455
ID: 12305325
What about algorithm 2?
0
 
LVL 1

Assisted Solution

by:Mistobaan
Mistobaan earned 20 total points
ID: 12306143
Alghoritm 2 is the same as 1
it suffers deadlock, Starvation and fairness.
It depends also on how the stick are released.
0
 
LVL 84

Expert Comment

by:ozo
ID: 12315807
Algorithm 2 does not suffer deadlock
0
 
LVL 2

Expert Comment

by:mtcmedia
ID: 12691147
Algorithm 2 looks like the good one to me :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
mergeTwo  challenge 13 82
for loop with Set 4 48
VB 6.0 printer how to align 6 57
How can i compile this github project?? 2 74
RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

939 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

4 Experts available now in Live!

Get 1:1 Help Now