The ProgrammersTalk Community
Forum Register Search Today's Posts Mark Forums Read
Register

Go Back   The ProgrammersTalk Community > General Programming > Java


Welcome to the The ProgrammersTalk Community forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.
Reply
 
LinkBack (1) Thread Tools    Display Modes   
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 06-27-2007, 03:31 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Icon13 Multithreading & Dining Philosophers

Does anybody have suggestions to design an application to represent this problem with command line? **I'm still designing it** I'm planning to use 2 Semaphore for the Chopstick class..

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #2 (permalink)  
Old 06-28-2007, 08:48 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
This is the illustration of Dining Philosophers. Where "Chopsticks" are the Buffer that is shared between philosophers so that they don't get starved. We're trying to prevent a "DEADLOCK" and "STARVATION" between philosophers.

I'm trying to figure out this... sigh....
Attached Images
File Type: gif cs13_1.gif (3.2 KB, 6 views)

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #3 (permalink)  
Old 06-28-2007, 08:55 PM
ccoonen ccoonen is offline
PT Staff
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jun 2007
Location: Wisconsin
Posts: 308
iTrader: (0)
ccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished road
Wish I could help you out buddy, but I'm outta my element here... If you explain what Chopsticks are possibly I could help you figure it out?...
Reply With Quote
The Following User Says Thank You to ccoonen For This Useful Post:
HelloWorld (06-28-2007)
  #4 (permalink)  
Old 06-28-2007, 09:07 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Quote:
Originally Posted by ccoonen View Post
Wish I could help you out buddy, but I'm outta my element here... If you explain what Chopsticks are possibly I could help you figure it out?...
you guys are frickkin nicee!!! **cry of happiness**
Well, here's the Dining Philosophers problem:

I'm not going to be historical here, but this problem is actually given by a famous CS professors a long time ago to his students in final exam. And now is my lab assignment... lol.. pretty interesting problem, but takes brain... somewhat it's fun though haha...

Here's what happen if you know multithreading? If you don't know then the simplified version of multithreading is when 2 programs are looks like running at the same time/simultaneously, even though actually it is not (assuming that this is a single core CPU). Anyways, and so Threads are programs those are running at the same time and sharing the same resources with other threads.

All of these threads are the philosophers, those are sharing the chopsticks with each other. Philosophers needs 2 chopsticks to eat (to get the resources) so that they don't go into STARVATION. Moreover, all of the philosophers are trying to get them. We also want to make sure that there's no DEADLOCK, where one philosopher get the right chopstick, and the other get the left, and vice versa, which will never end.. in result of this... both of them will never be able to eat the food, so this situation is called a DEADLOCK. (I think... or starvation..?) anyways, they're kind of the same.. haha...

So we basically try to simulate this situation and prevent deadlocks as well as starvation in the dining philosophers

hopefully that's a little nice information for you.. it is really cool programming problem though... if you think about it...? however, it is need to be remembered that programmers don't have control over CPU and Operating System, those are handling which threads can go first... so this is the REAL problem that arises.. we need to be able to manage these threads, but I think the harder part is to simulate the dining philosophers. They have 2 hands, 1 chopsticks, determining the left and the right chopsticks, and when they're eating, when they're thinking.. is the real problem for me so far ...

one more, we have to use Semaphore to solve this problem..

hey you know what, a good news!
I think I kind of get the program working... just know I tried my program
just a little exception and trying to detect when they got hungry... haha...
thanx ccoonen for your support...

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!

Last edited by Lee : 06-29-2007 at 04:20 AM. Reason: Triple post in 8mins, hours apart = fine otherwise edit please.
Reply With Quote
  #5 (permalink)  
Old 06-28-2007, 09:37 PM
TeraTask's Avatar
TeraTask TeraTask is offline
PT Staff*
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 3
Join Date: Jun 2007
Location: Reno, NV
Posts: 426
iTrader: (0)
TeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enoughTeraTask will become famous soon enough
Um, why don't you share your solution? I'd personally love to see it as I don't fully understand the problem statement.

__________________
Jeremy Miller
Content Farmer - Optimized Automated Blog Posting

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
  #6 (permalink)  
Old 06-28-2007, 09:40 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
Programming Expert
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,111
iTrader: (0)
HelloWorld will become famous soon enoughHelloWorld will become famous soon enoughHelloWorld will become famous soon enough
Quote:
Originally Posted by TeraTask View Post
Um, why don't you share your solution? I'd personally love to see it as I don't fully understand the problem statement.
I will surely post it once I got the correct answer, so far I still got an exception, and I post it on the other thread. I don't see there's anything wrong on my main method though...

IllegalThreadStateException

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

   Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.programmerstalk.net/thread826.html
Posted By For Type Date
ProgrammersTalk's bookmarks tagged with This thread Refback 09-20-2007 05:37 PM


All times are GMT -7. The time now is 10:43 AM. Powered by vBulletin
Copyright © 2000 - 2007, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO © 2007 ProgrammersTalk Sedo - Buy and Sell Domain Names and Websites project info: programmerstalk.net Statistics for project programmerstalk.net etracker® web controlling instead of log file analysis


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50