public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: Question on pthread_cancel/pthread_exit and thread stack  unwind
@ 2004-09-16 21:04 lrtaylor
  2004-09-16 21:08 ` Yufeng_Xiong
  0 siblings, 1 reply; 9+ messages in thread
From: lrtaylor @ 2004-09-16 21:04 UTC (permalink / raw)
  To: Yufeng_Xiong; +Cc: gcc-help

Hi Yufeng,

I may be off, but I believe that pthreads is really separate from GCC,
so if stack unwinding doesn't occur, etc., etc., with pthread_cancel and
pthread_exit, it may be more of an issue to take up with the maintainers
of the pthread library on Linux.  You might try there and see what kind
of a response they give you...

Thanks,
Lyle


-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Eljay Love-Jensen
Sent: Thursday, September 16, 2004 2:47 PM
To: Yufeng_Xiong@ltx.com
Cc: gcc-help@gcc.gnu.org
Subject: Re: Question on pthread_cancel/pthread_exit and thread stack
unwind

Hi Yufeng,

 >I'm not sure how active you are involved with the GCC development...

I'm a user of GCC just like yourself, much like most of the people on
this 
forum.  This is a user-community supported self-help forum.

 >...is there a technical problem preventing this from happening or it's

just nobody is considering doing it?

Well, yes, it's a technical problem of sorts.  The C++ specification
does 
not support multithreading programming.

POSIX Threads in C/C++ are an "after market bolt-on", so to speak.

There are other languages which handle multithreaded programming better 
than C++:  Ada and Java come to mind.  Those are but two examples; I'm
sure 
there are many other languages which are multithread savvy.

 >We can consider other compilers but we really like to use GCC because 
then we can pretty much use the 'same' compiler for different platforms.

As I understand it, GCC supports Ada and supports Java.  So you could
stick 
with GCC.

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: Question on pthread_cancel/pthread_exit and thread stack  unwind
  2004-09-16 21:04 Question on pthread_cancel/pthread_exit and thread stack unwind lrtaylor
@ 2004-09-16 21:08 ` Yufeng_Xiong
  0 siblings, 0 replies; 9+ messages in thread
From: Yufeng_Xiong @ 2004-09-16 21:08 UTC (permalink / raw)
  To: lrtaylor; +Cc: gcc-help





On the same Solaris platform, using SUN's Workshop6.2 compiler,
there's no such problem, with the same pthread library, so the compiler
has something to do with it.

Yufeng




                                                                           
             lrtaylor@micron.c                                             
             om                                                            
                                                                        To 
             09/16/2004 05:04          <Yufeng_Xiong@ltx.com>              
             PM                                                         cc 
                                       <gcc-help@gcc.gnu.org>              
                                                                   Subject 
                                       RE: Question on                     
                                       pthread_cancel/pthread_exit and     
                                       thread stack  unwind                
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




Hi Yufeng,

I may be off, but I believe that pthreads is really separate from GCC,
so if stack unwinding doesn't occur, etc., etc., with pthread_cancel and
pthread_exit, it may be more of an issue to take up with the maintainers
of the pthread library on Linux.  You might try there and see what kind
of a response they give you...

Thanks,
Lyle


-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Eljay Love-Jensen
Sent: Thursday, September 16, 2004 2:47 PM
To: Yufeng_Xiong@ltx.com
Cc: gcc-help@gcc.gnu.org
Subject: Re: Question on pthread_cancel/pthread_exit and thread stack
unwind

Hi Yufeng,

 >I'm not sure how active you are involved with the GCC development...

I'm a user of GCC just like yourself, much like most of the people on
this
forum.  This is a user-community supported self-help forum.

 >...is there a technical problem preventing this from happening or it's

just nobody is considering doing it?

Well, yes, it's a technical problem of sorts.  The C++ specification
does
not support multithreading programming.

POSIX Threads in C/C++ are an "after market bolt-on", so to speak.

There are other languages which handle multithreaded programming better
than C++:  Ada and Java come to mind.  Those are but two examples; I'm
sure
there are many other languages which are multithread savvy.

 >We can consider other compilers but we really like to use GCC because
