Game Development Reference
In-Depth Information
Chapter 20
Introduction to
Multiprogramming
The general term for creating software that can figuratively or actually run in multi-
ple, independent pieces simultaneously is multiprogramming.
There are few subjects in programming as tricky as this. It turns out to be amazingly
simple to get multiple threads chewing on something interesting, like calculating
to
1,000,000 digits. The difficulty comes in getting each of these jobs to play nicely with
each other
π
s memory and getting them to send information to each other so that the
results of their work can be put to good use.
The code you will learn in this chapter will work on single or multiprocessor Win-
dows systems, but it is easy enough to port to others. The concepts you will learn are
also portable to any system that has threading built into the operating system.
The first question you should ask is why should we bother with multithreading at all?
Isn
'
'
t one thread on one CPU enough?
What Multiprogramming Does
A CPU is amazingly fast, and many desktop CPUs are now sitting solidly in the
2
3GHz range, and some systems on the market are peaking over 5GHz. If you hap-
pen to have a really nice lab and can get your transistors down to near absolute zero,
you can get it to switch at 500GHz like IBM and Georgia Tech did back in 2006. But
what does that really mean?
-
693
 
 
 
 
Search WWH ::




Custom Search