This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libstdc++, how to set gcc on a multithread environment ?



--- Em dom, 26/7/09, Jonathan Wakely <jwakely.gcc@gmail.com> escreveu:

> De: Jonathan Wakely <jwakely.gcc@gmail.com>
> Assunto: Re: libstdc++, how to set gcc on a multithread environment ?
> Para: "Jose Luis Marchetti" <joseluismarchetti@yahoo.com.br>
> Cc: libstdc++@gcc.gnu.org
> Data: Domingo, 26 de Julho de 2009, 15:57
> 2009/7/26 Jose Luis Marchetti:
> >
> > Hi,
> >
> > After reading gcc documentation and this link:http://gcc.gnu.org/onlinedocs/libstdc++/manual/using_concurrency.html,
> I am not sure of:
> >
> > 1) Only adding -pthread option when invoking gcc
> suffices ?
> 
> Suffices for what?? Your question isn't clear.

I would like to safely run a multithread application that uses the libstdc++. -pthread option when invoking gcc is the only option I need to add ? Do I need this option at compiler time ?

> 
> > Here is what gcc documentation says:
> > -pthread Add support for multithreading using the
> POSIX threads library. This option
> > sets flags for both the preprocessor and linker. It
> does not affect the thread
> > safety of object code produced by the compiler or that
> of libraries supplied with
> > it.
> >
> >
> > 2) I have already added the pthread lib on my link,
> but it looks like I also need to add the -pthread option to
> the compiler.
> 
> Yes, probably.
Exactly, also not clear for me as well.

> 
> > 3) The link I showed above says:
> > "Allocators called while a container or element is
> constructed uses an internal lock obtained and released
> solely within libstdc++ code (in fact, this is the reason
> STL requires any knowledge of the thread configuration)."
> >
> > So this is the reason we need to use the -pthread
> option when invoking gcc ? Any other reason ?
> 
> Depending on the platform, the -pthread option might affect
> the
> preprocessor, e.g. defining _REENTRANT, and that can affect
> the C
> library, and other libraries, so using -pthread can affect
> many
> things.
> 

When you say "defining _REENTRANT", that does not mean anything to me, I am a compiler user. As this subject is not clear for me, I would like to know ( or at least have some examples ) where the -pthread option makes difference.

> Jonathan
> 


      ____________________________________________________________________________________
Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]