newlib reentrancy question
Tue Jun 19 07:17:00 GMT 2001
Where's the best description and/or example of how to
implement newlib pre-thread reentrancy support these
I am investigating a case where cout does not work
for the 2nd task in a system unless the 1st task
uses it. All of the standard C routines work fine.
In fact, the printf immediately before the cout calls
in the 2nd task prints. The clue I think is that
printf does not call fwrite and cout does. Here
is how we do the per-task reentrancy structures
+ At system initialization, we use a global struct _reent.
It is initialized using _REENT_INIT.
+ Each task has its own copy of the reent structure.
+ As part of a context switch the contents of _impure_ptr
+ As each task begins execution time, the following code
ptr = (struct _reent *) calloc(1, sizeof(struct _reent));
*ptr = (struct _reent) _REENT_INIT((*ptr));
What seems to be happening is that the 2nd task gets to
#define CHECK_INIT(fp) \
if ((fp)->_data == 0) \
(fp)->_data = _REENT; \
if (!(fp)->_data->__sdidinit) \
__sinit ((fp)->_data); \
and it decides to do the copy in the first if. But since
_REENT_INIT at task_begin time set __sdidinit to 1, it
skips the __sinit portion. Any ideas? Do you think
that our per-task initialization should be different
and make sure __sdidinit is 0?
Joel Sherrill, Ph.D. Director of Research & Development
joel@OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
More information about the Newlib