then we can pretty much use the 'same' compiler for different platforms.

As I understand it, GCC supports Ada and supports Java.  So you could
stick
with GCC.

HTH,
--Eljay



^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: Question on pthread_cancel/pthread_exit and thread stack  unwind
@ 2004-09-16 22:13 Ramadass, Ramanathan
  0 siblings, 0 replies; 9+ messages in thread
From: Ramadass, Ramanathan @ 2004-09-16 22:13 UTC (permalink / raw)
  To: Yufeng_Xiong; +Cc: gcc-help

Not necessarily. pthread library is separate from gcc. The compiler
proper does not care. The behaviour you are looking for is in the
runtime startup code(files named crtbegin.o, crtend.o etc; use gcc -v
and note the actual files being used in the link line) and also in the
standard libraries. Note that the startup object files are specific to
the compiler and are built when you build gcc. It is there that you will
find the setup and calls for global ctors/dtors. You might want to look
at the CRT code to figure out what is being done. You might also need
the pthread API implementation itself (i think it comes with the glibc
source) to see how the pthread_cancel/pthread_exit calls interact with
the runtime code.

HTH
Ram

-----Original Message-----
From: Yufeng_Xiong@ltx.com [mailto:Yufeng_Xiong@ltx.com]
Sent: Thursday, September 16, 2004 2:12 PM
To: lrtaylor@micron.com
Cc: gcc-help@gcc.gnu.org
Subject: RE: Question on pthread_cancel/pthread_exit and thread stack
unwind






On the same Solaris platform, using SUN's Workshop6.2 compiler,
there's no such problem, with the same pthread library, so the compiler
has something to do with it.

Yufeng




 

             lrtaylor@micron.c

             om

 
To 
             09/16/2004 05:04          <Yufeng_Xiong@ltx.com>

             PM
cc 
                                       <gcc-help@gcc.gnu.org>

 
Subject 
                                       RE: Question on

                                       pthread_cancel/pthread_exit and

                                       thread stack  unwind

 

 

 

 

 

 





Hi Yufeng,

I may be off, but I believe that pthreads is really separate from GCC,
so if stack unwinding doesn't occur, etc., etc., with pthread_cancel and
pthread_exit, it may be more of an issue to take up with the maintainers
of the pthread library on Linux.  You might try there and see what kind
of a response they give you...

Thanks,
Lyle


-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On
Behalf Of Eljay Love-Jensen
Sent: Thursday, September 16, 2004 2:47 PM
To: Yufeng_Xiong@ltx.com
Cc: gcc-help@gcc.gnu.org
Subject: Re: Question on pthread_cancel/pthread_exit and thread stack
unwind

Hi Yufeng,

 >I'm not sure how active you are involved with the GCC development...

I'm a user of GCC just like yourself, much like most of the people on
this
forum.  This is a user-community supported self-help forum.

 >...is there a technical problem preventing this from happening or it's

just nobody is considering doing it?

Well, yes, it's a technical problem of sorts.  The C++ specification
does
not support multithreading programming.

POSIX Threads in C/C++ are an "after market bolt-on", so to speak.

There are other languages which handle multithreaded programming better
than C++:  Ada and Java come to mind.  Those are but two examples; I'm
sure
there are many other languages which are multithread savvy.

 >We can consider other compilers but we really like to use GCC because
then we can pretty much use the 'same' compiler for different platforms.

As I understand it, GCC supports Ada and supports Java.  So you could
stick
with GCC.

HTH,
--Eljay


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Question on pthread_cancel/pthread_exit and thread stack  unwind
  2004-09-16 20:14       ` Yufeng_Xiong
@ 2004-09-16 20:47         ` Eljay Love-Jensen
  0 siblings, 0 replies; 9+ messages in thread
From: Eljay Love-Jensen @ 2004-09-16 20:47 UTC (permalink / raw)
  To: Yufeng_Xiong; +Cc: gcc-help

Hi Yufeng,

 >I'm not sure how active you are involved with the GCC development...

I'm a user of GCC just like yourself, much like most of the people on this 
forum.  This is a user-community supported self-help forum.

 >...is there a technical problem preventing this from happening or it's 
