Duggle Posted July 17, 2012 Report 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?
Duggle Posted July 18, 2012 Author Report 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.
TK. Posted July 18, 2012 Report 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.
Duggle Posted July 18, 2012 Author Report 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).
TK. Posted July 18, 2012 Report 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.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now