What we can learn about multitasking from machines

Best Of / Productivity

I’ve been thinking a lot recently about focus and dealing with many projects at once. I’ve heard many people say that it is difficult, if not impossible, to be 100% committed to more than one endeavor at any time. Furthermore, the more stuff you have on your plate, the more everything simultaneously suffers. In an opportunity dense world, not everything has equal value. Indeed, I can relate to having spent too much time on value-poor projects in pursuit of a paycheck. I can identify at least a couple of occasions this year where really amazing opportunities had to be passed over because I was in the middle of client work deadlines.Jon Lebkowsky writes about the difficulty of multitasking:

I was good at balancing many tasks, I could keep a lot of balls in the air without dropping them. As I matured, I realized that depth has more value than breadth, and in recent years I’ve been trying to learn to focus and do a few things well.

Jon is an interesting guy who is smart and involved in many worthwhile projects. I like to think that most of my friends fall into this category of diverse interests and passions. But how do we cope? When a thousand things come at you and all of them seem equally interesting or even lucrative at the onset, how do you decide which are most important? I’m still figuring out what my personal filters need to be.

In the meantime, there are projects to complete and things to accomplish.

How computers multitask

I distinctly remember a project in a computer architecture class where we designed multitasking systems and applications that ran on top of them.

Inside your PC is a device called the Central Processing Unit (CPU) which is, loosely, the “brain” of the computer. Its primary function is to do math as quickly as possible.

When somebody says they have a 3.0Ghz computer, they are referring to the CPU’s speed at doing math. 3.0Ghz translates into 3 billion arithmetic operations per second.

We’re only counting very simple binary operations (add, subtract, bitshift, etc). However, if you do enough small bits of math, and you do them very fast (ex, 3 billion per second), things like youtube videos and email emerge.

When you turn on your computer, you likely have dozens of programs that load automatically. The computer itself runs an operating system (ex. Windows or OS X) that, in turn, has dozens or hundreds of processes that need to run all the time, like the subsystems that deal with file management or the mouse cursor display. As soon as we load our email program or web browser, the computer adds a whole new set of threads of activity on top of the current workload.

So you are taking the limited resource of tasks per second and dividing it up among a large set of activities. That’s why when you have 50 applications open at once, you might notice the computer starting to drag (or why you have to reboot every once in a while to “clear the deck.”)

However, from our human perspective, most of the time, it appears the computer is not even breaking a sweat despite the myriad tasks it’s completing about every second. Never mind that you can easily identify the CPU on an opened computer because it usually has it’s own cooling fan or large spiky projections that help distribute the heat generated by so much math. The computer works really hard to be that fast.

Here’s the thing: our puny human brains are actually faster. MUCH faster. But we’ll get to that in a little bit.

The CPU can, roughly, do only one math operation at a time. Most interesting things a computer can do require billions of math operations to complete. If a computer only had to do one interesting thing at a time that required multiple steps or tasks, the fastest way to complete that single problem is to begin at the beginning and work through until it’s completed (i.e. not to get sidetracked doing anything off of the critical path).

So let’s look at an example.

Suppose a computer has a problem that requires 10 small math operations to complete and lets say that the computer can only process 10 math operations a second. This means the computer will accomplish this problem in 1 second:


It follows that if a CPU can work only one small step at a time, then if it has 2 complicated projects to complete each with 10 small steps, it takes 20 steps, or 2 seconds to complete. The diagram below shows the computer only working on one complicated project at a time. It completes the first project and then starts the second project. This is called “sequential processing.”

Untitled 1

If computers actually worked that way, we would be so frustrated that we would bang our heads on our keyboards and probably spend more time outside.

Right now, your computer is doing, easily, a few million extremely complicated processes (ex. the video rendering that causes these words to show up at the right place on your screen). If you had to wait for the first million projects to complete before the computer started the next million, it would take minutes for your mouse to move a couple pixels in any direction.

