So, in one class I'm writing implementations of the dining philosophers problem (note that a variation uses chopsticks and rice) using both semaphores (it is possible to prevent deadlock if you're careful) and mutex/conditions. Running tests on it, I noticed something odd - a semi-deadlock state in the semaphore version; that is, a single philosopher was taking his time eating, while none of the others could eat (they couldn't get a hold of a pair of chopsticks). It took me a little bit to figure out what was going on (because I knew that if the teacher saw that he'd ask me if it was broken).
So, here are the questions for you:
1. How do you implement a deadlock-free dining philosophers system using semaphores?
2. How could a single philosopher block all four others all by himself?
Search This Blog
Saturday, December 09, 2006
Subscribe to:
Post Comments (Atom)
2 comments:
misogynist - what makes you think all philosophers are men? :-)
-sd
Hi Quantam.
Can you please upload yours "recMPQ" and "MPQDump" programs?
Post a Comment