Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #649

Re: User threads

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From Alexander Terekhov <terekhov@web.de>
Newsgroups comp.programming.threads
Subject Re: User threads
Date Thu, 20 Oct 2011 14:32:21 +0200
Organization A noiseless patient Spider
Lines 73
Message-ID <4EA014D5.A33A0B42@web.de> (permalink)
References <66835f2d-f95e-410a-834a-104a1345ae02@x20g2000vbl.googlegroups.com> <017v97derjj10laokopv39l4kmrer84kpc@4ax.com>
Reply-To terekhov@web.de
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
Injection-Info mx04.eternal-september.org; posting-host="MCbSEzW5qwGLFMNXJh39IQ"; logging-data="24672"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/RsitJjshn7/g3czxH3agsYtC+BpgMSKY="
X-Mailer Mozilla 4.77 [en] (Windows NT 5.0; U)
X-Accept-Language en
Cancel-Lock sha1:kOnf37mmWilacvA08+Or7S+nwJI=
Xref x330-a1.tempe.blueboxinc.net comp.programming.threads:649

Show key headers only | View raw


Robert Wessel wrote:
[...]
> Hybrid schemes have been implemented where N user level threads are
> mapped onto M kernel threads, the goal being the combination of low
> overhead of user level threads and the multiple processor support of
> kernel threads.  This is actually quite attractive, since the vast
> majority of threads exist more for control-flow reasons, rather than
> making use of multiple processors.  But the difficulty of
> implementation has mostly eliminated that as an approach.

From 

http://publib.boulder.ibm.com/infocenter/aix/v7r1/topic/com.ibm.aix.prftungd/doc/prftungd/prftungd_pdf.pdf

"Thread tuning

User threads provide independent flow of control within a process.

If the user threads need to access kernel services (such as system
calls), the user threads will be serviced by associated kernel threads.
User threads are provided in various software packages with the most
notable being the pthreads shared library (libpthreads.a). With the
libpthreads implementation, user threads sit on top of virtual
processors (VP) which are themselves on top of kernel threads. A
multithreaded user process can use one of two models, as follows:

1:1 Thread Model

The 1:1 model indicates that each user thread will have exactly one
kernel thread mapped to it. This is the default model on AIX 4.1, AIX
4.2, AIX 4.3, and AIX 6.1. In this model, each user thread is bound to a
VP and linked to exactly one kernel thread. The VP is not necessarily
bound to a real CPU (unless binding to a processor was done). A thread
which is bound to a VP is said to have system scope because it is
directly scheduled with all the other user threads by the kernel
scheduler.

M:N Thread Model

The M:N model was implemented in AIX 4.3.1 and is also now the default
model. In this model, several user threads can share the same virtual
processor or the same pool of VPs. Each VP can be thought of as a
virtual CPU available for executing user code and system calls. A thread
which is not bound to a VP is said to be a local or process scope
because it is not directly scheduled with all the other threads by the
kernel scheduler. The pthreads library will handle the scheduling of
user threads to the VP and then the kernel will schedule the associated
kernel thread. As of AIX 4.3.2, the default is to have one kernel thread
mapped to eight user threads. This is tunable from within the
application or through an environment variable.

Depending on the type of application, the administrator can choose to
use a different thread model. Tests on AIX 4.3.2 have shown that certain
applications can perform much better with the 1:1 model. The default
thread model was changed back to 1:1 from M:N in AIX 6.1, but for AIX
4.3.1 to AIX 6.1, by simply setting the environment variable
AIXTHREAD_SCOPE=S for that process, we can set the thread model to 1:1
and then compare the performance to its previous performance when the
thread model was M:N.

If you see an application creating and deleting threads, it could be the
kernel threads are being harvested because of the 8:1 default ratio of
user threads to kernel threads. This harvesting along with the overhead
of the library scheduling can affect the performance. On the other hand,
when thousands of user threads exist, there may be less overhead to
schedule them in user space in the library rather than manage thousands
of kernel threads. You should always try changing the scope if you
encounter a performance problem when using pthreads; in many cases, the
system scope can provide better performance."

regards,
alexander.

Back to comp.programming.threads | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

User threads divcurl <divcurl@europe.com> - 2011-10-19 18:06 -0700
  Re: User threads Robert Wessel <robertwessel2@yahoo.com> - 2011-10-19 23:16 -0500
    Re: User threads Alexander Terekhov <terekhov@web.de> - 2011-10-20 14:32 +0200

csiph-web