So we need something like this:

Untitled 2

Notice how we haven’t saved any time at all. However, the perception is that lots of things are finishing at around the same time. That’s all computer multitasking is about — it’s just getting things finished at a time which seems acceptable to the end user.

For complex problems which require many steps, the computer maintains a set of holders in its memory called “registers.” At any given time, as the computer is working through a multi-step problem, it can take the state of everything it is working on in its CPU and put all the values into some of the registers. It can also load up a different collection of values from another group of registers and pick up where it left off. This is basically how the CPU can keep track of many complicated problems in various states of completion. This process is called “context switching” and happens every so often (i.e. millions of times per second.)

We can amend our previous example by adding context switching tasks. The worst case scenario has you switching projects after every task. Let’s simplify and say that a context switch takes the same amount of time as any other small task.

Untitled 3

Whoa! We almost doubled the amount of time required to complete just two projects by adding context switching. In fact: we get exponential increases of time for every new project we add a multitasked project just because of the overhead of having to think about a different set of information.

Computers deal with this in several ways:

  • They optimize the time it takes to context switch by storing as minimal amount of information as necessary to continue working on a problem.
  • The engineers who build CPUs design chips so they are physically able to context switch faster than anything else.
  • They add more brains. The only way a computer can physically do more than one math problem at a time is by adding additional CPUs. So when we hear “Quad-core CPU” you have 4 math machines working at the exact same time. This adds a whole new layer of complication because how you split up a problem among multiple processors will affect the speed of your computer. The Saguaro 2 supercomputer has hundreds and hundreds of core CPUs and requires elaborate water cooling systems to keep it from melting down, but can handle 50 trillion math operations per second.
  • They can reduce the number of times they context switch by chunking their problems differently. Rather than switch between every task, for example, they might switch between every 5th task.
  • They can pre-process complicated tasks so that they are prioritized and broken up into parts that will complete faster. Major branches of computer science deal with the serious math behind this approach.

Multitasking is a tough problem for a machine. There’s a huge amount of computer science around how you schedule and prioritize tasks and how they are broken down so that the most complicated projects don’t consume too many resources at the wrong time.

Many times a “faster” computer is not faster at all. The software is just tweaked, via mathematics, to deliver finished projects sooner. Projects which deliver the most perceptual impact (ex. graphics processing) are usually prioritized.

Human Multitasking

Our brains are capable of about 100 000 000 000 000 000 operations per second. That is at least a hundred thousand times faster than the fastest super computer requiring all that water cooling and government money.

So why are we so bad at multitasking?

We, thankfully, do not perceive each of the trillions of operations required to observe, wonder, tinker and build things in our world around us. On a conscious level, we do not manage the the tiny tasks of our brain computers.

We operate on a higher level. Our self-awareness is an application running on top of a really fast wet operating system. However, as is of any abstraction, as we simplify and aggregate functions, we start lose flexibility and power. We don’t have complete control over ourselves. We are prone to mental illness (bugs in our synapse programming), there are daemon processes that run on autopilot, backing up our memories and making sure the graphics displays of our visual processing render with a reasonable precision. Reasonable, but not perfect.

What’s a puny human mind to do when we can’t add CPUS (yet) and are limited by our core OS? We have to reduce our context switching. It’s the only way to get multiple interesting things done.

  • Eliminate tasks to reduce context switching.
  • Chunk tasks so you get as much done on one project before you must switch to another.
  • Focus on projects which provide the most perceptual impact. Those projects which provide you the most value, recognition, and velocity towards your passions should deserve more cpu time.
  • The final task of a project is the most important task. All effort should be placed on getting the final task crossed off the list. “The quicker you finish, the quicker you finish.”

I think those four things are easier said than done.

As a parting shot, after reading many self-help productivity books and blogs, trying to implement system after system of productivity, and listening to people who might know better, I’ve come to the conclusion that getting things done can actually be boiled down to one word: