Necessity of SEGGER_SYSVIEW_LOCK()/UNLOCK()

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Necessity of SEGGER_SYSVIEW_LOCK()/UNLOCK()

      SystemView's manual page 68 currently states:

      SEGGER SystemView User Guide wrote:

      4.5.1.4 SEGGER_SYSVIEW_LOCK()
      Function macro to recursively lock SystemView transfers from being interrupted. I.e. disable interrupts.

      SEGGER_SYSVIEW_LOCK() must preserve the previous lock state to be restored in SEGGER_SYSVIEW_UNLOCK().

      Recording a SystemView event must not be interrupted by recording another event. Therefore all interrupts which are recorded by SystemView (call SEGGER_SYSVIEW_RecordEnterISR / SEGGER_SYSVIEW_RecordExitISR), call an instrumented function (e.g. an OS APIfunction), cause an immediate context switch, or possibly create any other SystemView event must be disabled.

      SEGGER_SYSVIEW_LOCK() can use the same locking mechanism as SEGGER_RTT_LOCK().

      Default: SEGGER_RTT_LOCK()

      SEGGER_RTT_LOCK() is defined for most systems (for example Cortex-M devices with Embedded Studio, GCC, IAR or Keil ARM, and RX devices with IAR) in SEGGER_RTT_Conf.h. If the macro is not defined, or empty, it has to be provided to match the target system.
      This section is also linked to in the FreeRTOS with SystemView entry on the SEGGER Knowledge Base (kb.segger.com/FreeRTOS_with_SystemView#Recording_Interrupts) where it says:

      SEGGER Knowledge Base wrote:


      Locking Interrupts
      Every interrupt which directly or indirectly generates SystemView events needs to be locked by SEGGER_SYSVIEW_Lock().Make sure the interrupt priority and the lock configuration matches.
      Note, the mention of "SEGGER_SYSVIEW_Lock()" in the KB hyperlinks directly to the above quoted part of the manual, I assume "LOCK" isn't used in all capitals as a stylistic choice or an accident, not because there are two different APIs with different capitalisation :D


      This raises some confusion, as it could be interpreted as suggesting that interrupts need to be wrapped in SEGGER_SYSVIEW_LOCK()/SEGGER_SYSVIEW_UNLOCK(). Although, I've been wrapping my (FreeRTOS based system) interrupts in traceISR_ENTER()/traceISR_EXIT(). If I follow the macro trail for a bit, these lead to SEGGER_SYSVIEW_RecordEnterISR()/SEGGER_SYSVIEW_RecordExitISR(), both of these call RECORD_START and RECORD_END. And it seems that these macros call SEGGER_SYSVIEW_LOCK()/SEGGER_SYSVIEW_UNLOCK() respectively (provided that SEGGER_SYSVIEW_USE_STATIC_BUFFER is enabled!).


      Does this mean that as long as SEGGER_SYSVIEW_USE_STATIC_BUFFER is on, the traceISR_ENTER() ,traceISR_EXIT() and traceISR_EXIT_TO_SCHEDULER() macros are sufficient and all I need to use when recording interrupts?


      (Using FreeRTOS 10.6 here, with SystemView instrumentation patches based on the provided SystemView FreeRTOS 10.4 sample code.)