Tuesday, 21 August 2012

Frankie on the slab

The stunning attractive young woman who'd recruited me to be Frankenstein's debugger was called Shirley and spent all of my first lunch break telling me about her celibacy pledge, her objections to sex-for-pleasure, and a number of tropical diseases that did curious things to reproductive systems.  By the time I'd laid my sandwich down, sadly, and admitted to myself that I couldn't eat ham slathered with mustard and grated cheese now, the lunch break was nearly over and Shirley was patting my hand and telling me what a good listener I was.  I forced a smile out, which she seemed happy with, and went to make myself a coffee.  Without milk.  I still had images in my head that were fairly milky that put me off drinking it.
The coffee was rather good without the milk though, so I didn't actually miss it in the end, and the buzz I got from it seemed a little sharper – purer – than before.  I sat back down at the computer, sipped my coffee, and stared at the code.
The code was divided up into several modules, each module running what Belinda, the lead scientist who looked like an older version of Shirley, had identified as a core system.  Initially I'd expected there to me a module for each arm, each leg, etc., and I'd rapidly discovered how wrong that was.  Instead I was looking through the module for the autonomous nervous system, and as I drilled down through it, studying how it split into sub-modules that interacted with one another, I started to realise how much a body does without its owner ever thinking about it.
"Is that the code for breathing?" said a soft voice like fingernails drawn across silk.  I swallowed reflexively and reached for the cup of coffee to cover my confusion.
"Yes," I said, not looking round.  I could feel Belinda leaning over my shoulder, and I was pretty certain that if I turned to look I'd spill the coffee.
"It took us eight days to write that," she said.  "You'd think it would be easy, but the problem is that you can't use finite loop counters.  If you do that you've set a maximum on the number of breaths the body can take, and when it runs out it just stands there, not breathing, slowly asphyxiating.  It's ridiculous, but it happened.  Three times!"  I pictured the body – the man, the monster, the thing on the slab – slowly choking to death because its internal software had run out of the ability to tell it to breath, and to my slight surprise I felt a little sorry for it.  Destined to die because of shoddy programming.
"That's why you're allowing the register to overflow," I said.  "So that you can just come back round and start again from the beginning.  An effective infinite loop that, thanks to this overflow flag here, keeps track of where it is.  It's very clever."
"Thank-you," she said.
"But there's a race condition," I continued.  Now she was silent and so I carried on.  "See over here, in this code for switching back to aerobic..."  I carried on, pointing out how code in three different areas could combine to produce a race condition where all of them wanted to do something but were waiting for the other code to run first.  Like three drivers at a roundabout all waiting for the next one to be the first to enter.
"I see," she said, her voice grating a little.  I got the impression she didn't believe me.  "And if this race condition occurs, what would I expect to see little Frankie do?"
Frankie was what she called the body on the slab.
"Well," I said.  "I don't know any biology, but this would stop the breathing, and this would cause lactic acid build up in whatever muscles were being used, and this last one would cause more of this chemical to be synthesised and released into the bloodstream."
"Headache, breathlessness, and dizziness," said Michael, one of the biologists leaning in over my other shoulder.  He smelled strongly of cigarette smoke.  "And when it falls over, does the race condition persist?"
"Uh...."  I had to trawl through the code looking for the answer while Belinda and Michael talked quietly over my head.  "Uh, it looks like falling over would break the race condition, so... Frankie... would start breathing again."
"Friday afternoon," said Michael promptly.  "Happened three times."
"Three?"  Belinda didn't sound happy.  "Surely this race condition would only happen infrequently."
"Expectation of daily," I said.  "People breathe a lot during twenty-four hours, and that's the key to the condition."
"Bugger," said Belinda.  "Looks like we were right to hire a debugger after all.  So, how do you fix it?"
I stared open-mouthed at her, realising that my duties were increasing exponentially.

No comments: