From owner-man-jp-reviewer@jp.FreeBSD.org Fri May  6 02:09:53 2005
Received: (from daemon@localhost)
	by castle.jp.FreeBSD.org (8.11.6p2+3.4W/8.11.3) id j45H9r647745;
	Fri, 6 May 2005 02:09:53 +0900 (JST)
	(envelope-from owner-man-jp-reviewer@jp.FreeBSD.org)
Received: from t-mta1.odn.ne.jp (mfep1.odn.ne.jp [143.90.131.179])
	by castle.jp.FreeBSD.org (8.11.6p2+3.4W/8.11.3) with ESMTP/inet id j45H9rX47740
	for <man-jp-reviewer@jp.FreeBSD.org>; Fri, 6 May 2005 02:09:53 +0900 (JST)
	(envelope-from n-kogane@syd.odn.ne.jp)
Received: from kces6.koganemaru.co.jp ([220.212.168.108])
          by t-mta1.odn.ne.jp with ESMTP
          id <20050505170953091.CWQF.8089.t-mta1.odn.ne.jp@mta1.odn.ne.jp>
          for <man-jp-reviewer@jp.FreeBSD.org>;
          Fri, 6 May 2005 02:09:53 +0900
Received: by kces6.koganemaru.co.jp (Postfix, from userid 100)
	id 4FF6AFE89; Fri,  6 May 2005 02:10:19 +0900 (JST)
To: man-jp-reviewer@jp.FreeBSD.org
MIME-Version: 1.0 (generated by MimeKit/1.8)
Content-Type: text/plain; charset=ISO-2022-JP
Message-Id: <20050505171019.4FF6AFE89@kces6.koganemaru.co.jp>
From: n-kogane@syd.odn.ne.jp (Nobuyuki Koganemaru)
Reply-To: man-jp-reviewer@jp.FreeBSD.org
Precedence: list
Date: Fri, 6 May 2005 02:10:19 +0900
X-Sequence: man-jp-reviewer 4771
Subject: [man-jp-reviewer 4771] kse.2 Update to 5.4RC4
Sender: owner-man-jp-reviewer@jp.FreeBSD.org
X-Originator: n-kogane@syd.odn.ne.jp
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+050320

$B>.6b4]$G$9!#(B

is only a close approximation to the problem $B$NLu$O$h$/$o$+$j$^$;$s!#(B

$B8e$m$K1QJ8$N:9J,$bIU$1$^$9!#(B

--- kse.2.orig	Wed Sep  1 23:37:33 2004
+++ kse.2	Fri May  6 02:00:25 2005
@@ -33,7 +33,7 @@
 .\" THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF
 .\" THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.\" %FreeBSD: src/lib/libc/sys/kse.2,v 1.13 2003/12/10 02:38:51 marcel Exp %
+.\" %FreeBSD: src/lib/libc/sys/kse.2,v 1.13.2.2 2005/02/28 03:32:34 brueffer Exp %
 .\"
 .\" $FreeBSD: doc/ja_JP.eucJP/man/man2/kse.2,v 1.1 2004/09/01 14:37:33 metal Exp $
 .\"
@@ -276,7 +276,6 @@
 .Fn kse_exit
 $B$O@5>o$KLa$j$^$9!#(B
 $B$3$l$O$=$N%W%m%;%9$r85$K!"$D$^$j%9%l%C%I2=$5$l$F$$$J$$>uBV$KLa$7$^$9!#(B
-($B$3$l$O$^$@<BAu$5$l$F$$$^$;$s(B)
 .Pp
 .Fn kse_release
 $B%7%9%F%`%3!<%k$O!"I,MW$G$J$/$J$C$?$H$-$K!"8=:_<B9T$7$F$$$k%9%l%C%I$K(B
@@ -337,37 +336,65 @@
 .\"
 .Ss $B%7%0%J%k(B
 .\"
-$B%W%m%;%9$,%a!<%k%\%C%/%9$K4XO"IU$1$i$l$?>/$J$/$H$b(B 1 $B$D$N(B KSE $B$r(B
-$B;}$C$F$$$k$H$-$K$O!"%7%0%J%k$O$b$O$d$=$N%W%m%;%9$N%9%?%C%/$K$OG[?.$5$l$J$$(B
-$B$+$b$7$l$^$;$s!#(B
-$BBe$o$j$K!"%7%0%J%k$O(B upcall $B$r2p$7$FG[?.$5$l$k$3$H$,$G$-$^$9!#(B
-$BJ#?t$N%7%0%J%k$O(B 1 $B$D$N(B upcall $B$GG[?.$5$l$k$3$H$,$G$-$^$9!#(B
-($B$3$N5!G=$O$^$@%3!<%I2=$5$l$F$$$^$;$s(B)
 .Pp
-$B$=$N%W%m%;%9$NCf$KJ#?t$N(B KSE $B%0%k!<%W$,B8:_$9$k>l9g$K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9%/$N@_Dj$H(B
+.Fn execve
+$B$N4V$N%W%m%;%9$KG[?.$5$l$k$+$b$7$l$J$$%&%#%s%I%&$r5v2D$7$^$9!#(B
+.\" is only a close approximation to the problem $B$NLu$O$"$d$7$$(B
+.Pp
+$BEvJ,!"$3$NLdBj$OFCJL$NAH$_9g$o$;(B
+.Fn kse_thr_interrupt Ns / Ns Fn execve
+$B%b!<%I$r(B
+.Fn kse_thr_interrupt
+$B%7%9%F%`%3!<%k$KDI2C$9$k$3$H$K$h$C$F2r7h$5$l$F$$$^$9!#(B
+.\" For now = $B:9$7Ev$?$j!"EvJ,$O(B
+.Fn kse_thr_interrupt
+$B%7%9%F%`%3!<%k$O%5%V%3%^%s%I(B
+.Dv KSE_INTR_EXECVE
+$B$,$"$j!"$=$l$O(B
+.Vt kse_execv_args
+$B9=B$BN$r<u$1IU$1$k$3$H$,$G$-!"%7%0%J%k$rD4@0$7$F!"<!$KIT2DJ,$K(B
+.Fn execve()
+$B8F$S=P$7$KJQ49$G$-$^$9!#(B
+.\" $B86J8(B: .Fn execve() $B$O(B .Fn execve $B$N8m$j!#(B
+$BDI2C$N%Z%s%G%#%s%0%7%0%J%k$H@5$7$$%7%0%J%k%^%9%/$O(B
+$B$3$N$h$&$K$7$F%+!<%M%k$KEO$9$3$H$,$G$-$^$9!#(B
+.\" in this way = $B$+$/$N$4$H$/!"$3$&$$$&D4;R$K!"$3$N$h$&$JJ}K!$G!"$3$N$h$&$K(B($B$7$F(B)$B!"(B
+$B%9%l%C%I%i%$%V%i%j$O!"(B
+.Fn execve
+$B%9%9%F%`%3!<%k$r$/$D$,$($7$F!"$=$l$r(B
+.Fn kse_intr_interrupt
+$B8F$S=P$7$KJQ49$7!"B?=E%9%l%C%I$r(B
+.Fn exec
+$B$r9T$J$&A0$K%Z%s%G%#%s%0%7%0%J%k$H@5$7$$%7%0%J%k%^%9%/$K(B
+$BI|85$G$-$k$h$&$K$7$^$9!#(B
+$B$3$NLdBj$N2r7hK!$OJQ99$9$k$+$b$7$l$^$;$s!#(B
 .\"
 .Ss KSE $B%a!<%k%\%C%/%9(B
 .\"
-$B$=$l$>$l$N(B KSE $B$O%f!<%6$H%+!<%M%k$NDL?.$N$?$a$NM#0l$N%a!<%k%\%C%/%9$r(B
-$B;}$C$F$$$^$9(B:
-.Bd -literal
-/* upcall $B4X?t7?(B */
-typedef void   kse_func_t(struct kse_mailbox *);
-
-/* KSE $B%a!<%k%\%C%/%9(B */
-struct kse_mailbox {
-   int         km_version; /* $B%P!<%8%g%s(B */
-   struct kse_thr_mailbox  *km_curthread;  /* $B8=:_$N%9%l%C%I(B */
-   struct kse_thr_mailbox  *km_completed;  /* $B40N;$7$?%9%l%C%I(B */
-   sigset_t        km_sigscaught;  /* $BJa$C$?%7%0%J%k(B */
-   unsigned int        km_flags;   /* KSE $B%U%i%0(B */
-   kse_func_t      *km_func;   /* UTS $B4X?t(B */
-   stack_t         km_stack;   /* UTS $B4D6-(B */
-   void            *km_udata;  /* UTS $B$K$h$C$F;HMQ(B */
-   struct timespec     km_timeofday;   /* upcall $B$N;~4V(B */
-};
-.Ed
+$B$=$l$>$l$N(B KSE $B$O(B
+.In sys/kse.h
+$B$GDj5A$5$l$?%f!<%6$H%+!<%M%k$NDL?.$N$?$a$NM#0l$N%a!<%k%\%C%/%9$,$"$j$^$9!#(B
+$B$=$N%U%#!<%k%I$N$$$/$D$+$O<!$NDL$j$G$9(B:
 .Pp
 .Va km_version
 $B$O$3$N9=B$BN$N%P!<%8%g%s$rI=$7!"(B
@@ -468,26 +495,34 @@
 .Va km_flags
 $B$O0J2<$NA4$F$N%S%C%HKh$N(B OR $B$r4^$`$3$H$,$G$-$^$9(B:
 .Bl -tag -width indent
-.It \&
-($B$^$@%U%i%0$OA4$/Dj5A$5$l$F$$$^$;$s(B)
+.It Dv KMF_NOUPCALL
+upcalls $B$,5/$-$J$$$h$&$K%V%m%C%/$7$^$9!#(B
+$B%9%l%C%I$O2?$i$+$N%/%j%F%#%+%k%;%/%7%g%s(B ($B4m810h(B) $B$K$"$j$^$9!#(B
+.It Dv KMF_NOCOMPLETED , KMF_DONE , KMF_BOUND
+$B$3$N%9%l%C%I$O!"1J5W$K(B KSE $B$K7k$S$D$1$i$l$k$H9M$($i$l$k$Y$-$G!"(B
+$B%9%l%C%I2=$5$l$F$$$J$$%W%m%;%9$H$=$C$/$j$K07$o$l$^$9!#(B
+.\" $B86J8(B: considerred $B$O(B considered $B$N8m$j!#(B
+.\"  considered to be = $B!T(Bbe $B!A!U!A$G$"$k$H9M$($i$l$F$$$k!NL\$5$l$F$$$k!O(B
+.\" much like = $B$=$C$/$j$N!"9s;w$N(B
+$B$=$l$O$"$k0UL#$G$O(B
+.Dv KMF_NOUPCALL
+$B$N(B
+.Dq $BD94|(B
+$B%P!<%8%g%s$G$9!#(B
+.\" in some ways = $B$"$kE@(B[$B0UL#(B]$B$G(B($B$O(B)$B!"$$$m$$$m$J0UL#$G!"$$$/$D$+$NE@$G(B
+.It Dv KMF_WAITSIGEVENT
+$B%7%0%J%kG[?.%9%l%C%I$KI,MW$JFC@-$r<BAu$7$^$9!#(B
+.\" $B86J8(B: charactersitics $B$O(B #  characteristics $B$N8m$j!#(B
 .El
 .\"
 .Ss $B%9%l%C%I%a!<%k%\%C%/%9(B
 .\"
-$B$=$l$>$l$N%f!<%6%9%l%C%I$O$=$l$K4XO"IU$1$i$l$?M#0l$N(B
+$B$=$l$>$l$N%f!<%6%9%l%C%I$O$=$l$K4XO"IU$1$i$l$?(B
+.In sys/kse.h
+$B$GDj5A$5$l$?M#0l$N(B
 .Vt "struct kse_thr_mailbox"
-$B$r;}$?$J$1$l$P$J$j$^$;$s(B:
-.Bd -literal
-/* $B%9%l%C%I%a!<%k%\%C%/%9(B */
-struct kse_thr_mailbox {
-   ucontext_t      tm_context; /* $B%f!<%6%9%l%C%I4D6-(B */
-   unsigned int        tm_flags;   /* $B%9%l%C%I%U%i%0(B */
-   struct kse_thr_mailbox  *tm_next;   /* $B%j%9%HCf$N<!%9%l%C%I(B */
-   void            *tm_udata;  /* UTS $B$K$h$C$F;HMQ(B */
-   unsigned int        tm_uticks;  /* $B%f!<%6;~4V%+%&%s%?(B */
-   unsigned int        tm_sticks;  /* $B%+!<%M%k;~4V%+%&%s%?(B */
-};
-.Ed
+$B$,$J$1$l$P$J$j$^$;$s!#(B
+$B$=$l$O<!$N%U%#!<%k%I$r4^$s$G$$$^$9(B:
 .Pp
 .Va tm_udata
 $B$O%+!<%M%k$K$h$C$FL5;k$5$l$?ITL@NF$J%]%$%s%?$G$9!#(B
@@ -528,8 +563,12 @@
 .Va tm_flags
 $B$O0J2<$NA4$F$N%S%C%HKh$N(B OR $B$r4^$`$3$H$,$G$-$^$9(B:
 .Bl -tag -width indent
-.It \&
-($B$^$@%U%i%0$OA4$/Dj5A$5$l$F$$$^$;$s(B)
+.It Dv TMF_NOUPCALL
+.Dv KMF_NOUPCALL
+$B$HF1MM$G$9!#(B
+$B$3$N%U%i%0$O%/%j%F%#%+%k%;%/%7%g%s(B ($B4m810h(B) $B$X$N(B upcall $B$r6X;_$7$^$9!#(B
+$B$$$/$D$+$N%"!<%-%F%/%A%c$O!"$"$k>l=j$H$b$&JRJ}$G$$$/$D$+$K$"$k$3$H$r(B
+$BI,MW$H$7$^$9!#(B
 .El
 .Sh $BLa$jCM(B
 $B@.8y$N>l9g$K$O(B
@@ -658,17 +697,17 @@
 .Sh $B:n<T(B
 KSE $B$O=i$a$K(B
 .An -nosplit
-.An "Julian Elischer" Aq julian@FreeBSD.org ,
+.An "Julian Elischer" Aq julian@FreeBSD.org
 $B$,<BAu$7!"(B
 .An "Jonathan Mini" Aq mini@FreeBSD.org ,
-.An "Daniel Eischen" Aq deischen@FreeBSD.org ,
+.An "Daniel Eischen" Aq deischen@FreeBSD.org
 $B$*$h$S(B
 .An "David Xu" Aq davidxu@FreeBSD.org
 $B$,DI2C$N9W8%$r$7$^$7$?!#(B
 .Pp
 $B$3$N%^%K%e%"%k%Z!<%8$O(B
 .An "Archie Cobbs" Aq archie@FreeBSD.org
-$B$,=q$-$^$7$?!#(B
+$B$K$h$C$F=q$+$l$^$7$?!#(B
 .Sh $B%P%0(B
 KSE $B$N%3!<%I$O3+H/Cf$G$9!#(B
 .\" .Ud .

diff -u /dskg/JMAN4/5.3-RELEASE/man2/kse.2 /dskg/JMAN4/5.4-RC4/man2/kse.2
--- /dskg/JMAN4/5.3-RELEASE/man2/kse.2	Fri Nov  5 10:24:22 2004
+++ /dskg/JMAN4/5.4-RC4/man2/kse.2	Mon May  2 05:53:48 2005
@@ -33,7 +33,7 @@
 .\" THE USE OF THIS SOFTWARE, EVEN IF PACKET DESIGN IS ADVISED OF
 .\" THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.\" $FreeBSD: src/lib/libc/sys/kse.2,v 1.13 2003/12/10 02:38:51 marcel Exp $
+.\" $FreeBSD: src/lib/libc/sys/kse.2,v 1.13.2.2 2005/02/28 03:32:34 brueffer Exp $
 .\"
 .Dd September 10, 2002
 .Dt KSE 2
@@ -271,7 +271,6 @@
 .Fn kse_exit
 returns normally.
 This returns the process to its original, unthreaded state.
-(This is not yet implemented.)
 .Pp
 The
 .Fn kse_release
@@ -333,35 +332,63 @@
 .\"
 .Ss Signals
 .\"
-When a process has at least one KSE with an associated mailbox, then
-signals might no longer be delivered on the process stack.
-Instead, signals may be delivered via upcalls.
-Multiple signals may be delivered with one upcall.
-(This feature is not yet coded.)
 .Pp
-If there are multiple KSE groups in the process, which KSE group is
-chosen to deliver the signal is indeterminate.
+The current implementation creates a special signal thread.
+Kernel threads (KSEs) in a process mask all signals, and only the signal
+thread waits for signals to be delivered to the process, the signal thread
+is responsible
+for dispatching signals to user threads.
+.Pp
+A downside of this is that if a multiplexed thread
+calls the
+.Fn execve
+syscall, its signal mask and pending signals may not be
+available in the kernel.
+They are stored
+in userland and the kernel does not know where to get them, however
+.Tn POSIX
+requires them to be restored and passed them to new process.
+Just setting the mask for the thread before calling
+.Fn execve
+is only a 
+close approximation to the problem as it does not re-deliver back to the kernel
+any pending signals that the old process may have blocked, and it allows a
+window in which new signals may be delivered to the process between the setting
+of the mask and the
+.Fn execve .
+.Pp
+For now this problem has been solved by adding a special combined
+.Fn kse_thr_interrupt Ns / Ns Fn execve
+mode to the
+.Fn kse_thr_interrupt
+syscall.
+The
+.Fn kse_thr_interrupt
+syscall has a sub command
+.Dv KSE_INTR_EXECVE ,
+that allows it to accept a
+.Vt kse_execv_args
+structure, and allowing it to adjust the signals and then atomically
+convert into an
+.Fn execve()
+call.
+Additional pending signals and the correct signal mask can be passed
+to the kernel in this way.
+The thread library overrides the
+.Fn execve
+syscall
+and translates it into
+.Fn kse_intr_interrupt
+call, allowing a multiplexed thread
+to restore pending signals and the correct signal mask before doing the
+.Fn exec .
+This solution to the problem may change.
 .\"
 .Ss KSE Mailboxes
 .\"
-Each KSE has a unique mailbox for user-kernel communication:
-.Bd -literal
-/* Upcall function type */
-typedef void	kse_func_t(struct kse_mailbox *);
-
-/* KSE mailbox */
-struct kse_mailbox {
-	int			km_version;	/* Mailbox version */
-	struct kse_thr_mailbox	*km_curthread;	/* Current thread */
-	struct kse_thr_mailbox	*km_completed;	/* Completed threads */
-	sigset_t		km_sigscaught;	/* Caught signals */
-	unsigned int		km_flags;	/* KSE flags */
-	kse_func_t		*km_func;	/* UTS function */
-	stack_t			km_stack;	/* UTS context */
-	void			*km_udata;	/* For use by the UTS */
-	struct timespec		km_timeofday;	/* Time of upcall */
-};
-.Ed
+Each KSE has a unique mailbox for user-kernel communication defined in
+.In sys/kse.h .
+Some of the fields there are:
 .Pp
 .Va km_version
 describes the version of this structure and must be equal to
@@ -459,25 +486,28 @@
 .Va km_flags
 may contain any of the following bits OR'ed together:
 .Bl -tag -width indent
-.It \&
-(No flags are defined yet.)
+.It Dv KMF_NOUPCALL
+Block upcalls from happening.
+The thread is in some critical section.
+.It Dv KMF_NOCOMPLETED , KMF_DONE , KMF_BOUND
+This thread should be considerred to be permanently bound to
+its KSE, and treated much like a non-threaded process would be.
+It is a
+.Dq "long term"
+version of
+.Dv KMF_NOUPCALL
+in some ways.
+.It Dv KMF_WAITSIGEVENT
+Implement charactersitics needed for the signal delivery thread.
 .El
 .\"
 .Ss Thread Mailboxes
 .\"
 Each user thread must have associated with it a unique
-.Vt "struct kse_thr_mailbox" :
-.Bd -literal
-/* Thread mailbox */
-struct kse_thr_mailbox {
-	ucontext_t		tm_context;	/* User thread context */
-	unsigned int		tm_flags;	/* Thread flags */
-	struct kse_thr_mailbox	*tm_next;	/* Next thread in list */
-	void			*tm_udata;	/* For use by the UTS */
-	unsigned int		tm_uticks;	/* User time counter */
-	unsigned int		tm_sticks;	/* Kernel time counter */
-};
-.Ed
+.Vt "struct kse_thr_mailbox"
+as defined in
+.In sys/kse.h .
+It includes the following fields.
 .Pp
 .Va tm_udata
 is an opaque pointer ignored by the kernel.
@@ -516,8 +546,11 @@
 .Va tm_flags
 may contain any of the following bits OR'ed together:
 .Bl -tag -width indent
-.It \&
-(No flags are defined yet.)
+.It Dv TMF_NOUPCALL
+Similar to
+.Dv KMF_NOUPCALL .
+This flag inhibits upcalling for critical sections.
+Some architectures require this to be in one place and some in the other.
 .El
 .Sh RETURN VALUES
 The
--
($BM-(B)$B>.6b4]%3%s%T%e!<%?%(%s%8%K%"%j%s%0%5!<%S%9(B ($BJ!2,8)BgLn>k;T(B)
	$B>.6b4](B $B?.9,(B (Nobuyuki Koganemaru)
E-Mail: n-kogane@syd.odn.ne.jp
E-Mail: kogane@jp.FreeBSD.org
E-Mail: kogane@koganemaru.co.jp
URL: http://www.koganemaru.co.jp
