Semaphores for children

In the never ending search for better metaphors, I stumbled upon a nice example from my childhood. When I was a child and went to kindergarten, next to the door in the classroom, there were 2 necklaces. If you wanted to go to the toilet, you had to take a necklace, and when you returned, you had to put the necklace back. If you were unlucky, both necklaces were lent, and you had wait or try again a few minutes later. This is a perfect example of a Semaphore with 2 licences.

The solution isn’t quite optimal however. The building has room for 2 classrooms (with each 2 necklaces) and 4 toilets. So it could happen that a child needs to wait in one classroom, even though the necklaces in the other classroom still are available. But heck, what more can you expect from a child that is able to comprehend the basic concepts of concurrency control 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: