Tuesday, April 12, 2011

The Truth about Multitasking

I've been reading recently about scientists studying multitasking and declaring that we're no good at it. I have something to say about that.

First, some background. Multitasking is a word borrowed from computer science and reapplied to life, which doesn't happen that often. In a computer's operating system, at the very heart of it, is a switching mechanism for doing a little bit of work on a lot of running programs, in a "round robin" approach, so that each of them gets a little time slice. No one program gets to run unbridled for any length of time. Processors are so blindingly fast that you can't tell the difference. A typical CPU today can execute many billions of instructions per second, so the fact that it is switching back and forth between, say, your browser and your email program and updating the display is done so many, many times per second that you couldn't possibly perceive it.

But yes, the computer is multitasking. And guess what? It doesn't come for free.

To switch back and forth between the many processes running on your computer, the operating system does what is called a context switch. This is important, so pay attention. A context switch isn't just jumping around between processes. The CPU needs to also store the context from each process, so it can come back to it later. The context is as little as possible--a bunch of memory locations, a few details of what the processor was doing, and things like that. It's not unlike the folders on your desk that contain the context of your human tasks -- the bills that you might be needing to pay, or the phone number and resume of the job candidate you're about to call.

There are decades of research on operating systems that try to trim down how much context you need to save when switching between them. The less, the better, with a huge multiplier in efficiency for every little bit you don't have to store, because the CPU has to physically copy the information back and forth every time it does a context switch. So do you, by the way, when you multitask. Understanding this, and making your context storage small and efficient, helps a lot with multitasking efficiency. If you have to open up your Word document, or find the phone number, every time you get back around to a task, the startup cost is too great, and you spend all your time thrashing (a real computer science term, believe it or not) and not doing real work. It feels like real work, but if you're just opening and closing folders (contexts) you're not doing anything useful.

Now here's where it gets interesting.

Computers don't just switch evenly between all processes. They look around to see where time is best spent. For example, many processes are blocked on I/O (input/output). That means that they're waiting for a file to be opened from your disk, or something to come back from the "cloud" over the network, or any of various other wait states that are commonplace deep inside a computer. If a processed is blocked, you don't give it any time. Simple as that. More CPU time for the other processes.

See what I mean, about getting interesting?

In the real world, our I/O is blocked all the time, too. We're waiting for somebody to call us back. We're at a stop light. We're waiting for the DSL modem to reboot. We're standing in line at a store, or even worse, at the DMV.

Human beings are not stupid. We know, as a species, that we can use our blocked I/O time for something more valuable. It is why we text madly at stop lights, or talk on the phone at the DMV, or do things that seem anti-social to old people, but are good time management when done well.

When scientists study "multi-tasking" in the lab, they do it abstractly, with tasks that don't exist in the real world, and have very few wait states. So yes, it is less efficient to switch frequently between truly parallel tasks that have no wait states. You spend time context switching and lose efficiency. But that's not how the real world is, and that does not seem to be accounted for in these studies.

Consider the teenager listening to music, texting, talking on the phone, and doing homework. Crazy? Good multi-tasker? If you dissected this scenario carefully, you would see all kinds of wait states. Texting has big holes in the timeline, waiting for somebody to reply. Even talking on the phone is like that. You can tune out for a few seconds and the person you're talking to doesn't notice, or care. With some people, the talkers, you can help yourself to 30 seconds of not listening and they won't even notice. Listening to music can be a background task, requiring a different part of your brain than conscious thought. Gee, there actually is a fair amount of time left over for homework, as long as it's the kind of homework that doesn't require your frontal cortext (which is, alas, most of it): coloring in the graph for biology; searching for something on google; writing your name and the date at the top of each piece of paper.

In the study I linked at the beginning of this article, the "multi-tasking" was forced on people by interrupting them with annoying tasks, which did not allow them to make the context switch themselves, or save state. That's not a useful measure of multi-tasking, it's the reason we don't answer our phones and close the door at the office. Interruptions, I claim, are not a form of multi-tasking.

Anyway, I think it's time somebody did a study on human multi-tasking with the ideas of context switching and wait states deeply embedded in the study. I guarantee they would get very, very different results.

No comments: