Unnecessary Context Switches & the Myth of MultitaskingPosted: March 28, 2011
Thanks to Tony C. who sent this suggestion as follow-up to the recent Social Media post:
[Disclosure: I haven’t read the book and so this is not an endorsement.]
This book deals with “Human Multitasking” – not operating systems. There is a common theme to the discussions of this book and to other content about human-multitasking. Your “cognitive attention” can be directed to any particular task but sharing attention across multiple tasks will reduce performance.
For example, if you read an important email while in a conversation then one activity or both will suffer. And, you might not even be aware of the impact.
It is worth noting the difference between conscious and sub-conscious tasks. With sub-conscious tasks, most people can walk and talk at the same time; programmers can type and eat; some of us can even talk, eat and type all at once!
Cost of the UCS (Unnecessary Context Switch)
So what happens in multitasking between conscious tasks? In reality, a person’s attention will switch between tasks.
It’s just like in context switching in operating systems and like most programmers I find context switching a challenge, especially when working on harder problems.
Each computer context switch has a non-trivial cost including the time to store and restore memory for each context. Operating systems are designed to optimize context switches even though they are measured as only fractions of a micro-second.
A human context switch might take seconds, minutes or longer. The more complex the task, the longer the switch will take.
Yet, working environments and desktops sometimes feel like they are set up to create many UCS’s.
When people multitask, particularly if they switch rapidly and repeatedly between tasks, the tasks take longer and errors go up. Remembering where you were on a task is a big part of the challenge. The more complex the tasks and the more attentive memory required, the greater the cost (or loss or error) of each switch.
Too often I’ve thought and heard programmer comments like “I was working on this nasty bug when Joe dropped by. Where was I up to?”
Doing tasks sequentially seems contrary to a lot of today’s social pressures and office expectations. The ultimate multi-tasker is the “Octopus” who has all eight hands doing separate tasks all at once: email, phone, Blackberry, Facebook, stock ticker and all that. I think most of us have met an octopus.
Alas, the octopus is considered cool and even macho in some environments.
Maybe that works for some jobs, but not for programming and most other high concentration jobs. These are best done in sequence. Doing tasks sequentially requires planning and discipline (not every programmer’s strength!). Even if it’s not cool to focus, it saves time and effort, it reduces bugs, and it will be far less stressful.
If your environment doesn’t encourage this, then it’s a good conversation to start.
Returning to the article by Mark Harrison sent in by Tony C, it describes focused attention as a “form of meditation”. That’s “the zone” for programmers. Put simply, attempting to multitask will keep a programmer from entering the most productive and rewarding state. So beware the temptations of distractions, interruptions, the lure of always-on social media, and prepare to defend against unnecessary context switches.