Mailing List Archive

Support open source code!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tlug: Multithreading, how to learn?



At Wed, 20 Jan 1999 21:41:39 +0100,
mike.fabian@example.com wrote:
> What is  a  multithreaded  C or  C++  program,

You need to know what multithread is?
Thread is kinda "light-weight" process.
Instead of creating a new process by fork(),
you create a new "thread" by something like pthread_create().

The cost of creating a new thread is much lower
than creating a new process, and it's way much easier to share
data between thread than between processes.

It's often used to have multiple execution points
in the program, having several tasks running concurrently.


> for what purposes is multithreading needed

There are mainly two purposes for using multithread programing;

1. To make the program run faster.
2. To prevent the program to hang while doing some time-consuming
   calculation or operation.

The first one is usually meaningful only if you have multi-CPUs
and your OS supports multithreads running on different CPUs,
AND your task is very heavy or time-consuming.

The second one is perhaps the top most reason to use multithread.
You can have the program calculate, say, the julian set,
while enabling the user to interact with the GUI.


> how does one write a multithreaded C or C++ program?

I use pthread (POSIX-thead) library.
Actually it comes with RedHat Linux.
I'm sure they are also available for many other linux distributions.
I think pthread was embeded in the new glibc2, but not sure.

There're several books you can
find about multithreading in any bookstore.
I used "Multithreaded Programming with Pthreads,"
Sun Microsystems Press, A Prentice Hall Title,
Bil Lewis and Daniel J. Berg, ISBN 0-13-680729-1.
Covers not only pthread, but also OS/2, Windows, and Solaris.


--- Kenichiro TANAKA
-------------------------------------------------------------------
Next Technical Meeting: February 13 (Sat), 12:30 place: Temple Univ.
** presentation: XEmacs, by Steven Baur and Martin Buchholz
Next Nomikai: March 19 (Fri), 19:30   Tengu TokyoEkiMae 03-3275-3691
-------------------------------------------------------------------
more info: http://tlug.linux.or.jp                     Sponsor: PHT


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links