Tue 05 Apr 2005 02:16:22 AM UTC, original submission:
Hi,
I am currently using the runtime library that accompanies WinAVR with my own pre-emptive RTOS. I have used fdevopen() to direct output to a serial port and an LCD. It is possible for a task that writes to the LCD to be preempted by a task that writes to a serial port, and vice-versa, and either could preempt a user input task that uses sscanf. This is all perfectly reasonable and normal in an embedded system.
Looking at fdevopen(), vfprintf() and vfscanf(), I notice that they all (indirectly) call malloc() (in the latter two cases, when using floating point numbers). This appears to be somewhat problematical, as malloc() does not appear to be reentrant. As far as I can determine, it appears to be possible for one task that is partway through walking the freelist to be preempted by another task that then alters the freelist, before resuming the first task.
I hope that I am wrong, and do not have to implement a workaround*.
I would appreciate your opinion as to whether or not this is a genuine issue.
Kind regards,
Tanya Cumpston
*(The workaround would consist of writing substitutes for the above stdio routines, which attempt to secure a semaphore before calling the existing library routines, then using #defines to redirect calls to the existing library routines to the substitute routines.)
|