Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jan 2002 12:34:06 -0800
From:      Alfred Perlstein <bright@mu.org>
To:        Julian Elischer <julian@elischer.org>
Cc:        arch@freebsd.org, dillon@freebsd.org
Subject:   Re: STOP and SLEEP in the kernel
Message-ID:  <20020122123406.D13686@elvis.mu.org>
In-Reply-To: <Pine.BSF.4.21.0201221130030.18165-100000@InterJet.elischer.org>; from julian@elischer.org on Tue, Jan 22, 2002 at 11:54:19AM -0800
References:  <Pine.BSF.4.21.0201221130030.18165-100000@InterJet.elischer.org>

next in thread | previous in thread | raw e-mail | index | archive | help
* Julian Elischer <julian@elischer.org> [020122 12:00] wrote:
> 
> Matt Dillon and I spent some time looking at the way in which process
> suspension is achieved in FreeBSD in order to try work out how best to do
> it in the KSE kernel.
> 
> We discovered a couple of things. 
> FIrstly that teh suspension occurs in CURSIG() which is an alias for
> issignal()

To deal with these issues it may be a good idea to consider a rundown
state in which kses automatically exit right before returning to userland.

This should help:

thread A calls exit(2).

  in exit(2) the thread aquires a lock on the proc struct.
  if the thread count is 1, it just exit(2)s, otherwise:

    it marks "in exit" in the proc struct.
    it then signalls all threads with a non blockable signal.
       (this will cause them to enter the kernel or interrupt any long blocking
        operation.)
    it then sleeps on the proc struct's thread count address or a cv.

  Now all other threads should be in the kernel.
  They will post a signal to themselves to help them avoid blocking.
  At exit points they will notice the flag and self terminate themselves,
    they will decerement the thread count.
  The second to last thread (the thread other than 'A') will notice the
    count go to '1' and wakeup the exit(2)'ing thread.

Done.

-- 
-Alfred Perlstein [alfred@freebsd.org]
'Instead of asking why a piece of software is using "1970s technology,"
 start asking why software is ignoring 30 years of accumulated wisdom.'
Tax deductable donations for FreeBSD: http://www.freebsdfoundation.org/

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020122123406.D13686>