From: Ilmari Heikkinen Date: 2005-12-24T07:23:20+09:00 Subject: Re: multithreaded file access On 12/23/05, J. Ryan Sobol wrote:> On Dec 23, 2005, at 4:13 PM, Ilmari Heikkinen wrote:> > [kig@jugend:~] ruby fw_test.rb> > puts in different threads seems to be atomic>> Crafty test program. Coincidentally, my results differ from yours.>> $ ruby fw_test.rb> puts in different threads isn't atomic> $ ruby -v> ruby 1.8.2 (2004-12-25) [powerpc-darwin8.3.0] Good! I thought it was odd that they seemed to be atomic.. And now we know to mutex disk writes (or use flock.) > I'm getting 8 unique lines in File.readlines(fn).uniq, as opposed to> the 3 thread objects in ts. Assuming I understand the program, that> means threads are not waiting their turn like they should. FYI, I've> compiled my own ruby executable from DarwinPorts instead of using the> 'broken' one shipped in OS X Tiger.>> However, if I change the multiplication factor in line 3 to 655, then>> $ ruby fw_test.rb> puts in different threads seems to be atomic I don't know the reason (can guess, but too unsure)Explanation anyone? > ~ ryan ~>> PS - I love the 205+ MB of text this app generates! :-D Ilmari