Michael Durian

RTOS locking

Discussion created by Michael Durian on Nov 27, 2017
Latest reply on Nov 29, 2017 by Michael Durian

I'll be using the sensor fusion library with an RTOS (uC/OS-II, not FreeRTOS, but I don't think that is relevant). The sensor fusion user's guide discusses using an RTOS and gives an example showing two tasks: one for reading data from the sensors (read_task) and another to process the data (fusion_task).


I don't see any locks (semaphore, mutex, etc) to serialize access to the raw sensor data. Depending what other tasks are running in the RTOS, I think it would be theoretically possible for the read_task to modify sensor data while the fusion_task is still processing it.


I think it might be enough to put a lock around


in read_task and around


in fusion_task. Is this correct? Is that sufficient locking to serialize data shared between the two tasks?