This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: How is _GLOBAL_REENT meant to be used?
- From: Thomas Zenker <thz at tuebingen dot netsurf dot de>
- To: Jeff Johnston <jjohnstn at redhat dot com>
- Cc: Thomas Zenker <thz at isepos dot de>, newlib at sourceware dot org
- Date: Sat, 22 Apr 2006 18:47:02 +0200
- Subject: Re: How is _GLOBAL_REENT meant to be used?
- References: <4448F81A.20340.162D826@localhost> <44496D24.9070101@redhat.com>
On Fri, Apr 21, 2006 at 07:39:16PM -0400, Jeff Johnston wrote:
> Thomas Zenker wrote:
> >Hi, I've ported newlib to my preemptive RTOS. The REENT resp. _impure_ptr
> >is set during task switches. Now on exit from a task fwalk etc. does not
> >cleanup impure_ptr but GLOBAL_REENT (_global_impure_ptr), which is the
> >static version.
> >How is it meant to be used or is there a possibility to map GLOBAL_REENT
> >to REENT without changing newlib?
> >Thomas
> >
>
> The _GLOBAL_REENT struct is used to store and access global information
> across threads. Such information includes open files and the atexit
> lists, for example. In the case of the I/O cleanup function in
> libc/stdio/findfp.c, _GLOBAL_REENT is used to walk the open file list
> and issue fclose. This corresponds to the fact that when a file is
> opened via fopen/freopen, it is added to the list of _GLOBAL_REENT (see
> __sfp in libc/stdio/findfp.c).
>
> -- Jeff J.
Ok, but what if you do not use newlib for threads within a process
(f.e. under linux), but as independent tasks in a RTOS, then you want to keep
the information about open files separate for each task. I think same applies to
atexit lists. ECOS could have the same problem probably.
I can see that this happens only if task are created and exit on the fly.
I will have to look deeper into this all.
-- Thomas