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.

How SysStd works?

Hi,

If use we do a System_printf call from a Hwi or Swi using SysStd we get an assertion failure of GateMutex, so wew must use SysMin instead. My question is, why SysStd causes this assertion failure?

Thanks

  • Johannes,

    SysStd uses the C stdio function printf() to output characters from System_printf(). To make printf() re-entrant  or thread-safe in a multi-tasking environment like SYS/BIOS, there is a blocking mutex (lock) in printf(). Hwi and Swi functions cannot block, so the mutex asserts() to tell you something is wrong.

    Mark

  • HI Johannes,

    SysStd sends its characters to the TI runtime support library's putchar()/getchar() calls so it gets the console. As the rts library is not re-entrant, BIOS allows you to add a gate locking mechanism to protect critical code sections. The GateMutex module is a gate locking mechanism that can't be used in a Hwi or Swi.

    See this wiki page.

    I think you can change the gate module by specifying a BIOS.rtsGateType.

    You can try setting  BIOS.rtsGateType = BIOS_GateHwi in your .cfg file System_printf it should work in Hwi/Swi's.

    Note that SysStd sends data out to the CCS console by halting the CPU core using a hardware breakpoint. It's not recommend to use SysStd within a Hwi or Swi since it stops the core while you are sending data to the console. (e.i. the longer the string, the longer you're keeping your core halted).

    SysMin sends data to a memory buffer (so it's really quick) so you can perform a System_flush() when you aren't in time-sensitive moment.