freeride-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [FR-devel] Yet another Win32 thread bug - how to reproduce


From: Curt Hibbs
Subject: RE: [FR-devel] Yet another Win32 thread bug - how to reproduce
Date: Thu, 12 Sep 2002 13:59:08 -0700

I'm leaving work right now -- I'll try this out this evening.

Curt

> -----Original Message-----
> From: address@hidden
> [mailto:address@hidden Behalf Of
> Laurent Julliard
> Sent: Thursday, September 12, 2002 1:52 PM
> To: Lyle Johnson
> Cc: FreeRIDE Developers
> Subject: [FR-devel] Yet another Win32 thread bug - how to reproduce
> 
> 
> Lyle,
> 
> I thought the popen_test.rb file I posted before was working but 
> actually it wasn't. I have reshaped popen_test.rb to make the thread 
> problem even more visible on Win32. Here is the new program:
> 
> (please other FR developpers tell me if this program runs correctly 
> and which Ruby platform/version do you use)
> 
> ----- beginning of script -----------
> 
> command = "ruby -e 'loop { STDOUT.sync=true;sleep 5; puts 'Ding!'}'"
> 
> f = IO.popen(command)
> 
> th1 = Thread.new {
>    loop {
>      begin
>        text = f.sysread(100)
>        print text
>      rescue EOFError
>        puts "Remote program stopped"
>        exit
>      end
>    }
> }
> 
> th2 = Thread.new(0) { |i|
>    loop { sleep 1; puts i=i+1 }
> }
> 
> th1.join
> th2.join
> 
> ----- end of script -----------
> 
> 
> On Linux (Ruby 1.6.6.) the output is exactly what one would expect:
> 
> 1
> 2
> 3
> 4
> Ding!
> 5
> 6
> 7
> 8
> 9
> Ding!
> 10
> 
> On Win32 (Ruby 1.7.3+ from CVS including the recent fix for mswin32 
> threads) the (wrong) output is :
> 
> Ding!1
> 
> Ding!2
> 
> Ding!3
> 
> 
> What happens is that the sysread call in th1 which is a blocking read 
> most of the time prevents th2 from running or it rather looks like th2 
> is given a chance to print something only when th1 does print 
> something itself once every 5 seconds.
> 
> I think this the root cause of all our troubles at least in FreeRIDE 
> and may be in FOX addInput() as well. Do you think it's a real bug or 
> is there something wrong in my program?
> 
> Laurent
> 
> 
> 
> 
> _______________________________________________
> Freeride-devel mailing list
> address@hidden
> http://mail.freesoftware.fsf.org/mailman/listinfo/freeride-devel
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]