thread and gc.fullCollect

Sean Kelly sean at f4.ca
Thu Jan 11 19:30:35 PST 2007


Ant wrote:
> Ant wrote:
> complete run on gdb:
> 
> $ gdb ./tt
> GNU gdb 6.4.90-debian
> Copyright (C) 2006 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you 
> are
> welcome to change it and/or distribute copies of it under certain 
> conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for details.
> This GDB was configured as "i486-linux-gnu"...Using host libthread_db 
> library "/lib/tls/i686/cmov/libthread_db.so.1".
> 
> (gdb) r
> Starting program: /tt
> [Thread debugging using libthread_db enabled]
> [New Thread -1210247504 (LWP 11551)]
> [New Thread -1211298912 (LWP 11554)]
> 
> Program received signal SIGUSR1, User defined signal 1.
> [Switching to Thread -1211298912 (LWP 11554)]
> 0xb7e9f508 in clone () from /lib/tls/i686/cmov/libc.so.6
> (gdb) c
> Continuing.
> 
> Program received signal SIGUSR2, User defined signal 2.
> 0xffffe410 in __kernel_vsyscall ()
> (gdb) c
> Continuing.
> 
> Program received signal SIGUSR1, User defined signal 1.
> 0xb7e9f508 in clone () from /lib/tls/i686/cmov/libc.so.6
> (gdb) c
> Continuing.
> 
> Program received signal SIGUSR2, User defined signal 2.
> 0xffffe410 in __kernel_vsyscall ()
> (gdb) c
> Continuing.
> Count = 0
> Count = 1
> 
> Program received signal SIGUSR1, User defined signal 1.
> 0xffffe410 in __kernel_vsyscall ()
> (gdb) c
> Continuing.
> 
> Program received signal SIGUSR2, User defined signal 2.
> 0xffffe410 in __kernel_vsyscall ()
> (gdb) c
> Continuing.
> [Thread -1211298912 (LWP 11554) exited]
> 
> Program exited normally.
> (gdb)

I know what's happening.  The sleep function is being interrupted by 
SIGUSR1, which is sent to indicate the beginning of a collection.  Then 
when the thread is resumed via SIGUSR2 it simply exits, since sleep was 
canceled.  The only real alternative on Unix would be to get the system 
time before sleeping, compare it against the time after sleeping, and 
resume sleeping if the thread hasn't slept long enough.


Sean


More information about the Digitalmars-d-learn mailing list