Monday, June 13, 2011

Bog Dragons Do Not Support Multithreading

Multithreading is a technique in modern computer architectures to process multiple sets of instructions on a single CPU core. Different sets of instructions run in different threads, and the operating system switches between these threads. Unlike multi-core or multi-processer systems, multithreaded systems are not actually running these sets of instructions in parallel (at the exact same time). Instead, a single CPU core is rapidly switching between the threads to allow each to make progress.


The ability to multithread instructions allows modern computers to effectively do work "in the background". For example, the spell check operation in a word processor might run in a separate thread, allowing the user to continue to work as the full document is being spell checked. In the absence of multithreading, computationally expensive operations can cause the entire computer to "freeze" as the CPU is stuck on one task.


Ferr dove low as another bog lizard snapped at her from a nearby tree branch. She hated traveling through the bog. It was filled with nasty creatures, and it always smelled like… a bog. At least there was only a few miles left to go. She would be home in time for dinner. For a brief moment, Ferr let her mind drift and wondered what dinner would be.


Then, Ferr heard a loud screech. The sound sent a chill through her. It was a bog dragon, and it sounded hungry.


Bog dragons are particularly vicious creatures, especially with respect to fairies. In fact, fairies seemed to be either their sworn enemies or their favorite snacks. Nobody was really sure which it was. Regardless of the dragon's motivation, Ferr knew that she was in grave danger. She took off flying as fast as she could.


Ferr dodged trees as she flew through the swamp. Unfortunately, bog dragons are much smaller than regular dragons, being about the size of a house cat, and thus are able to maneuver quickly in the dense swamp. Ferr knew that she had little chance of winning this race. The bog dragon was both fast and familiar with the swamp. It was only a matter of time before it caught up to her.


Her mind raced, trying to find anything that would save her. She mentally ran through the list of all of her spells. Nothing seemed promising. She cursed herself for having not perfected any defense spells against a bog dragon. Bog dragon sightings were rare enough that she had never made it a priority. Now, that seemed like a mistake.


She could hear the bog dragon breathing behind her.


Distracted by the sound and her own thoughts, Ferr clipped a tree. Her left wing missed a beat, and she was thrown off balance. She spun through the air, trying to regain control. But, it was no use. She had been flying too fast. She barreled into the soft mud with a loud squish, sliding fifteen feet. She was coated from head to toe in brown bog mud.


Above her, the bog dragon circled eagerly.


As she scolded herself for not paying more attention, a memory popped into her head. Bog dragons were not multithreaded. They could not multitask. They could only ever do one thing at a time! No matter what it was, that one thing would occupy their full attention. Right now, the dragon was doing one thing: hunting her. But, if she could distract it with some other task, it would not be able to context switch. She could escape.


Ferr ran through the list of spells again in her mind. Finally, she hit upon the perfect solution: the spell of Mental Flash Cards.


Ferr had used this spell on herself to prepare for her finals last year. When cast, it ran through five minutes of simple math flashcards in the back of the target's mind. Ferr would use this to practice math while flying to school. Since the math was simple, she could balance the two tasks. She would quickly solve each flash card and then concentrate on flying: one card, one beat of her wings, one card, one beat of her wings, and so forth. As long as she switched between the tasks, she could do both safely. But, the bog dragon could not.


Hoping that she was remembering this characteristic of the bog dragon correctly, Ferr cast the spell. If she was mistaken, and the bog dragon could multitask, then giving it math flash cards would probably just anger it. It would be like having someone rudely scream "WHAT IS 1 + 3?" in your ear every few minutes. Nobody enjoyed that.


Three seconds later, the bog dragon flew directly into a tree. It fell to the ground with a squishy thud.


The spell had worked. The bog dragon was fully occupied with the flash cards. It was unable to switch between the flash cards and flying.


Ferr did not waste any time. She was up and flying immediately. The five minutes would give her enough time to escape.


Ferr looked back once. The bog dragon was lying on the ground looking miserable. Ferr could not feel too bad. After all, she would have been the dragon's lunch. And even though the dragon had lost its lunch, at least it would learn some simple math in exchange.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.