| MATLAB Central > MATLAB Newsreader > Safe file mutex without race condition |
|
|
|
Subject: Safe file mutex without race condition From: Jan Simon Date: 15 Apr, 2010 13:10:22 Message: 1 of 13 |
|
Dear Newsgroup! |
|
Subject: Safe file mutex without race condition From: Ashish Uthama Date: 15 Apr, 2010 12:27:10 Message: 2 of 13 |
|
On Thu, 15 Apr 2010 10:10:22 -0300, Jan Simon |
|
Subject: Safe file mutex without race condition From: Jan Simon Date: 15 Apr, 2010 18:14:06 Message: 3 of 13 |
|
Dear Ashish! |
|
Subject: Safe file mutex without race condition From: Walter Roberson Date: 15 Apr, 2010 19:34:27 Message: 4 of 13 |
|
Jan Simon wrote: |
|
Subject: Safe file mutex without race condition From: Yair Altman Date: 15 Apr, 2010 22:26:04 Message: 5 of 13 |
|
Another poor-man's solution: try using the fileattrib function to test & set a specific file attribute (for example: archive or execute). It's not guarantied to be "thread-safe", but it should work in practice unless you have extremely close race conditions. |
|
Subject: Safe file mutex without race condition From: Jan Simon Date: 16 Apr, 2010 20:39:24 Message: 6 of 13 |
|
Dear Yair! |
|
Subject: Safe file mutex without race condition From: Walter Roberson Date: 16 Apr, 2010 21:15:20 Message: 7 of 13 |
|
Jan Simon wrote: |
|
Subject: Safe file mutex without race condition From: Jan Simon Date: 17 Apr, 2010 20:14:05 Message: 8 of 13 |
|
Dear Walter! |
|
Subject: Safe file mutex without race condition From: Walter Roberson Date: 17 Apr, 2010 22:02:25 Message: 9 of 13 |
|
Jan Simon wrote: |
|
Subject: Safe file mutex without race condition From: David Portabella Date: 10 Aug, 2010 18:37:04 Message: 10 of 13 |
|
> Is there a method to create a safe file mutex in Matlab? |
|
Subject: Safe file mutex without race condition From: Walter Roberson Date: 10 Aug, 2010 19:01:10 Message: 11 of 13 |
|
David Portabella wrote: |
|
Subject: Safe file mutex without race condition From: Sean Date: 10 Aug, 2010 22:07:05 Message: 12 of 13 |
|
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. |
|
Subject: Safe file mutex without race condition From: Jan Simon Date: 11 Aug, 2010 00:00:21 Message: 13 of 13 |
|
Dear Sean, |
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
