brianfeaster / worldtm

Automatically exported from code.google.com/p/worldtm
0 stars 0 forks source link

Interrupts wake up sleeping threads prematurely #17

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
To replicate create an interrupt handler, call sleep then send the interrupt:

(vector-set! SIGNALHANDLERS 2 (lambda () (display 'interrupt) (unthread)))
(signal 2)
(begin (sleep 10000) (display 'DONE))

Hitting ctrl-c will result in "^CinterruptDONE" being displayed.

Original issue reported on code.google.com by bri...@gmail.com on 9 Sep 2010 at 8:09

GoogleCodeExporter commented 8 years ago
(vector-set! SIGNALHANDLERS 2 (lambda () (display 'interrupt) (unthread)))
(signal 2)
(thread (sleep 10000) (display 'AAAA))
(thread (sleep 10000) (display 'BBBB))
(thread (sleep 10000) (display 'DDDD))
(begin (sleep 10000) (display 'DONE))

Interrupting the process with ctrl-c will only wake up the current thread but 
not the three spawned threads.

Original comment by bri...@gmail.com on 30 Jun 2011 at 10:11

GoogleCodeExporter commented 8 years ago
Fix in r158.  The bug was in the scheduler and was caused by Linux interrupts 
forcing usleep to return before the timer expired.  This forced the next 
sleeping thread to be scheduled.  The fix is to check that the thread is indeed 
ready to be run as well as check if a new signal handler thread needs to be 
created and ready-queued.

Original comment by bri...@gmail.com on 7 Jul 2011 at 4:55