Best way of storing state?

harrywright88 wrote on Wednesday, March 16, 2016:

Hi, I’m using FreeRTOS to write code for a music system and need to be able to save several states simultaneously (boot status, play status, source selected etc). Normally I would do this by having a global struct which contains several enums for each state.
Is there a different/more appropriate way to accomplish saving states in FreeRTOS? I’m fairly new to the RTOS world, so excuse me if I’ve missed something obvious here.
Many thanks

rtel wrote on Wednesday, March 16, 2016:

I am an advocate of “the simplest way that works” - in this case the only reason not to continue to use the structure would be if multiple tasks need to write to the structure at the same time - in which case you would need to use some form of mutual exclusion primitive to ensure one task does not corrupt what another task is doing.

harrywright88 wrote on Thursday, March 17, 2016:

thanks for your response, I’ll probably implement it as before, but with mutual exclusion.