Skip to content

Commit

Permalink
Adding volatile to tasks.c's runtime information to protect against c…
Browse files Browse the repository at this point in the history
…ompiler optimization (#62)

As discussed in https://forums.freertos.org/t/make-runtime-stats-working-with-compiler-optimization-enabled/9846 and on lined out on https://blog.the78mole.de/freertos-debugging-on-stm32-cpu-usage/, adding the volatile prevents the run-time stats variable being optimized away when used with compiler optimizations.
  • Loading branch information
the78mole authored May 22, 2020
1 parent bac101c commit e4e4fb0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended = ( UBaseType_t
/* Do not move these variables to function scope as doing so prevents the
code working with debuggers that need to remove the static qualifier. */
PRIVILEGED_DATA static uint32_t ulTaskSwitchedInTime = 0UL; /*< Holds the value of a timer/counter the last time a task was switched in. */
PRIVILEGED_DATA static uint32_t ulTotalRunTime = 0UL; /*< Holds the total amount of execution time as defined by the run time counter clock. */
PRIVILEGED_DATA static volatile uint32_t ulTotalRunTime = 0UL; /*< Holds the total amount of execution time as defined by the run time counter clock. */

#endif

Expand Down

0 comments on commit e4e4fb0

Please sign in to comment.