One of the reasons this blog is called “Live & Code” is because Computer Science (and by extension programming) is one of the lenses through which I view the world. There are often parallels between the way we think and the way computers work. I don’t think that this is an accident; the term “computer” used to refer to a human being whose profession was computing values. These people would sit and work through algorithms to calculate values that would be used in scientific research.
One of these parallels between humans and computers is the way that we multitask. Computers only seem to multitask by switching between tasks rapidly, with the exception of new multi-core and multi-processor systems, which can run as many tasks in parallel as there are cores or processors. So it was interesting to read recently that the prevailing theory is that humans multitask in precisely the same way!
Analogous to a multitasking CPU, current experimental psychology research shows that interference occurs when we attempt to perform even simple tasks simultaneously. There are certain exceptions to this, particularly when one of the two tasks is stored in “muscle memory”, but this is because we can perform such tasks without even thinking about them. In many other cases, the effectiveness with which we perform the tasks is diminished when we are doing more than one task at the same time.
It is also common wisdom in IT that when somebody is deep in his/her work (commonly referred to as flow), an interruption of even a few seconds can result in 15 minutes of lost productivity. While I’ve never verified the actual number, I have often had trouble putting myself back on a task after being jolted out of it by a short interruption.
When a CPU switches tasks, it must perform a context switch. The current state of the program that is running on the computer, including the values stored in the registers, a reference to the next instruction to execute, and other housekeeping information are stored in memory (RAM). When the program comes back, the stored information is put back into its proper places so that the CPU can pick up where it left off. This is a fairly costly operation as the CPU cannot access RAM even a fraction as fast as it can access its registers. Of course, this means that when a CPU runs two programs simultaneously, it is less efficient at each than if it were concentrating entirely on one program or the other. Determining when to switch to a different program is therefore an incredibly important concern in the design of modern operating systems.
I’ve witnessed human “context switching” in a co-worker of mine. When I knock on her door to ask her a quick question about work that I’m doing for her, she asks me to give her a moment and looks to be deep in thought. She then asks me to repeat my question and answers it with surprising conciseness and accuracy. She has told me that she needs to switch from the mindset of what she’s currently working on to the mindset of what I’m asking her or she can’t answer properly.
This isn’t to say that multitasking is bad, but I am acutely aware that when I do multitask, I am not going to be able to perform each task as effectively as if I were focused entirely on one. Also, there are certain points at which it is easier or more natural to switch from doing one thing to doing another, particularly where I’ve accomplished a sub-goal in the task or where I’ve written down detailed notes on the current state of what I’m doing, which makes it easier to switch back to it later.
What do you think?