public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] cyg_libc_invoke_atexit_handlers
@ 2007-05-16 21:19 Paul D. DeRocco
  2007-05-16 21:38 ` Andrew Lunn
  0 siblings, 1 reply; 3+ messages in thread
From: Paul D. DeRocco @ 2007-05-16 21:19 UTC (permalink / raw)
  To: eCos Discuss

I notice that after my "cyg_user_start" function returns, "exit" is called,
which in turn calls "cyg_libc_invoke_atexit_handlers". This function has a
"cyg_" prefix, so is apparently part of eCos, and not some immutable part of
the C library, so I assume it has some intended use. But I don't understand
why one would want an atexit handler to be called at the end of system
initialization. (I also notice that the destruction of static C++ objects is
fortunately _not_ done by an atexit handler, the way it is with some C++
compilers; indeed my system has no atexit handlers at all.) Since eCos has
no standard shutdown mechanism, is there some reason that atexit handlers
are called at all?

-- 

Ciao,               Paul D. DeRocco
Paul                mailto:pderocco@ix.netcom.com 


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* Re: [ECOS] cyg_libc_invoke_atexit_handlers
  2007-05-16 21:19 [ECOS] cyg_libc_invoke_atexit_handlers Paul D. DeRocco
@ 2007-05-16 21:38 ` Andrew Lunn
  2007-05-17 21:23   ` Paul D. DeRocco
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Lunn @ 2007-05-16 21:38 UTC (permalink / raw)
  To: Paul D. DeRocco; +Cc: eCos Discuss

On Wed, May 16, 2007 at 02:09:55PM -0700, Paul D. DeRocco wrote:
> I notice that after my "cyg_user_start" function returns, "exit" is called,
> which in turn calls "cyg_libc_invoke_atexit_handlers". This function has a
> "cyg_" prefix, so is apparently part of eCos, and not some immutable part of
> the C library, so I assume it has some intended use. But I don't understand
> why one would want an atexit handler to be called at the end of system
> initialization. (I also notice that the destruction of static C++ objects is
> fortunately _not_ done by an atexit handler, the way it is with some C++
> compilers; indeed my system has no atexit handlers at all.) Since eCos has
> no standard shutdown mechanism, is there some reason that atexit handlers
> are called at all?

Im no expert here......

Is this something special for main(), or is it generic for all
threads?  eCos threads are allowed to exit, since they can be short
lived. POSIX probably states that exiting threads run their atexit
handlers. So when main() exists its atexit handlers get called.

          Andrew

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

* RE: [ECOS] cyg_libc_invoke_atexit_handlers
  2007-05-16 21:38 ` Andrew Lunn
@ 2007-05-17 21:23   ` Paul D. DeRocco
  0 siblings, 0 replies; 3+ messages in thread
From: Paul D. DeRocco @ 2007-05-17 21:23 UTC (permalink / raw)
  To: eCos Discuss

> From: Andrew Lunn
> 
> Is this something special for main(), or is it generic for 
> all threads?  eCos threads are allowed to exit, since they 
> can be short lived. POSIX probably states that exiting 
> threads run their atexit handlers. So when main() exists its 
> atexit handlers get called.

It's certainly true that returning from "main" should call "exit". In eCos,
this kills the calling thread, and also calls its registered destructors,
which handles stuff specific to that thread. However, the atexit handlers
are global. This means that any atexit handler registered by any thread will
be called whenever any other thread exits, and may even be called multiple
times if multiple threads exit, since cyg_libc_atexit_handlers doesn't
unregister the handlers as they are called.

My guess is that this is something that wasn't thought through, but that no
one ever uses anyway. If that's the case, that's fine with me--I'm just
trying to make sure I'm not missing something important.

Perhaps "atexit" should be replaced with something that registers a thread
destructor.

-- 

Ciao,               Paul D. DeRocco
Paul                mailto:pderocco@ix.netcom.com 


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

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

end of thread, other threads:[~2007-05-16 21:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-16 21:19 [ECOS] cyg_libc_invoke_atexit_handlers Paul D. DeRocco
2007-05-16 21:38 ` Andrew Lunn
2007-05-17 21:23   ` Paul D. DeRocco

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