Re: Did I misunderstand the concept of threads?
On 2008-02-07 08:04:22 -0500, Lars Uffmann <aral@nurfuerspam.de> said:
In a previous post, I was asking about thread programming in C++ and
was pointed to the boost libraries. However, now I am reading in the
boost.thread documentation at
http://www.boost.org/doc/html/thread.html#thread.glossary / Table 15.26
for Thread State that "Running" means: "Currently executing on a
processor. Zero or more threads may be running at any time, with a
maximum equal to the number of processors."
Yup. That's simply a physical fact: with only one processor, only one
thread of execution can run at a time.
So does that mean multithreading is only intended for multi-processor
environments?
No. On single-processor systems, the threading mechanism switches the
processor from one thread to another, giving each running thread a
chunk of run time. In fact, the same thing happens whenever there are
more threads than there are processors.
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)