This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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: Thread model: simple and C


On 5 August 2010 04:54,  <Marcos_David.Dione@sophia.inria.fr> wrote:
> On Wed, August 4, 2010 8:45 pm, Jonathan Wakely wrote:
>> On 4 August 2010 13:56, Marcos Dione wrote:
>>> ? ?so, in short: does a simple Thread model have any impact on C-only
>>> programs that could use threads? in particular, how it does impact
>>> Boehm's GC usage in a C-only program? if the impact is negative, would
>>
>> IIUC GCC's thread model doesn't affect how you use threads in your own
>> program, only how GCC's libraries (e.g. the C++ and ObjC runtimes) use
>> threads.
>
> ? ?so it is wrong that some projects (in particular, Boehm's GC) test
> thread availability by looking at the output of 'gcc -v' because that
> would be assuming that it will use the same libraries compiled along
> with that gcc?

I don't know that it's "wrong," it might just be a requirement of
using that project that you use suitable runtime libraries that match
the compiler used to build the project.  It's not up to GCC to decide
other projects' requirements.

> in particular, this platform uses its own libc
> implementation... also, you don't mention libc at all. is it different

I have no idea, that's something you'd have to ask the libc
maintainers, not the GCC list.

> with it? and last one: can anyone explain *how* it affects stdlibc++
> and others?

The library is called libstdc++, see
http://gcc.gnu.org/onlinedocs/libstdc++/manual/ext_concurrency.html
and http://gcc.gnu.org/onlinedocs/libstdc++/manual/using_concurrency.html
and for more details see the code. With thread model "single" all
calls to atomic operations are always turned into plain integer
arithmetic.  So for example, std::string reference counting uses
simple increments and decrements, with no memory synchronisation and
no protection against data races.  You could still write a
multithreaded program which uses std::string, but the library will
behave as though you have a single-threaded program so if you share
objects between threads you will get problems.
Additionally, features of the library which require thread-related
components such as mutexes will be disabed and unavailable if GCC was
configured without a supported thread model.


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