Writing Fast Programs: A Practical Guide for Scientists and Engineers

Chapter 11: Multi-Tasking Basics

OVERVIEW

Though one may use highly optimized source code, compiled with optimized compilers, program execution ultimately reaches a point of maximum performance when running on a single computer running a single task. The answer to this performance wall may be parallel processing: breaking the problem into smaller pieces that can be solved concurrently. Before parallel processing is outlined in Chapter 12, however, a brief introduction of multi-tasking is presented in Chapter 11.

Multi-tasking can take many forms, and is perhaps a term often used without precise definition. The concepts of multi-tasking have significant consequences on the way a program interacts with the operating system, hardware and, in the case of some parallel architectures, other computers. In this chapter, some key terms related to multi-tasking and basic multi-tasking programming is presented.

11.1 MULTI-TASKING TERMS

The term multi-tasking itself warrants a basic definition and some discussion. Multitasking refers to the ability, or apparent ability, of a computer to run more than one program at one time. Strictly speaking, a single processor can only execute a single stream of instructions at any one time, but the illusion of multi-tasking can be made by relatively rapid context switching.

A context switch in a protected mode system occurs when the OS and hardware switch instruction streams from one program to another. This involves considerable overhead at the system level, as presented in Chapter 3. However, even with such overhead, a single processor machine gives the appearance of running multiple programs. Context switches can...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Safety Mats
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.