Terms of art: Context switch

| 1 Comment | No TrackBacks

The second installment of “terms of art.”

context switch |ˈkɑntɛkst swɪtʃ| noun

The art

Computers can run more than one program at a time, yet many only have one CPU. Yet when I’m programming, I don’t have to include any logic about what to do if another program needs to take over for a while. How do modern computers manage this feat, then?

Whenever the operating system determines that a different process deserves some CPU time, it pauses the currently running program and resumes the other. This is called context switching. All of the registers on the CPU (encapsulating the entire state of the program) are saved in memory, and the other program’s registers are loaded into the CPU. Amazingly, this allows us to pause and resume programs as they’re running!

Saving and loading these registers takes substantially longer than a normal CPU operation, though. Despite this performance hit, context switches occur on the order of hundreds of times per second to maintain the illusion of multiple programs running simultaneously.

Out of context (no pun intended)

the cost associated with changing the task one is working on, usually referencing the time necessary to begin to be productive in the new task : after abruptly being pulled into the meeting, the engineer requested a few moments to context switch.

No TrackBacks

TrackBack URL: http://tr.ashcan.org/mt/mt-tb.cgi/174

1 Comment

Seriously. What kind of blog post is this?