>>>>> "Y" == Yukihiro Matsumoto <matz / ruby-lang.org> writes:

Y> Sorry for being stupid, but rb_trap_immediate is turned off in the
Y> restore_context, so thread_timer only set rb_thread_pending to 1 at
Y> most during the function execution, thus context switch would not
Y> happen even when tb_thread_critical is not set, right?

 Another example (yesterday it was easier to see that that was io_fflush()
 which give him the possibility to block easily). Same here I stop it
 immediately when it block


(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y

Starting program: /home/ts/ruby/ruby-1.8.1/ruby c.rb
[New Thread 16384 (LWP 8256)]
[New Thread 32769 (LWP 8257)]
[New Thread 16386 (LWP 8258)]
- 1- 1- 2- 3- 4- 5- 6- 7- 8- 9- 10- 11- 12- 13- 14- 15- 16||- 17- 17- 18- 19- 20- 21- 22- 23- 24- 25- 26- 27- 28- 29- 30- 31- 32- 33- 34- 35- 36- 37- 38- 39- 40- 41- 42- 43- 44- 45- 46- 47- 48- 49- 50|||||||||- 51- 51- 51- 51- 51- 51- 51- 51- 52- 52- 52- 52- 54- 54|- 55|||||||- 56||||||- 57- 58- 58- 58- 59- 59- 59- 59- 59- 59- 59- 59- 60- 60- 60- 61- 61- 61- 61- 62||||||- 63|- 63- 63- 63|- 64- 64- 64- 65|||||- 66- 66- 67|||||- 67- 68- 68- 68||- 69|||- 69- 69- 69- 70|
Program received signal SIGINT, Interrupt.
[Switching to Thread 16386 (LWP 8258)]
0x40033156 in nanosleep () from /lib/i686/libpthread.so.0
(gdb) t 1
[Switching to thread 1 (Thread 16384 (LWP 8256))]#0  0x420459c6 in setcontext
    () from /lib/i686/libc.so.6
(gdb) bt
#0  0x420459c6 in setcontext () from /lib/i686/libc.so.6
#1  0x081cdd70 in ?? ()
#2  0x080629a0 in rb_thread_schedule () at eval.c:8943
#3  0x4003274e in __pthread_sighandler () from /lib/i686/libpthread.so.0
#4  0xbffe9dd8 in ?? ()
(gdb) stepi 32
8427        switch (n) {
(gdb) bt
#0  rb_thread_switch (n=1) at eval.c:8427
#1  0x08062945 in rb_thread_schedule () at eval.c:8930
#2  0x4003274e in __pthread_sighandler () from /lib/i686/libpthread.so.0
#3  <signal handler called>
#4  0x420459c6 in setcontext () from /lib/i686/libc.so.6
#5  0x081cdd70 in ?? ()
#6  0x080629a0 in rb_thread_schedule () at eval.c:8943
#7  0x4003274e in __pthread_sighandler () from /lib/i686/libpthread.so.0
#8  0xbffe9dd8 in ?? ()
(gdb) 




Guy Decoux