| Parallel Computing Toolbox™ | ![]() |
labBarrier
labBarrier blocks execution of a parallel algorithm until all labs have reached the call to labBarrier. This is useful for coordinating access to shared resources such as file I/O.
In this example, all labs know the shared data filename.
fname = 'c:\data\datafile.mat';
Lab 1 writes some data to the file, which all other labs will read.
if labindex == 1
data = randn(100, 1);
save(fname, 'data');
pause(5) %allow time for file to become available to other labs
end
All labs wait until all have reached the barrier; this ensures that no lab attempts to load the file until lab 1 writes to it.
labBarrier; load(fname);
![]() | jobStartup | labBroadcast | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |