* Thread model: simple and C
@ 2010-08-04 12:56 Marcos Dione
2010-08-04 18:47 ` Jonathan Wakely
0 siblings, 1 reply; 5+ messages in thread
From: Marcos Dione @ 2010-08-04 12:56 UTC (permalink / raw)
To: gcc
first of all: I'm not subscribed to gcc's ML, so please cc: in any answers.
I'm cross-compiling an application to a platform whose SDK brings a gcc
which reports 'Thread model: single'. even so, the platform implements a
rudimentary thread support (a subset of posix), which leads me to think
that it should be possible to use it in C programs.
why? because the only reference to Thread model I could find in gcc's
doc is in libstdc++'s manual[1] and no other useful reference about simple
thread model.
in particular, my main concern is not about our own program but a library
we use, namely, Boehm's GC, which I see is included in gcc's code. I already
asked Boehm itself (via the GC's ML[2]) but he's not sure what are the
implications.
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
you say that the original gcc is compiled with the wrong flags, given that
there is a bit of pthreads implementation in the platform?
--
[1] http://gcc.gnu.org/onlinedocs/libstdc++/manual/using_concurrency.html
[2] http://comments.gmane.org/gmane.comp.programming.garbage-collection.boehmgc/3680
--
Lic. Marcos Dione
Engineer Expert - Hop Project
http://hop.inria.fr/
INRIA Sophia Antipolis - Méditerranée
Phone: +33 (0)4 92 38 79 67
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Thread model: simple and C
2010-08-04 12:56 Thread model: simple and C Marcos Dione
@ 2010-08-04 18:47 ` Jonathan Wakely
2010-08-05 6:40 ` Marcos_David.Dione
0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Wakely @ 2010-08-04 18:47 UTC (permalink / raw)
To: Marcos Dione; +Cc: gcc
On 4 August 2010 13:56, Marcos Dione wrote:
>
> I'm cross-compiling an application to a platform whose SDK brings a gcc
> which reports 'Thread model: single'. even so, the platform implements a
> rudimentary thread support (a subset of posix), which leads me to think
> that it should be possible to use it in C programs.
>
> why? because the only reference to Thread model I could find in gcc's
> doc is in libstdc++'s manual[1] and no other useful reference about simple
> thread model.
Do you man single, not simple?
See the docs for --enable-threads at
http://gcc.gnu.org/install/configure.html
> 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.
> you say that the original gcc is compiled with the wrong flags, given that
> there is a bit of pthreads implementation in the platform?
If the configure command for GCC doesn't show --enable-threads=no or
--disable-threads then it probably means that configure tried to find
the functions needed for --enable-threads=posix and failed, so the
rudimentary support is not enough.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Thread model: simple and C
2010-08-04 18:47 ` Jonathan Wakely
@ 2010-08-05 6:40 ` Marcos_David.Dione
2010-08-05 9:58 ` Jonathan Wakely
0 siblings, 1 reply; 5+ messages in thread
From: Marcos_David.Dione @ 2010-08-05 6:40 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: Marcos Dione, gcc
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? in particular, this platform uses its own libc
implementation... also, you don't mention libc at all. is it different
with it? and last one: can anyone explain *how* it affects stdlibc++
and others?
--
Lic. Marcos Dione
Engineer Expert - Hop Project
http://hop.inria.fr/
INRIA Sophia Antipolis - Méditerranée
Phone: +33 (0)4 92 38 79 67
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Thread model: simple and C
2010-08-05 6:40 ` Marcos_David.Dione
@ 2010-08-05 9:58 ` Jonathan Wakely
2010-08-05 13:49 ` Thread model: single and C programs Marcos Dione
0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Wakely @ 2010-08-05 9:58 UTC (permalink / raw)
To: Marcos_David.Dione; +Cc: gcc
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Thread model: single and C programs
2010-08-05 9:58 ` Jonathan Wakely
@ 2010-08-05 13:49 ` Marcos Dione
0 siblings, 0 replies; 5+ messages in thread
From: Marcos Dione @ 2010-08-05 13:49 UTC (permalink / raw)
To: Jonathan Wakely; +Cc: gcc
On Thursday 05 August 2010 10:33:11 Jonathan Wakely wrote:
> On 5 August 2010 04:54, <Marcos_David.Dione@sophia.inria.fr> wrote:
> > 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.
you're right, I was asking in the general sense. from the rest of the mail
it seems that a check like that is meaningful only if you're going to use any
of the libraries that comes with gcc (which is not my case). now, is it
possible that if a project does not use libstdc++ or any other library that
comes with gcc still be affected by the thread model? for example, does it
affect the C code produced? you only mentioned that it doesn't affect on the
usage of threads.
> > 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.
ah, sorry, the fact that libstdc++ is part of gcc got me to think that
glibc was also, but didn't check.
> The library is called libstdc++
yes, sorry, that's what happens when you answer technical mails (or
otherwise) at 5AM.
> 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.
just to be sure, you're still talking about libstdc++?
--
Lic. Marcos Dione
Engineer Expert - Hop Project
http://hop.inria.fr/
INRIA Sophia Antipolis - Méditerranée
Phone: +33 (0)4 92 38 79 67
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-08-05 9:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-04 12:56 Thread model: simple and C Marcos Dione
2010-08-04 18:47 ` Jonathan Wakely
2010-08-05 6:40 ` Marcos_David.Dione
2010-08-05 9:58 ` Jonathan Wakely
2010-08-05 13:49 ` Thread model: single and C programs Marcos Dione
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).