Calling sprintf from interrupt context - VxWorks

This is a discussion on Calling sprintf from interrupt context - VxWorks ; Hello, Is it safe to call sprintf from interrupt context? I couldn't think of a reason why not, but on the other hand I'm not sure what OS facilities it uses (perhaps it needs to allocate memory?). I'm using VxWorks ...

+ Reply to Thread
Results 1 to 7 of 7

Thread: Calling sprintf from interrupt context

  1. Calling sprintf from interrupt context

    Hello,
    Is it safe to call sprintf from interrupt context?
    I couldn't think of a reason why not, but on the other hand I'm not
    sure what OS facilities it uses (perhaps it needs to allocate
    memory?).
    I'm using VxWorks 5.5.
    Thanks.

  2. Re: Calling sprintf from interrupt context

    Hello,

    It is safe to call printf, but some times it may messup execution of
    tasks(As printf is having High priority),
    So better not to use it from ISR, it may hit the performance.
    For debugging purpose printf can be used.

    Regards,
    Shrikant


    barkan.a...@gmail.com wrote:
    > Hello,
    > Is it safe to call sprintf from interrupt context?
    > I couldn't think of a reason why not, but on the other hand I'm not
    > sure what OS facilities it uses (perhaps it needs to allocate
    > memory?).
    > I'm using VxWorks 5.5.
    > Thanks.


  3. Re: Calling sprintf from interrupt context

    On Aug 20, 5:11*pm, pawar.shrik...@gmail.com wrote:
    > Hello,
    >
    > It is safe to call printf, but some times it may messup execution of
    > tasks(As printf is having High priority),
    > So better not to use it from ISR, it may hit the performance.
    > For debugging purpose printf can be used.
    >
    > Regards,
    > Shrikant
    >
    >
    >
    > barkan.a...@gmail.com wrote:
    > > Hello,
    > > Is it safe to call sprintf from interrupt context?
    > > I couldn't think of a reason why not, but on the other hand I'm not
    > > sure what OS facilities it uses (perhaps it needs to allocate
    > > memory?).
    > > I'm using VxWorks 5.5.
    > > Thanks.- Hide quoted text -

    >
    > - Show quoted text -


    if i want to get some log info in ISR ,while the printf can not be
    used,what can i do?
    how about the logMsg() ?

  4. Re: Calling sprintf from interrupt context

    On Aug 20, 5:29*am, DeNNis wrote:
    > On Aug 20, 5:11*pm, pawar.shrik...@gmail.com wrote:
    >
    >
    >
    >
    >
    > > Hello,

    >
    > > It is safe to call printf, but some times it may messup execution of
    > > tasks(As printf is having High priority),
    > > So better not to use it from ISR, it may hit the performance.
    > > For debugging purpose printf can be used.

    >
    > > Regards,
    > > Shrikant

    >
    > > barkan.a...@gmail.com wrote:
    > > > Hello,
    > > > Is it safe to call sprintf from interrupt context?
    > > > I couldn't think of a reason why not, but on the other hand I'm not
    > > > sure what OS facilities it uses (perhaps it needs to allocate
    > > > memory?).
    > > > I'm using VxWorks 5.5.
    > > > Thanks.- Hide quoted text -

    >
    > > - Show quoted text -

    >
    > if i want to get some log info in ISR ,while the printf can not be
    > used,what can i do?
    > how about the logMsg() ?


    Regarding your question about logMsg()--yes, it is ISR safe.

    Sparky.

  5. Re: Calling sprintf from interrupt context

    On Aug 20, 12:11*pm, pawar.shrik...@gmail.com wrote:
    > Hello,
    >
    > It is safe to call printf, but some times it may messup execution of
    > tasks(As printf is having High priority),
    > So better not to use it from ISR, it may hit the performance.
    > For debugging purpose printf can be used.
    >
    > Regards,
    > Shrikant
    >
    > barkan.a...@gmail.com wrote:
    > > Hello,
    > > Is it safe to call sprintf from interrupt context?
    > > I couldn't think of a reason why not, but on the other hand I'm not
    > > sure what OS facilities it uses (perhaps it needs to allocate
    > > memory?).
    > > I'm using VxWorks 5.5.
    > > Thanks.


    Hello,

    Thanks for the reply,
    but I actually asked about sprintf, not about printf...
    Does anybody know whether it's safe to call sprintf from interrupt
    context? (I've tried it, seems to work ok, I just like to be on the
    safe side).

    Regarding printf, while we're on the subject - from my experience,
    it's definitely not interrupt-safe.
    I recently had a bug in which printf was called from interrupt context
    (a watchdog callback). All went well as long as no other task was
    printing when the watchdog fired, but otherwise the printf call would
    cause the system to reboot almost instantly, and while booting
    afterwards it would print the workQPanic message (which is usually
    related to interrupt problems).

    Alon.

  6. Re: Calling sprintf from interrupt context

    On Aug 20, 3:23*pm, barkan.a...@gmail.com wrote:
    > On Aug 20, 12:11*pm, pawar.shrik...@gmail.com wrote:
    >
    >
    >
    > > Hello,

    >
    > > It is safe to call printf, but some times it may messup execution of
    > > tasks(As printf is having High priority),
    > > So better not to use it from ISR, it may hit the performance.
    > > For debugging purpose printf can be used.

    >
    > > Regards,
    > > Shrikant

    >
    > > barkan.a...@gmail.com wrote:
    > > > Hello,
    > > > Is it safe to call sprintf from interrupt context?
    > > > I couldn't think of a reason why not, but on the other hand I'm not
    > > > sure what OS facilities it uses (perhaps it needs to allocate
    > > > memory?).
    > > > I'm using VxWorks 5.5.
    > > > Thanks.

    >
    > Hello,
    >
    > Thanks for the reply,
    > but I actually asked about sprintf, not about printf...
    > Does anybody know whether it's safe to call sprintf from interrupt
    > context? (I've tried it, seems to work ok, I just like to be on the
    > safe side).
    >
    > Regarding printf, while we're on the subject - from my experience,
    > it's definitely not interrupt-safe.
    > I recently had a bug in which printf was called from interrupt context
    > (a watchdog callback). All went well as long as no other task was
    > printing when the watchdog fired, but otherwise the printf call would
    > cause the system to reboot almost instantly, and while booting
    > afterwards it would print the workQPanic message (which is usually
    > related to interrupt problems).
    >
    > Alon.


    It it is perfectly safe to call sprintf from an interrupt. It is
    reentrant, and does not block. The previous poster is completely
    wrong. It is never safe to call I/O functions such as printf from an
    interrupt, since they may potentially block (that is why logLib
    exists).

    REH

  7. Re: Calling sprintf from interrupt context

    On Aug 20, 5:11*am, pawar.shrik...@gmail.com wrote:
    > Hello,
    >
    > It is safe to call printf, but some times it may messup execution of
    > tasks(As printf is having High priority),
    > So better not to use it from ISR, it may hit the performance.
    > For debugging purpose printf can be used.
    >
    > Regards,
    > Shrikant
    >


    1) No, printf cannot be safely called from an interrupt because it can
    potentially block.
    2) Functions, such as printf, have no concept of "priority."

    REH

+ Reply to Thread