Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev Use kthread_join() to wait for the termination of th...



details:   https://anonhg.NetBSD.org/src/rev/78b57add6104
branches:  trunk
changeset: 766393:78b57add6104
user:      hannken <hannken%NetBSD.org@localhost>
date:      Tue Jun 21 13:59:41 2011 +0000

description:
Use kthread_join() to wait for the termination of the helper thread.

diffstat:

 sys/dev/fss.c |  13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)

diffs (49 lines):

diff -r 7c0e7b0c7d11 -r 78b57add6104 sys/dev/fss.c
--- a/sys/dev/fss.c     Tue Jun 21 13:25:45 2011 +0000
+++ b/sys/dev/fss.c     Tue Jun 21 13:59:41 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fss.c,v 1.76 2011/06/21 12:41:24 hannken Exp $ */
+/*     $NetBSD: fss.c,v 1.77 2011/06/21 13:59:41 hannken Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.76 2011/06/21 12:41:24 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.77 2011/06/21 13:59:41 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -455,8 +455,9 @@
        }
 
        sc->sc_flags |= FSS_BS_THREAD;
-       if ((error = kthread_create(PRI_BIO, 0, NULL, fss_bs_thread, sc,
-           &sc->sc_bs_lwp, "%s", device_xname(sc->sc_dev))) != 0) {
+       if ((error = kthread_create(PRI_BIO, KTHREAD_JOINABLE, NULL,
+           fss_bs_thread, sc, &sc->sc_bs_lwp,
+           "%s", device_xname(sc->sc_dev))) != 0) {
                sc->sc_flags &= ~FSS_BS_THREAD;
                return error;
        }
@@ -478,9 +479,8 @@
                mutex_enter(&sc->sc_slock);
                sc->sc_flags &= ~FSS_BS_THREAD;
                cv_signal(&sc->sc_work_cv);
-               while (sc->sc_bs_lwp != NULL)
-                       kpause("fssdetach", false, 1, &sc->sc_slock);
                mutex_exit(&sc->sc_slock);
+               kthread_join(sc->sc_bs_lwp);
 
                disk_detach(sc->sc_dkdev);
        }
@@ -1056,7 +1056,6 @@
                        cv_wait(&sc->sc_work_cv, &sc->sc_slock);
                thread_idle = true;
                if ((sc->sc_flags & FSS_BS_THREAD) == 0) {
-                       sc->sc_bs_lwp = NULL;
                        mutex_exit(&sc->sc_slock);
                        kthread_exit(0);
                }



Home | Main Index | Thread Index | Old Index