Duggle Posted July 17, 2012 Report Share Posted July 17, 2012 The module documentation at uCApps clearly states that a mutex must be used to ensure mutual exclusion between tasks that may be attempting to access the sd card. But can calls to FILE_SDCardAvailable() be made without taking/giving the mutex? Quote Link to comment Share on other sites More sharing options...
Duggle Posted July 18, 2012 Author Report Share Posted July 18, 2012 It seems that FILE_SDCardAvailable() returns the value of a flag, so calling this function from different tasks should not require the use of a semaphore. Quote Link to comment Share on other sites More sharing options...
TK. Posted July 18, 2012 Report Share Posted July 18, 2012 Yes, correct. The flag is set by FILE_CheckSDCard which should be frequently called and should be protected via Mutex Note that the Mutex is only required if the SPI port is shared with another device (e.g. MBHP_ETH interface) Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
Duggle Posted July 18, 2012 Author Report Share Posted July 18, 2012 Presumably, mutexs are required when ever two or more tasks are accessing the same data structures (with the possibility of incomplete changes being seen by the other task(s)). I think I've been using the SD Card mutex to prevent mutliple processes from simultaneous access to file structures. I have a settings save/restore mechanism that is called from different tasks as well as a data logging facility. I suppose that I should have separate mutexs to remove the potential for bottlenecks. (Although I dont see performance being an issue). Quote Link to comment Share on other sites More sharing options...
TK. Posted July 18, 2012 Report Share Posted July 18, 2012 Of course, you are right, in this case the usage of a Mutex is required as well. I mixed this with the mutex which is mentioned in the MIOS32 documentation (MIOS32_SPI). The only reason for not using mutexes would be to keep the code as simple as possible - but once you learned how to setup them, there is no reason for not using this "protection" mechanism. Best Regards, Thorsten. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.