This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Re: A safe way to print debug output in DSRs ?
On Tue, Aug 29, 2000 at 07:58:52PM +0100, Jonathan Larmour wrote:
> > I'm looking for a safeway to print debug ouput while in a DSR.
> >
> > Printf is not safe for it locks a mutex.
> >
> > The weird thing is that AFAICS it uses this mutex only when using the
> > thread-safe printf option. Could this mean that the not thread safe printf
> > call is more safe for DSRs?
>
> Yes, but any threads that used printf wouldn't be using it in a thread-safe
> way. If this isn't going to happen, then go ahead and disable the option.
>
> > Or is there another call that is safe? What about diag_printf?
>
> diag_printf is probably a better option since it's only simple debug output
> you want. Just include <cyg/infra/diag.h> and go from there.
If diag_printf does a busy-wait on a UART (as it does on my
system in hal_diag_write_char()), it can have a pretty big
timing impact on the DSR. If it doesn't get called too often
and the messages fit into the UART FIFO, then this isn't too
much of a problem -- but it's important to keep in mind as you
sprinkle diag_printf() around in the code.
--
Grant Edwards
grante@visi.com