just nobody is considering doing it?

Well, yes, it's a technical problem of sorts.  The C++ specification does 
not support multithreading programming.

POSIX Threads in C/C++ are an "after market bolt-on", so to speak.

There are other languages which handle multithreaded programming better 
than C++:  Ada and Java come to mind.  Those are but two examples; I'm sure 
there are many other languages which are multithread savvy.

 >We can consider other compilers but we really like to use GCC because 
then we can pretty much use the 'same' compiler for different platforms.

As I understand it, GCC supports Ada and supports Java.  So you could stick 
with GCC.

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Question on pthread_cancel/pthread_exit and thread stack  unwind
  2004-09-16 20:04     ` Eljay Love-Jensen
@ 2004-09-16 20:14       ` Yufeng_Xiong
  2004-09-16 20:47         ` Eljay Love-Jensen
  0 siblings, 1 reply; 9+ messages in thread
From: Yufeng_Xiong @ 2004-09-16 20:14 UTC (permalink / raw)
  To: Eljay Love-Jensen; +Cc: gcc-help





Hi Eljay,

Thanks for sticking with my problem and all the 'nice' suggestions.

We have a very large system where an 'execution' thread is taking care of
running, the main thread monitors it and is required to have the ability to
stop
the execution at any time. Use a separate process is a solution but the two
threads
share a lot of data and communications with other processes/CPUs.

I'm not sure how active you are involved with the GCC development, is there
a
technical problem preventing this from happening or it's just nobody is
considering
doing it? We can consider other compilers but we really like to use GCC
because
then we can pretty much use the 'same' compiler for different platforms.

Thanks.

Yufeng




                                                                           
             Eljay Love-Jensen                                             
             <eljay@adobe.com>                                             
                                                                        To 
             09/16/2004 04:04          Yufeng_Xiong@ltx.com                
             PM                                                         cc 
                                       gcc-help@gcc.gnu.org                
                                                                   Subject 
                                       Re: Question on                     
                                       pthread_cancel/pthread_exit and     
                                       thread stack  unwind                
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




Hi Yufeng,

One alternative is to make sure all items are created / destructed in the
main thread then handed over to the spawned threads, keeping track of which

object is under the domain of which TID.  Use reference counting, and post
their imminent demise to a reaper list which the main thread acts
upon.  Any TID that is noted causes the main thread to go through it's
outstanding object list to put all those items on the reap list -- note
that reference counts may let them stay around for a few cycles until the
things referring to them are destructed.  Disallow stack based objects in
threads.

May not be doable depending on all your developers and the third party code

you use.

Or, you could try fixing those issues of pthread_cancel / pthread_exit
abuse with QA and apoplectical management.

Or, try bribing the developers with cookies and donuts.  If that fails, use

thumbscrews.

Or, if you want proper garbage collecting in a multithreaded environment,
use Java.  (Multithreading is a "bolt on" for C and
C++.  Unfortunately.  It's not going become part of the language proper any

time soon.)

--Eljay



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Question on pthread_cancel/pthread_exit and thread stack  unwind
  2004-09-16 19:45   ` Yufeng_Xiong
@ 2004-09-16 20:04     ` Eljay Love-Jensen
  2004-09-16 20:14       ` Yufeng_Xiong
  0 siblings, 1 reply; 9+ messages in thread
From: Eljay Love-Jensen @ 2004-09-16 20:04 UTC (permalink / raw)
  To: Yufeng_Xiong; +Cc: gcc-help

Hi Yufeng,

One alternative is to make sure all items are created / destructed in the 
main thread then handed over to the spawned threads, keeping track of which 
object is under the domain of which TID.  Use reference counting, and post 
their imminent demise to a reaper list which the main thread acts 
upon.  Any TID that is noted causes the main thread to go through it's 
outstanding object list to put all those items on the reap list -- note 
that reference counts may let them stay around for a few cycles until the 
things referring to them are destructed.  Disallow stack based objects in 
threads.

May not be doable depending on all your developers and the third party code 
you use.

