Re: [ROOT] Threading and windows: TThreads in general?

From: Marc Hemberger (hemberge@embl-heidelberg.de)
Date: Mon Mar 18 2002 - 10:11:17 MET


Hi Christian,

cstrato@EUnet.at wrote:

>Dear Rooters
>
>Maybe this is a good opportunity to ask some questions about TThread:
>
>1, In which cases would it be recommended to use class TThread?
>
If you can not think of some use for threads in your application, then 
you don't need them ;-) But I think, if you want to see some of the uses 
of threads in general, take a look at Valeris 'Literature List' in one 
of his previous mails:

TrollTech Web site http://doc.trolltech.com/2.3/threads.html says:

" . . . This document is intended for an audience that has knowledge 

and experience with multithreaded applications. Recommended reading: 

  a.. Threads Primer: A Guide to Multithreaded Programming 
  b.. Thread Time: The Multithreaded Programming Guide 
  c.. Pthreads Programming: A POSIX Standard for Better Multiprocessing (O'Reilly Nutshell) 
  d.. Win32 Multithreaded Programming

Take also a look at http://go4.gsi.de.

>
>2, Support for Dual-Processor machines:
>Sorrowly, I do not have such a machine :-(, but for interest:
>If you write programs in root and want your program to take advantage
>of a dual-processor machine:
>What is the best way to achieve this goal?
>Do you need to use PROOF?
>Would TThread support dual-processors?
>As far as I understand, Mach (MacOSX) threads support SMP. Does
>root TThread support this? What about Linux? Does not WinNT also
>support threads?
>
Dual processor machines are a bit a different topic. The simplest way of 
exploiting two CPUs is the use of two processes, which each use one 
processor. They act independently, so they are really independent.

When you want to use only one process, then you might want to use 
threads within a single process. But then, sharing resources in one 
process so that they can be used within different threads can and will 
cause an overhead, which reduces the performance of your program may be 
a lot.

Most of the SMP implementations are worked out quite well (even for 
Linux;-), so the OS can deal with it in general. Cache coherency is 
causing troubles, but works well.

Don't expect too much of a multiprocessor machine when you use threads. 
What you will get is at first trouble, then more trouble and in the end 
perhabs a gain of 50% in performance, but never the expected 100% (as 
you would have with two didtinct processes). At least what my experience 
tells me (from Linux, HP, Sun and AIX multi-processor machines).

>
>3, The tutorial spyserver.C shows how a TServerSocket can handle
>requests from two or more clients. No threads are necessary.
>In which cases would threads be necessary?
>Could this tutorial be expanded to show how to use TThreads?
>
Hmm, the server uses one socket, different clients attach to this port 
and "spy" for histograms. Imagine the case, that you want to use 
different sockets ... Check for the Go4 page, which does something like 
that: a per-client connection in a thread, which will never/not block, 
when nothing comes.

>
>Thank you.
>
>Best regards
>Christian
>
Greetings,

Marc

>
>----------------------------------
>C.h.r.i.s.t.i.a.n  S.t.r.a.t.o.w.a
>V.i.e.n.n.a,  A.u.s.t.r.i.a
>
>
>
>Valeri Fine wrote:
>
>>Hello Joe,
>>
>>>Hi Rooters,
>>>
>>>I was reading the Thread section in the root manual and browsed through some
>>>root mailing list messages> Sorry , but its not 100 % clear for me: DO ROOT
>>>threads work under windows ??
>>>
>>  It is not clear what did you mean  "ROOT thread".
>>  ROOT system has some class called TThread.
>>  That has not been implemented under Win32 yet.
>>
>>>It looks like the main problems are in
>>>graphics and cint, so if my classes do NOT use root graphics (QT instead)
>>>and run as a MSVC compiled exe and NOT in cint interpreted, can I than use
>>>SAFELY threads under windows ??
>>>
>> None can run threads safely unless one knows what "thread" is.
>> None should use threads unless he/she knows the strong reasons to do so.
>> None can avoid using CINT within ROOT package.
>>
>>>If so, what happens, if a thread executes QT classes ? Is the system
>>>correctly executing everything as a thread, or would something like this
>>>crash because of qt's owned message loop ?
>>>
>> Nothing happens unless the codes run by different threads have to share
>> their data. It doesn't matter whether qt "owns the message loop" or not.
>> On other hand if your threads do not share any data then there is no reason
>> to create these threads at all. They can be replaced by two independent
>> processes.
>>
>>TrollTech Web site http://doc.trolltech.com/2.3/threads.html says:
>>
>>" . . . This document is intended for an audience that has knowledge
>>
>>and experience with multithreaded applications. Recommended reading:
>>
>>  a.. Threads Primer: A Guide to Multithreaded Programming
>>  b.. Thread Time: The Multithreaded Programming Guide
>>  c.. Pthreads Programming: A POSIX Standard for Better Multiprocessing (O'Reilly Nutshell)
>>  d.. Win32 Multithreaded Programming
>>
>>  Hope this helps.
>>                                                    Valeri
>>
>>>Thanks for any clarification
>>>
>>>Joe
>>>
>>>
>>>
>>>_________________________________________________________
>>>Do You Yahoo!?
>>>Get your free @yahoo.com address at http://mail.yahoo.com
>>>
>

-- 
Dr. Marc Hemberger
                      /\_/\
                     ( o.o )
                      > ^ <
             |\      _,,,---,,         EMBL
      ZZZzz  /,`.-'`'    -.  ;-;;,_    C&N Group
            |,4-  ) )-,_. ,\ (  `'-'   Meyerhofstr. 1
           '---''(_/--'  `-'\_)        69117 Heidelberg
                                       Germany        privat: 
    Marc.Hemberger@embl-heidelberg.de                 MHemberger@csi.com
 
      ** Disclaimer: My views/comments/beliefs, as strange as they are, are my own.**



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:46 MET