Thread-Safe FileStreams

Andreas Raab raab at isgnw.cs.Uni-Magdeburg.DE
Mon Apr 6 17:15:28 UTC 1998


Mark,

> Over on the PWS mailing list (pws at cc.gatech.edu), we've been investigating
> Squeak's file system under thread access.  If process 1 opens the file,
> then process 2 opens the file, then process 1 closes the file, then process
> 2 closes the file, what happens?  The short answer is that you get a
> primitive failure, but if you do this long enough and ignore the errors
> (through exception handling), you end up leaking all the file handles.  The
> code at the bottom of this message, run a couple times, uses up all the
> filehandles on a PowerMac 6100 running Jitter 1.31 under System 7.6.1.

You're doing two bad things at the same time ;-) Not only you access the
same file from different processes, you even more *share* the variable
where the file pointer is stored. If you wouldn't do this, you would not
run out of file handles. If you would use aFile1, aFile2, and aFile3 in
each process everything would be fine (except from the primitiveFailed
of course).

  Andreas
-- 
Linear algebra is your friend - Trigonometry is your enemy.
+===== Andreas Raab ============= (raab at isg.cs.uni-magdeburg.de) =====+
I Department of Simulation and Graphics      Phone: +49 391 671 8065  I
I University of Magdeburg, Germany           Fax:   +49 391 671 1164  I
+=============< http://isgwww.cs.uni-magdeburg.de/~raab >=============+





More information about the Squeak-dev mailing list