My first time interviewing at Microsoft I got the Philosophers question with
Rice and Chopsticks.  I proposed two solutions... 

One that worked on position and timing... 

The other was the "Python 2.7" fix. 

doonce(BreakChopSticks);

do{think;}
while(hungry!=true)

Cut the chopsticks in half and let everyone eat half as fast, but think on
their own schedule.   The philosophers will be happier, and the code is
easier to write.



-----Original Message-----
From: google-appengine@googlegroups.com
[mailto:google-appengine@googlegroups.com] On Behalf Of Emlyn
Sent: Wednesday, October 26, 2011 5:39 PM
To: google-appengine@googlegroups.com
Subject: Re: [google-appengine] Re: The Dining Philosophers

On 25 October 2011 02:18, Kyle <kyle.rich...@gmail.com> wrote:
> Is there a reason that you didn't use the memcached service to 
> implement semaphores?
>
> -Kyle

I'm assuming you mean Memcache?

Well, two things. Firstly, as far as I know there are no transactions or
locks or anything like that for memcache, so where you need a critical
section, how will you implement it? (This is not actually a rhetorical
question; is there a way?)

Secondly, you can't trust Memcache to stick around, as far as I know.
If one task constructs a semaphore in memcache, then will that still be
there when another tasks tries to wait() on it?

Anything that is implemented in terms of Semaphores really needs to be able
to rely on them to behave. It might be good to come up with an alternative
construct that can tolerate memcache's behaviour, I'm totally open to
suggestions.



>
> On Oct 23, 6:23 am, Emlyn <emlynore...@gmail.com> wrote:
>> Here's a new AppEngine article from me, "The Dining Philosophers". It 
>> includes a full working implementation of Semaphores using the 
>> Datastore, and implementation of flawed and successful solutions to 
>> the classic Dining Philosophers problem using Semaphores.
>>
>> http://appenginedevelopment.blogspot.com/2011/10/dining-philosophers....
>>
>> Fun for hard core comp sci types ;-)
>>
>> --
>> Emlyn
>>
>> http://my.syyn.cc- Synchonise Google+, Facebook, WordPress and Google 
>> Buzz posts, comments and all.http://point7.wordpress.com- My blog 
>> Find me on Facebook and Buzz
>
> --
> You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
> To post to this group, send email to google-appengine@googlegroups.com.
> To unsubscribe from this group, send email to
google-appengine+unsubscr...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.
>
>



--
Emlyn

http://my.syyn.cc - Synchonise Google+, Facebook, WordPress and Google Buzz
posts, comments and all.
http://point7.wordpress.com - My blog
Find me on Facebook and Buzz

--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to