My question relates to
What is disadvantage of calling sleep() inside mutex lock?
I have a similar situation, and I am not quite understanding why sleeping while holding a mutex is such a no-no. What are the consequences, in terms of deadlock, starvation, correctness, etc, of doing this?
I have an embedded system, using an RTOS. That RTOS supports osDelay (sleep) and mutexes.
I have 2+ threads that may require access to an i2c bus peripheral in order to write to an eeprom device on that bus. There may be other devices on that same i2c bus.
A mutex is taken to ensure exclusive access to the i2c peripheral (and hence bus). During the period of holding that mutex, I have to delay 10ms between consecutive eeprom writes. This is just a requirement of the eeprom chip. eeprom reads don't require delays.
How can I achieve my hardware constraints WITHOUT 'delay inside mutex'?