Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Monitor + killing thread => thread in an aborting state

Reply
Thread Tools

Monitor + killing thread => thread in an aborting state

 
 
Christopher Debski
Guest
Posts: n/a
 
      02-22-2009
Hi
I am using ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32].
I have made a small program, to see whether killing thread is safe, when
it is using a monitor.
I have 3 threads:
-writer, which changes global resource guarded by monitor
-interrupter, which kills and spawns writer in a loop
-main, which only monitors other threads

After a few seconds my program hangs, because kill method does not
return. Main thread says that the writer thread is in an aborting state.

Sample output:
writer: ok?
main: tick writer-#<Thread:0x3b4b1e run> interrupter-#<Thread:0x1a80aea
run>
interrupter: kill
interrupter: join
interrupter: sleep 1
interrupter: new
interrupter: sleep 2
writer: ok?
interrupter: kill
main: tick writer-#<Thread:0x1b66b06 aborting>
interrupter-#<Thread:0x1a80aea run>
main: tick writer-#<Thread:0x1b66b06 aborting>
interrupter-#<Thread:0x1a80aea run>
main: tick writer-#<Thread:0x1b66b06 aborting>
interrupter-#<Thread:0x1a80aea run>
(repeats infinitely)

Is it ruby's bug?
See attachment for full program source.

Regards,
Christopher

Attachments:
http://www.ruby-forum.com/attachment/3328/rubyMon.txt

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Alex Katebi
Guest
Posts: n/a
 
      02-22-2009
[Note: parts of this message were removed to make it a legal post.]

For one thing you should use ruby 1.9 which uses the OS thread instead of
native ruby threading. The other is when you kill or cancel thread you need
to provide safe areas for your condemned thread to die so resources are
releases if any used.
Look into pthread about canceling.

On Sun, Feb 22, 2009 at 11:34 AM, Christopher Debski <
http://www.velocityreviews.com/forums/(E-Mail Removed)> wrote:

> Hi
> I am using ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32].
> I have made a small program, to see whether killing thread is safe, when
> it is using a monitor.
> I have 3 threads:
> -writer, which changes global resource guarded by monitor
> -interrupter, which kills and spawns writer in a loop
> -main, which only monitors other threads
>
> After a few seconds my program hangs, because kill method does not
> return. Main thread says that the writer thread is in an aborting state.
>
> Sample output:
> writer: ok?
> main: tick writer-#<Thread:0x3b4b1e run> interrupter-#<Thread:0x1a80aea
> run>
> interrupter: kill
> interrupter: join
> interrupter: sleep 1
> interrupter: new
> interrupter: sleep 2
> writer: ok?
> interrupter: kill
> main: tick writer-#<Thread:0x1b66b06 aborting>
> interrupter-#<Thread:0x1a80aea run>
> main: tick writer-#<Thread:0x1b66b06 aborting>
> interrupter-#<Thread:0x1a80aea run>
> main: tick writer-#<Thread:0x1b66b06 aborting>
> interrupter-#<Thread:0x1a80aea run>
> (repeats infinitely)
>
> Is it ruby's bug?
> See attachment for full program source.
>
> Regards,
> Christopher
>
> Attachments:
> http://www.ruby-forum.com/attachment/3328/rubyMon.txt
>
> --
> Posted via http://www.ruby-forum.com/.
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
aborting without killing the python interpreter Russ Python 5 02-19-2006 10:01 AM
Stop aborting my thread! Jerry Camel ASP .Net 7 02-26-2004 04:47 PM
Aborting a _Click event? Wayne MJ ASP .Net 0 07-23-2003 05:50 AM
Aborting Fucntions Willem Oosthuizen VHDL 2 07-11-2003 11:32 AM
I need help on aborting msxml3 sax2 parser Asana MCSD 0 06-30-2003 01:02 PM



Advertisments