Are file mutexes available in Matlab these days?
20 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Ben Wetherill
am 29 Jan. 2018
Bearbeitet: Steven Lord
am 30 Jan. 2018
I'm using Matlab 2016b. I looking at using the Parallel Pool to run a large number of simulations and post processing. The simulations are split into several classes, each with its own Excel result summary file. To ensure I don't get file access issues I want to use mutexes, but I've not been able to find anything about these being available in Matlab. I found some threads on here from people lamenting the lack of mutexes back in 2011, but maybe they have been implemented by now?
I'm aware of more clunky methods of doing this, such as using fopen() to see if the file is already open, but this doesn't give me the same protection a mutex lock would.
1 Kommentar
Walter Roberson
am 29 Jan. 2018
Unfortunately not. But see https://stackoverflow.com/questions/6415283/semaphores-and-locks-in-matlab
Akzeptierte Antwort
Edric Ellis
am 30 Jan. 2018
Probably your best bet with the current implementation is to use a DataQueue. The plan would be to have the workers send the information to be saved back to the client using the send method of the DataQueue. The client would use afterEach to react to these incoming messages, and save the data to file. This means that only a single process is ever accessing the files - so no mutex required. Obviously there's cost associated with sending the data from the workers back to the client - but there's also cost involved with using a mutex to wait until it is safe to access the file.
3 Kommentare
Guillaume
am 30 Jan. 2018
Bearbeitet: Steven Lord
am 30 Jan. 2018
[SL: fixed typo in name of the object]
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!