From owner-cvs-all Tue Sep 29 23:37:06 1998 Return-Path: Received: (from daemon@localhost) by hub.freebsd.org (8.8.8/8.8.8) id XAA05244 for cvs-all-outgoing; Tue, 29 Sep 1998 23:37:06 -0700 (PDT) (envelope-from owner-cvs-all) Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id XAA05238; Tue, 29 Sep 1998 23:37:01 -0700 (PDT) (envelope-from jb@FreeBSD.org) From: John Birrell Received: (from jb@localhost) by freefall.freebsd.org (8.8.8/8.8.5) id XAA11479; Tue, 29 Sep 1998 23:36:56 -0700 (PDT) Date: Tue, 29 Sep 1998 23:36:56 -0700 (PDT) Message-Id: <199809300636.XAA11479@freefall.freebsd.org> To: cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG Subject: cvs commit: src/lib/libc_r/uthread uthread_gc.c Makefile.inc uthread_init.c uthread_find_thread.c uthread_kern.c uthread_create.c uthread_exit.c Sender: owner-cvs-all@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk jb 1998/09/29 23:36:56 PDT Modified files: lib/libc_r/uthread Makefile.inc uthread_init.c uthread_find_thread.c uthread_kern.c uthread_create.c uthread_exit.c Added files: lib/libc_r/uthread uthread_gc.c Log: Move the cleanup code that frees memory allocated for a dead thread from the thread kernel into a garbage collector thread which is started when the fisrt thread is created (other than the initial thread). This removes the window of opportunity where a context switch will cause a thread that has locked the malloc spinlock, to enter the thread kernel, find there is a dead thread and try to free memory, therefore trying to lock the malloc spinlock against itself. The garbage collector thread acts just like any other thread, so instead of having a spinlock to control accesses to the dead thread list, it uses a mutex and a condition variable so that it can happily wait to be signalled when a thread exists. Revision Changes Path 1.16 +2 -1 src/lib/libc_r/uthread/Makefile.inc 1.9 +5 -0 src/lib/libc_r/uthread/uthread_init.c 1.2 +10 -5 src/lib/libc_r/uthread/uthread_find_thread.c 1.13 +2 -80 src/lib/libc_r/uthread/uthread_kern.c 1.10 +16 -0 src/lib/libc_r/uthread/uthread_create.c 1.6 +17 -44 src/lib/libc_r/uthread/uthread_exit.c