Or, you could try fixing those issues of pthread_cancel / pthread_exit 
abuse with QA and apoplectical management.

Or, try bribing the developers with cookies and donuts.  If that fails, use 
thumbscrews.

Or, if you want proper garbage collecting in a multithreaded environment, 
use Java.  (Multithreading is a "bolt on" for C and 
C++.  Unfortunately.  It's not going become part of the language proper any 
time soon.)

--Eljay

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Question on pthread_cancel/pthread_exit and thread stack  unwind
  2004-09-16 19:40 ` Eljay Love-Jensen
@ 2004-09-16 19:45   ` Yufeng_Xiong
  2004-09-16 20:04     ` Eljay Love-Jensen
  0 siblings, 1 reply; 9+ messages in thread
From: Yufeng_Xiong @ 2004-09-16 19:45 UTC (permalink / raw)
  To: Eljay Love-Jensen; +Cc: gcc-help





Thanks for the suggestion, it is REALLY a good suggestion, however, the
real world is not that idea,
we are in a situation that it has to work, we can not depend on all
developers and third party code
to be all nice.

Yufeng




                                                                           
             Eljay Love-Jensen                                             
             <eljay@adobe.com>                                             
                                                                        To 
             09/16/2004 03:40          Yufeng_Xiong@ltx.com,               
             PM                        gcc-help@gcc.gnu.org                
                                                                        cc 
                                                                           
                                                                   Subject 
                                       Re: Question on                     
                                       pthread_cancel/pthread_exit and     
                                       thread stack  unwind                
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




Hi Yufeng,

Refrain from using pthread_cancel and pthread_exit.  Those are Big Hammers
and Sharp Knives.

Instead, set a variable that is monitored by the thread and set by the
owner-thread / main thread which signals the child thread to terminate
gracefully.

Mutex / condvar yada yada yada like normal apply.

HTH,
--Eljay



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Question on pthread_cancel/pthread_exit and thread stack  unwind
  2004-09-16 19:31 Yufeng_Xiong
@ 2004-09-16 19:40 ` Eljay Love-Jensen
  2004-09-16 19:45   ` Yufeng_Xiong
  0 siblings, 1 reply; 9+ messages in thread
From: Eljay Love-Jensen @ 2004-09-16 19:40 UTC (permalink / raw)
  To: Yufeng_Xiong, gcc-help

Hi Yufeng,

Refrain from using pthread_cancel and pthread_exit.  Those are Big Hammers 
and Sharp Knives.

Instead, set a variable that is monitored by the thread and set by the 
owner-thread / main thread which signals the child thread to terminate 
gracefully.

Mutex / condvar yada yada yada like normal apply.

HTH,
--Eljay

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Question on pthread_cancel/pthread_exit and thread stack unwind
@ 2004-09-16 19:31 Yufeng_Xiong
  2004-09-16 19:40 ` Eljay Love-Jensen
  0 siblings, 1 reply; 9+ messages in thread
From: Yufeng_Xiong @ 2004-09-16 19:31 UTC (permalink / raw)
  To: gcc-help





Hi All,

Use GCC compiler, pthread_cancel and pthread_exit do not unwind thread
stack (and destruct stack
C++ objects), this is a well-known 'problem', is there any plan to make it
work? Or is there something
out there already that can solve the problem?

I'm using Solaris now and we plan to move to Linux, is there a solution for
Linux already? This problem
is preventing us from moving to GCC and eventually moving to Linux.

Thanks.

Yufeng

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-09-16 22:13 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-16 21:04 Question on pthread_cancel/pthread_exit and thread stack unwind lrtaylor
2004-09-16 21:08 ` Yufeng_Xiong
  -- strict thread matches above, loose matches on Subject: below --
2004-09-16 22:13 Ramadass, Ramanathan
2004-09-16 19:31 Yufeng_Xiong
2004-09-16 19:40 ` Eljay Love-Jensen
2004-09-16 19:45   ` Yufeng_Xiong
2004-09-16 20:04     ` Eljay Love-Jensen
2004-09-16 20:14       ` Yufeng_Xiong
2004-09-16 20:47         ` Eljay Love-Jensen

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).