I have a large list of variables that can be read or written to by multiple tasks. One of the Task that updates some of these variables is triggered off(using semaphore take/give)of an interrupt when new data is available.
Option 1: Create a ReadVariable() and WriteVariable() functions that use a critical section to protect the variable and the only way to access the variable.
Option 2: Create a semaphore for “each” variable. Have multiple functions in a class that may be accessing these variables directly but uses the specific semaphore associated with that variable to read/write that variable. How performance/memory intesive is creating and using a semaphore because in this method, each variable has its own semaphore.
Any suggestions/advice? Thanks.