From: David Portabella on 10 Aug 2010 14:37 > Is there a method to create a safe file mutex in Matlab? See this workaround: atomically creating a file lock in MATLAB (file mutex) http://stackoverflow.com/questions/3451343/automically-writing-a-file-in-matlab/3452143#3452143
From: Walter Roberson on 10 Aug 2010 15:01 David Portabella wrote: >> Is there a method to create a safe file mutex in Matlab? > > See this workaround: > atomically creating a file lock in MATLAB (file mutex) > http://stackoverflow.com/questions/3451343/automically-writing-a-file-in-matlab/3452143#3452143 > That's not safe either.
From: Sean on 10 Aug 2010 18:07 I have done this before, and had a similar problem. The solution that worked for me (which is probably not the best, but did fix my race condition) was to write a temporary file and then delete it when I was done writing to the log file. If the temporary file existed, then my script would know that another instance of Matlab was currently writing to the log, and that it should pause for a moment and try again. Again, this is kind of a hackish solution, but it worked. Sean
From: Jan Simon on 10 Aug 2010 20:00 Dear Sean, > The solution that worked for me (which is probably not the best, but did fix my race condition) was to write a temporary file and then delete it when I was done writing to the log file. If the temporary file existed, then my script would know that another instance of Matlab was currently writing to the log, and that it should pause for a moment and try again. The problem of this method is, as described above: Two instances test at the same time, if the temporary file is existing. Then both instances decide, that there is none and create it. This *is* a racing condition. My Professor told me: 1. A program is a deterministic algorithm, which stops after a finite time. 2. Write programs, if you want to use a computer. Although from the view point of the universe, each evaluation in a computer is deterministic, for practical usage a racing condition is not. If you can proove, that the frequency of collisions is smaller than the inverse of the age of the universe (or the age of computers), I'd be satisfied. Kind regards, Jan
|
Pages: 1 Prev: Cell2mat issues Next: Tips to find "From" blocks without corresponding "Goto" |