Wednesday Oct 24, 2007

Let's think about this for a second.

Imagine that we are nothing more than threads. That we are spawned by parents and that our time here will eventually end and our bodies consequently reaped.

In different moments in our life we're stopped and we stand around waiting for some event to come around and put us back towards our goal. Some of us wait intensely, spin locking on something/someone/somewhere. Occasionally getting in the way of others.

Others just sit around and do nothing, occupying physical space - sometimes wasting, sometimes just occupying. Sometimes causing others to wait too, a deadlock is a couple of steps ahead and then back.

We may have to wait on others too. During this madness of racing forward so intensely we think too much of ourselves, sometimes forget about other threads and so they might wait more than necessary (or give up and quit). Sometimes that happens to us too. But that wouldn't be a semaphore... that would have to be a barrier (or a shared lock), as we can depend on more than one person at a time. And vice-versa.

When lucky, we have someone to dispatch us towards the right place, so we can execute peacefully with all the resources we need. Other times we have to fight everything and everyone to get our share of space. Hopefully that struggle wasn't in vain and we're not just saying "Hello, World!".

What would be worth facing all the other threads and waiting in line, blocked somewhere, for ?
That's the big question, right ? Relax, a thread is just a flow of execution, we don't have any true conscious of why we exist.

What about processors, where do we execute ?
Maybe that's our cities, and we're racing through a mile long pipeline every time we decide to do something. To that goal, somethings can take place out of order, some can't. Some stages are longer, some shorter. And we always get mad when the wait is too long.

If a city is a processor, semaphores are part of the instruction set. Right ?

Or maybe the world is the processor, and every bridge, railroad and air route are parts of this huge NOC interconnect. We are just threads scheduled from one core to the other, migrating our data with us.

What about our sleep ?

That's easy. That's the garbage collector.

And I obviously need to get some.

This blog copyright 2009 by rv