View Single Post
  #4 (permalink)  
Old 06-28-2007, 10:07 PM
HelloWorld's Avatar
HelloWorld HelloWorld is offline
PT Admin
Awards Showcase
Quality Tutorial 
Total Awards: 1
Join Date: Jun 2007
Location: In front of computer...
Posts: 1,119
iTrader: (0)
HelloWorld is a jewel in the roughHelloWorld is a jewel in the roughHelloWorld is a jewel in the rough
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 05:20 AM. Reason: Triple post in 8mins, hours apart = fine otherwise edit please.
Reply With Quote