Wednesday, March 7, 2012

Context Switching

Computers seem to able to do many things at the same time. Before the days of multi-core central processing units (CPUs), this was accomplished with a bit of magic. The computer could never perform simultaneous actions and had to rely on tricks to make it seem like that was happening. Assuming the CPU was trying to work on 3 different tasks at the same time, it would do the following:
  • Work on task 1 for a bit and then make a note of what was done.
  • Work on task 2 for a bit and then make a note of what was done.
  • Work on task 3 for a bit and then make a note of what was done.
  • Repeat until all 3 tasks are completed.

The process of "making a note of what was done" is known in computer science as a "context switch." There is a lot that takes place on the computer, but it runs so fast that the user thinks 3 things are going on at the same time.

People are not much different than computers. We also have to perform a "context switch" when we are trying to do multiple things at the same time. During the course of writing this blog entry, I was also on the phone working on solving a computer hardware problem. As long as I didn't have to participate in the conversation, I could add to the post. The moment someone needed my help, I had to stop typing and pay attention to the conversation. There was no need to "make a note of what was done" because it remained on my computer screen. Therefore context switches were fairly painless. There was a little time lost when I was no longer needed on the phone as I had to regain my train of thought, but it wasn't too painful.

Things that make context switching hard for people are the number of simultaneous tasks and the duration allowed to work on those tasks. Typing and talking on the phone worked because I was only trying to do two things. It also worked because I was needed on the phone only for a minute out of every quarter hour (it was a long phone call). Now if I had been on the phone, driving in traffic, and trying to eat a burger, things would not be so simple. While I might get away with it once or twice, eventually I wouldn't be able to context switch fast enough and might cause an accident. That is why I never eat and drive at the same time . . . while also trying to talk on the phone.

No comments:

Post a Comment