Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

logmsg vs printf

502 views
Skip to first unread message

pushpa

unread,
May 18, 2004, 12:28:45 AM5/18/04
to
Why is it advisable to use logMsg instead of printf's in a interrupt
service routine?

Wade Oram

unread,
May 18, 2004, 1:40:50 AM5/18/04
to
In message <78a4243a.04051...@posting.google.com>, pushpa
<deena.m...@wipro.com> writes

>Why is it advisable to use logMsg instead of printf's in a interrupt
>service routine?


Its not 'advisable' - its mandatory. printf will attempt to block on IO
- something you can't do in an interrupt routine. Conversely, logMsg
simply sends the text to a queue (with NOWAIT) where it is picked up by
a different thread and printed.
--
Wade Oram
Reply address valid for 1 calendar month from date of posting.

biju k

unread,
May 18, 2004, 7:35:33 AM5/18/04
to
Some of the illeffects what printf() has when used in ISR are:

1.non reentrant.
2.usually one will disable all the hardware interrupts inside isr,and
printf() cannot proceed unless interrupts are enabled for the serial
device.
3.Also printf() code is supposed to be quite large.

logMsg()is equivalent to printk() in unix.


Best Regards,
Biju Koruthu.

joe durusau

unread,
May 18, 2004, 7:40:46 AM5/18/04
to

pushpa wrote:

> Why is it advisable to use logMsg instead of printf's in a interrupt
> service routine?

Mainly, because the use of printf() (or any function that can block
is absolutely forbidden in ISR context. There is a very restricted list
of
functions that can be called fro ISR context, and this list should be
adhered
to strictly. See the manuals for the list.

Speaking only for myself,

Joe Durusau


almo...@hotmail.com

unread,
May 19, 2004, 4:07:59 AM5/19/04
to
Wade Oram <ne...@wtoram.co.uk> wrote:

>In message <78a4243a.04051...@posting.google.com>, pushpa
><deena.m...@wipro.com> writes
>>Why is it advisable to use logMsg instead of printf's in a interrupt
>>service routine?
>
>
>Its not 'advisable' - its mandatory. printf will attempt to block on IO
>- something you can't do in an interrupt routine. Conversely, logMsg
>simply sends the text to a queue (with NOWAIT) where it is picked up by
>a different thread and printed.

printf() may also malloc, IIRC.

Falessi D.

unread,
May 19, 2004, 5:22:28 AM5/19/04
to
In addition the logMsg() could be useful when you use ioTaskStdSet( )
or ioGlobalStdSet( ).Infact this kind of function afflict prinf but
don't afflict logMsg.

D.Falessi

s.subbarayan

unread,
May 20, 2004, 12:03:20 AM5/20/04
to
Hi,
LogMsg as said by others gives you better control over the place where
you want the output to be displayed.Suppose you want to create an
event logger in that case instead of printing the output to display
device u can use logmsg and redirect the output to a text file and use
it for debugging purpose in future.U can use LogFdSet and do this.And
another advantage is since it postpones the printing its ideal to be
used in ISR so vxworks advices u to use LOgMsg inside ISR instead of
printf.
Regards,
s.subbarayan

davf...@tin.it (Falessi D.) wrote in message news:<5831889a.04051...@posting.google.com>...

0 new messages