How can I troubleshoot this in my code 'The process cannot access the file because it is being used by another process.'

I am using matlabpool command to run some txt files from one software using parfor command. The problem here is that I am receiving this error 'The process cannot access the file because it is being used by another process'
Can someone guide me on this that what should i change in my code to avoid this error.
parfor i = 1 : N
xxxxx...........
end

 Accepted Answer

It sounds as if you might have different iterations of the loop attempting to write to the same output file. You need to use different output files for the different iterations.

4 Comments

No ... in parfor loop the code is calling different input files based on the iteration number and generate result file based on the iteration number as well ... but the problem is that it is not generating some files on random iteration number ... for eg.
It misses itereation 5th file, 12th 18th etc.
The reason I understand is that may be 2 cores are addressing same iteration file ... but it is built-in in matlab. Do anyone knows how to resolve this issue ?
Please show the code, and also indicate which line the error is being generated against.
parfor fit_loop = 1 : Pop_size
system(['$eclipse ' 'MainFile30x30x3(' int2str(fit_loop) ')'])
end
Are you assuming that the iterations are executed in order in your code? parfor does not guarantee the order in which iterations are executed.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!