ARTHUR: Who lives in that castle?
WOMAN: No one lives there.
ARTHUR: Then who is your lord?
WOMAN: We don’t have a lord.
ARTHUR: What?
DENNIS: I told you. We’re an anarcho-syndicalist commune. We take it in turns to act as a sort of executive officer for the week.
(from Monty Python and the Holy Grail)
Yeah, whatever. I want to hear about bunnies
Picture a world consisting of forty Energizer bunnies, grouped into four teams of ten. Each team has one battery between them, and the main rule of the game is that each bunny may only use the battery for a little while before transferring it to a teammate. There is no way for a sleeping player to be woken up except by being passed the battery, and each battery strictly stays within one team.
Following from this, another important rule is that a player may not go to sleep while in possession of the battery. If you feel sleepy, just pass the damn thing along.
We like to pretend that these batteries go on and on, but every so often a battery (and its energetic owner) will mysteriously go dead for a bit because somebody outside of the game is stealing the real power. But when control reverts to any team member, it will be the one with the battery, and this bunny will not realise that the world had briefly frozen for it and its team.
When the time comes for a bunny to pass the battery, it may be out of free choice, or it might be because its script went down a path where passing it along is The Thing To Do. At this juncture, the team’s collective memory and playbook comes to the fore, and agreed rules dictate who the battery goes to. It doesn’t really matter what those rules are for the moment. The important point is that control is transferred by the players themselves using shared rules and a team whiteboard tracking who is ready to go, which team member might be most deserving, who has been waiting the longest etc. This code of conduct and state, this bushido of bunny bonhomie, is what we call a scheduler.
Now most of the bunnies are indistinguishable from each other and live rather varied lives, but a few of them are specialists, doing jobs like log writing and lazywriting. Special uniforms aside though, they still play by our fundamental rule: you only get the battery when it’s your turn. This can make an observer think that the system isn’t as reasonable as it should be. If there is a vast pile of dirty dishes and Ingeborg is dirtying even more, surely Roger the Sculler should be woken up post haste? But no, Ingeborg has the battery and we must trust her to know how the game works. This is why one of the rules involves keeping turns short.
Occasionally players need to leave the game to do a chore like going to the shops. We can not allow them to take the team battery along, because then the whole team will remain frozen and at the mercy of Lord knows what accidents may befall our intrepid shopper. So a special rule is invoked: you can take a spare grocery shopping battery along as long as you leave the team battery behind. When you want to rejoin to team, you have to relinquish that battery and go to sleep, waiting for your turn with the team battery. But every moment you actively use the spare battery (as opposed to just sitting on the bus en route to the shop) is a moment that some team’s battery goes dark.
Players truly look after each other, even helping out other teams. For instance, if you are too thirsty to continue playing out your turn, you can shout out your drinks order and pass the battery along. At some point drinks will be delivered to the side of the field, and someone who currently has a battery will deal with distributing all such deliveries before passing along her battery. “Distributing” means updating the team whiteboard, and this may influence who she ends up passing the battery to.
And while it really really shouldn’t happen, it is theoretically possible that a player goes crazy and doesn’t give up the team battery. What is to be done when faced with a runaway bunny?
2 thoughts on “King Arthur, Energizer bunnies, and the search for the SQLOS scheduler”