What a geeky post title. Well, I guess it's a geeky post.
Based on the number of people actually in the bathroom at work when I'm in there, I would think that two people entering/exiting the bathroom at the same time would be a rare event. Yet, I've come to expect the door to magically open in front of me as my hand nears the handle, or swing violently at my face as I exit.
I always find it amazing the number of things in real life that have dualities in software. In software, we'd solve the problem of collisions in the doorway by taking a lock on it (although locking on a public object is not always a good idea). This becomes a problem in the real world because of visibility. The bathroom door has no window (which is probably good), so you can't see when someone is right on the other side. You seldom have a collision when the door has a window because you can see who else is going to try to use the door before you can get there. There are tons of "shared resources" in the world where we've created synchronization mechanisms of various authority. I think we could learn a thing or two by observing them.
For instance, when roads intersect, we have several different ways of dealing with collisions (we sometimes call them that in the software world as well.):
And there are tons of "in-between" flavors. Hopefully you see what I'm getting at. The granularity of synchronization in software can be just as complex. Simple locks, Mutexes, Reader/Writer locks, etc.
Where am I going with this? I don't know. I just thought it was interesting how many real-world examples of synchronization there are, and how we avoid them in different scenarios, sometimes delegating that responsibility, sometimes taking a more strict position. Prioritizing etc.
That is all.
Remember Me
Page rendered at Tuesday, October 07, 2008 9:00:27 AM (Pacific Standard Time, UTC-08:00)
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.