This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

System_printf() not using the system gate

Hello,

it looks like the documentation of System_printf() is inconsistent or unclear in respect to thread safety:

"This module is gated and other modules use its gate via the Gate.enterSystem and Gate.leaveSystem. ... "

Looking at the source code, System_printf() doesn't seem to enter the system gate. I understand that the underlying SysMin / SysStd modules provide thread safety, but only on a character basis. This can lead to very confusing output strings when multiple System_printf() calls interrupt each other.

Thanks,
Ralf

  • That part of the documentation refers to the whole module, not specifically to System_printf. That statement is there primarily to warn that there are calls to Gate_enterSystem() and Gate_leaveSystem() in the code in System.c, and therefore either ISRs must not call xdc.runtime functions, or the gate used as the System gate must disable interrupts because you can't have an ISR being blocked on the gate, or you have to configure your system to use a non-blocking gate.
    You can see here that the System functions that are protected by the gate are System_atexit and application termination functions: http://rtsc.eclipse.org/docs-tip/Working_with_xdc.runtime#Multi-Threading_Support

    The calls to System_printf are potentially too long to guard them with the System gate that for example disables interrupts, as required above. It does makes the output confusing if there are multiple threads generating output at the same time, but it's an acceptable tradeoff.

  • I have no problem that System_printf() isn't protected by the gate. But it would be nice if this was mentioned in the documentation.

    Because of this, I think it's also possible to use System_printf() in ISRs when using the SysMin implementation.

    Ralf