Multithreading?

Multithreading?

Post by Peter Seibe » Wed, 11 Oct 1995 04:00:00



Okay, I looked it up in an online dictionary and I sort of get it but
can someone explain what multithreading is and why it matters
(particularly for running a web server)? In responses to another
question of mine I was told that the crucial difference between
Solaris x86 and Linux was that Linux doesn't do multithreading. So
before I plunk down $1,200 for Solaris x86, can someone enlighten me.
Does multithreading happen automatically with a multithreading OS or
do programs have to be written to take advantage of it? Or whatever?
Please fill me in.

Thanks,
Peter

---------------------------------------------

The MoJo Wire      http://www.motherjones.com
---------------------------------------------

 
 
 

Multithreading?

Post by Michael L. Lew » Thu, 12 Oct 1995 04:00:00



> Okay, I looked it up in an online dictionary and I sort of get it but
> can someone explain what multithreading is and why it matters
> (particularly for running a web server)? In responses to another
> question of mine I was told that the crucial difference between
> Solaris x86 and Linux was that Linux doesn't do multithreading. So
> before I plunk down $1,200 for Solaris x86, can someone enlighten me.
> Does multithreading happen automatically with a multithreading OS or
> do programs have to be written to take advantage of it? Or whatever?
> Please fill me in.

> Thanks,
> Peter

> ---------------------------------------------

> The MoJo Wire      http://www.motherjones.com
> ---------------------------------------------

Mutithreading will happen automatically at the kernel level but not
at the user level. To get user level MT will require you to write you
code using threads. Then the kernel will schedule your threads to run
on as many CPU's as you have.

Unless less you plan on having more than one CPU MT code won't buy you
much especially if your programs are CPU intensive.

The Solaris DOOM port is a nice app (game) that shows the benefits of
having a MT app with 2 CPU's. Even running at a window size of 1024x768
its very fast on a 2 cpu sprac10.
--

====


 
 
 

Multithreading?

Post by Bil Lew » Thu, 12 Oct 1995 04:00:00


: Okay, I looked it up in an online dictionary and I sort of get it but
: can someone explain what multithreading is and why it matters
: (particularly for running a web server)? In responses to another
: question of mine I was told that the crucial difference between
: Solaris x86 and Linux was that Linux doesn't do multithreading. So
: before I plunk down $1,200 for Solaris x86, can someone enlighten me.
: Does multithreading happen automatically with a multithreading OS or
: do programs have to be written to take advantage of it? Or whatever?
: Please fill me in.

  MT is wonderful for many things.  Look it up:
http://www.sun.com/sunsoft/Developer-products/sig/threads/

  However that isn't a reasonable reason for a home user to skip Linux.

: Thanks,
: Peter

: ---------------------------------------------

: The MoJo Wire      http://www.motherjones.com
: ---------------------------------------------

--
Det ?r den som g?r vilse, som finner de nya v?garna


Developer Technical Evangelism

 
 
 

Multithreading?

Post by Raj (x07 » Thu, 12 Oct 1995 04:00:00


: Okay, I looked it up in an online dictionary and I sort of get it but
: can someone explain what multithreading is and why it matters
: (particularly for running a web server)? In responses to another
: question of mine I was told that the crucial difference between
: Solaris x86 and Linux was that Linux doesn't do multithreading. So
: before I plunk down $1,200 for Solaris x86, can someone enlighten me.
: Does multithreading happen automatically with a multithreading OS or
: do programs have to be written to take advantage of it? Or whatever?
: Please fill me in.

Reasons for making your web server multithreaded:

1. Less memory and processing overhead when handling multiple network
clients simultaneously.

 if you were to write a network server you would fork processes to
handle clients in parallel. An alternative is to create threads which has much
lesser overhead since the whole address space is not copied, but only some
things like stack, program counter and registers.

2. The communication between threads is much simpler compared to that
between processes.

Communication is done largely through various global variables and
synchronised using mutexes.

3. The program can be easily be made more responsive that otherwise since
blocking calls block only the thread not the entire process.

If the app is one process and get blocked while accessing a resource the whole
process with block. On the other hand, in a multithreaded app, this resource
can be requested in a independent thread which can then set a flag
indicating the success. While that thread is blocked the main thread
can perhaps indicate to the user that the data is on the way.
So,figuratively speaking you can avoid a clock
showing up at the user interface under any circumstance !!!

4. You can achieve parallel execution (using multiple proceccors,
if available) to a very fine granularity easily, compared to achieving
the same using multiple processes.

        In the case of your web server, you could have one main
thread initially.  When three clients connect simultaneously then you could
have three client threads to service each of these requests.  If any of
these requests require say a search of several files, you could spin off
independant threads to do them, while you wait for the completion and so on...

Regarding the other question.....

Well, for a program to take advantage of the multithread feature
should have to specifically written that way making use of either POSIX
API or Solaris Threads API. Otherwise
it can gain no advantage from the OS which provides such a feature.

However, IMHO, it is very advantageous to have an OS which is
multhreaded at the kernel since many of the resources that the kernel
and the add on layers manipulate are blocking in nature...For an
example take a look at the web site http://www.sun.com under the
developer products section.
They provide a paper which explains how NFS is improved if the server
is mulththreaded. The same can be extrapolated to the OS as well...
I dont know how well this OS (Solaris x86) takes advantage of this
feature itself... but the potential exists...

Did I miss something.... I will be glad if someone enlightens me.

Thanks,
Raj

: Thanks,
: Peter

: ---------------------------------------------

: The MoJo Wire      http://www.motherjones.com
: ---------------------------------------------

 
 
 

1. Multithreading on a multi processor computer



It might be a FAQ question, but anyway: are there any guidelines for
defining the optimal number of LWPs for one's program? Is it the
number of CPUs in the box? I don't think that thread or pthread
libraries fire up LWPs dynamically, so one have to do it on one's own.
Am I wrong here?

Thanks,

Dima

2. "-t" command line option

3. Multithreading in linux

4. How to Tell

5. Multithreading

6. GMT time conversion

7. Help: Who is running a Pentium with Lin

8. multithreading under linux

9. More cluelessness: file descriptors and multithreading

10. n_r3964 -- ad hoc async io vs. multithreading

11. Pthreads: Solaris 2.6 aren't multithreading

12. Segmantation fault with multithreading