From owner-man-jp-reviewer@jp.FreeBSD.org Thu Sep  4 09:02:45 2003
Received: (from daemon@localhost)
	by castle.jp.FreeBSD.org (8.11.6p2+3.4W/8.11.3) id h8402jw18173;
	Thu, 4 Sep 2003 09:02:45 +0900 (JST)
	(envelope-from owner-man-jp-reviewer@jp.FreeBSD.org)
Received: from mx02.mitsumi.co.jp (mx02.mitsumi.co.jp [202.33.112.205])
	by castle.jp.FreeBSD.org (8.11.6p2+3.4W/8.11.3) with ESMTP/inet id h8402jw18168
	for <man-jp-reviewer@jp.FreeBSD.org>; Thu, 4 Sep 2003 09:02:45 +0900 (JST)
	(envelope-from a_ikeuchi@mic.mitsumi.co.jp)
Received: from mvc01.mitsumi.co.jp ([192.168.1.254])
	by mx02.mitsumi.co.jp (8.11.6p2/8.11.6) with ESMTP id h8402u908871
	for <man-jp-reviewer@jp.FreeBSD.org>; Thu, 4 Sep 2003 09:02:56 +0900
Received: from mmx01.mitsumi.co.jp (localhost [127.0.0.1] (may be forged))
	by mvc01.mitsumi.co.jp (8.11.6/8.11.6) with ESMTP id h8402ZY07188
	for <man-jp-reviewer@jp.FreeBSD.org>; Thu, 4 Sep 2003 09:02:35 +0900
Received: from ml01.mic.mitsumi.co.jp (mic.mitsumi.co.jp [172.17.5.244] (may be forged))
	by mmx01.mitsumi.co.jp (8.9.3p2+3.2W/3.7W) with ESMTP id JAA24885
	for <man-jp-reviewer@jp.FreeBSD.org>; Thu, 4 Sep 2003 09:02:28 +0900
Received: from mic.mitsumi.co.jp (a-ikeuchi.mic.mitsumi.co.jp [172.17.40.89])
	by ml01.mic.mitsumi.co.jp (8.10.2/8.10.2) with ESMTP id h83NkE808757;
	Thu, 4 Sep 2003 08:46:33 +0900
Message-ID: <3F568149.1080108@mic.mitsumi.co.jp>
From: Akira Ikeuchi <a_ikeuchi@mic.mitsumi.co.jp>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja-JP; rv:1.4) Gecko/20030718
X-Accept-Language: ja, en-us, en
MIME-Version: 1.0
To: man-jp-reviewer@jp.FreeBSD.org
Content-Type: text/plain; charset=ISO-2022-JP
Content-Transfer-Encoding: 7bit
Reply-To: man-jp-reviewer@jp.FreeBSD.org
Precedence: list
Date: Thu, 04 Sep 2003 09:03:21 +0900
X-Sequence: man-jp-reviewer 4507
Subject: [man-jp-reviewer 4507] (man2) kse.2 (& Makefile)
Sender: owner-man-jp-reviewer@jp.FreeBSD.org
X-Originator: a_ikeuchi@mic.mitsumi.co.jp
X-Distribute: distribute version 2.1 (Alpha) patchlevel 24e+030902

$BCSFb$G$9!#(B

man2 $B$N(B kse.2 $B$N=iLu$G$9!#(B
$B%A%'%C%/$*4j$$$7$^$9!#(B
Makefile $B$b=$@5$7$F$_$^$7$?!#(B


diff -ur original/Makefile japanese/Makefile
--- original/Makefile	Sun Aug 24 13:26:14 2003
+++ japanese/Makefile	Wed Sep  3 22:37:02 2003
@@ -67,6 +67,7 @@
 	kldsym.2\
 	kldunload.2\
 	kqueue.2\
+	kse.2\
 	ktrace.2\
 	link.2\
 	lio_listio.2\
@@ -190,6 +191,8 @@
 MLINKS+=intro.2 errno.2
 MLINKS+=jail.2 jail_attach.2
 MLINKS+=kqueue.2 kevent.2
+MLINKS+=kse.2 kse_create.2 kse.2 kse_exit.2 kse.2 kse_release.2 \
+	kse.2 kse_wakeup.2 kse.2 kse_thr_interrupt.2
 MLINKS+=madvise.2 posix_madvise.2
 MLINKS+=mlock.2 munlock.2
 MLINKS+=mlockall.2 munlockall.2
diff -ur original/kse.2 japanese/kse.2
--- original/kse.2	Wed Sep  3 08:47:16 2003
+++ japanese/kse.2	Thu Sep  4 01:06:02 2003
@@ -38,12 +38,12 @@
 .Dd September 10, 2002
 .Dt KSE 2
 .Os
-.Sh NAME
+.Sh $BL>>N(B
 .Nm kse
-.Nd "kernel support for user threads"
-.Sh LIBRARY
+.Nd $B%f!<%6%9%l%C%I$N$?$a$N%+!<%M%k%5%]!<%H(B
+.Sh $B%i%$%V%i%j(B
 .Lb libc
-.Sh SYNOPSIS
+.Sh $B=q<0(B
 .In sys/types.h
 .In sys/kse.h
 .Ft int
@@ -56,573 +56,569 @@
 .Fn kse_wakeup "struct kse_mailbox *mbx"
 .Ft int
 .Fn kse_thr_interrupt "struct kse_thr_mailbox *tmbx"
-.Sh DESCRIPTION
-These system calls implement kernel support for multi-threaded processes.
-.\"
-.Ss Overview
-.\"
-Traditionally, user threading has been implemented in one of two ways:
-either all threads are managed in user space and the kernel is unaware
-of any threading (also known as
-.Dq "N to 1" ) ,
-or else separate processes sharing
-a common memory space are created for each thread (also known as
-.Dq "N to N" ) .
-These approaches have advantages and disadvantages:
-.Bl -column "- Cannot utilize multiple CPUs" "+ Can utilize multiple CPUs"
-.It Sy "User threading	Kernel threading"
-.It "+ Lightweight	- Heavyweight"
-.It "+ User controls scheduling	- Kernel controls scheduling"
-.It "- Syscalls must be wrapped	+ No syscall wrapping required"
-.It "- Cannot utilize multiple CPUs	+ Can utilize multiple CPUs"
+.Sh $B2r@b(B
+$B$3$l$i$N%7%9%F%`%3!<%k$O%^%k%A%9%l%C%I2=$5$l$?%W%m%;%9$N$?$a$N(B
+$B%+!<%M%k%5%]!<%H$r<BAu$7$F$$$^$9!#(B
+.\"
+.Ss $B35MW(B
+.\"
+$BEAE}E*$K%f!<%6%9%l%C%G%#%s%0$O!"<!$N(B 2 $B$D$NJ}K!$N(B 1 $B$D$G<BAu$5$l$F$-$^$7$?!#(B
+$BA4$F$N%9%l%C%I$O%f!<%66u4V$G4IM}$5$l!"%+!<%M%k$OA4$F$N%9%l%C%G%#%s%0$r(B
+$BG'<1$7$^$;$s(B
+.Dq ( "N $BBP(B 1"
+$B$H$7$F$bCN$i$l$F$$$^$9(B)$B!#(B
+$B$^$?$O!"8D!9$N%9%l%C%I$N$?$a$K6&DL$N%a%b%j6u4V$rJ,$19g$&(B
+$BJ,N%$7$?%W%m%;%9$r:n@.$7$^$9(B
+.Dq ( "N $BBP(B N"
+$B$H$7$F$bCN$i$l$F$$$^$9(B)$B!#(B
+$B$3$l$i$N%"%W%m!<%A$OD9=j$HC;=j$r;}$C$F$$$^$9(B:
+.Bl -column "- $B%7%9%F%`%3!<%k$N%i%C%T%s%0I,?\(B" "+ $B%7%9%F%`%3!<%k$N%i%C%T%s%0ITMW(B"
+.It Sy "$B%f!<%6%9%l%C%G%#%s%0(B	$B%+!<%M%k%9%l%C%G%#%s%0(B"
+.It "+ $B7ZNL(B	- $B=ENL(B"
+.It "+ $B%f!<%6@)8f%9%1%8%e!<%j%s%0(B	- $B%+!<%M%k@)8f%9%1%8%e!<%j%s%0(B"
+.It "- $B%7%9%F%`%3!<%k$N%i%C%T%s%0I,?\(B	+ $B%7%9%F%`%3!<%k$N%i%C%T%s%0ITMW(B"
+.It "- $B%^%k%A(B CPU $B$NM-8z3hMQIT2D(B	+ $B%^%k%A(B CPU $B$NM-8z3hMQ2DG=(B"
 .El
 .Pp
-The KSE system is a
-hybrid approach that achieves the advantages of both the user and kernel
-threading approaches.
-The underlying philosophy of the KSE system is to give kernel support
-for user threading without taking away any of the user threading library's
-ability to make scheduling decisions.
-A kernel-to-user upcall mechanism is used to pass control to the user
-threading library whenever a scheduling decision needs to be made.
-An arbitrarily number of user threads are multiplexed onto a fixed number of
-virtual CPUs supplied by the kernel.
-This can be thought of as an
-.Dq "N to M"
-threading scheme.
+KSE $B%7%9%F%`$O%f!<%6%9%l%C%G%#%s%0$*$h$S%+!<%M%k%9%l%C%G%#%s%0$NN>J}$N(B
+$BD9=j$r@.$7?k$2$k:.@.$N%"%W%m!<%A$G$9!#(B
+KSE $B%7%9%F%`$N:,K\E*$JE/3X$O!"%9%1%8%e!<%j%s%0$r7hDj$9$k$?$a$N(B
+$B%f!<%6%9%l%C%G%#%s%0%i%$%V%i%j$NG=NO$rA4$/<h$j=|$/$3$H$J$/!"(B
+$B%f!<%6%9%l%C%G%#%s%0$N$?$a$N%+!<%M%k%5%]!<%H$rM?$($k$3$H$G$9!#(B
+$B%+!<%M%k$+$i%f!<%6%9%l%C%I$X$N(B upcall $B5!9=$O!"%9%1%8%e!<%j%s%0$N7hDj$,(B
+$BI,MW$H$5$l$k$H$-$K$O$$$D$G$b!"%f!<%6%9%l%C%G%#%s%0%i%$%V%i%j$K@)8f$r(B
+$B0\$9$?$a$K;HMQ$5$l$^$9!#(B
+$BG$0U$N?t$N%f!<%6%9%l%C%I$O!"%+!<%M%k$K$h$C$F6!5k$5$l$k8GDj?t$N2>A[(B CPU $B>e$K(B
+$BJ#9g2=$5$l$^$9!#(B
+$B$3$l$O(B
+.Dq "N $BBP(B M"
+$B%9%l%C%G%#%s%05!9=$H9M$($k$3$H$,$G$-$^$9!#(B
 .Pp
-Some general implications of this approach include:
+$B$3$N%"%W%m!<%A$N$$$/$D$+$N0lHLE*$JN"$N0UL#$O0J2<$r4^$_$^$9(B:
 .Bl -bullet
 .It
-The user process can run multiple threads simultaneously on multi-processor
-machines.
-The kernel grants the process virtual CPUs to schedule as it
-wishes; these may run concurrently on real CPUs.
+$B%f!<%6%W%m%;%9$O%^%k%A%W%m%;%C%5%^%7%s>e$GJ#?t$N%9%l%C%I$r(B
+$BF1;~$K<B9T$9$k$3$H$,2DG=$G$9!#(B
+$B%+!<%M%k$O!"%W%m%;%92>A[(B CPU $B$,$=$l$,K>$`$h$&$K%9%1%8%e!<%k$9$k$3$H$r(B
+$B>5Bz$7$^$9!#$3$l$i$O!"<B:]$NJ#?t$N(B CPU $B>e$GF1;~$K<B9T$5$l$k$3$H$,$G$-$^$9!#(B
 .It
-All operations that block in the kernel become asynchronous, allowing
-the user process to schedule another thread when any thread blocks.
+$B%9%l%C%I$,%V%m%C%/$5$l$?$H$-$K%f!<%6%W%m%;%9$,B>$N%9%l%C%I$r%9%1%8%e!<%k(B
+$B$G$-$k$h$&$K!"%+!<%M%kFb$G%V%m%C%/$9$kA4$F$NA`:n$OHsF14|$K$J$j$^$9!#(B
 .It
-Multiple thread schedulers within the same process are possible, and they
-may operate independently of each other.
+$BF1$8%W%m%;%9Fb$NJ#?t$N%9%l%C%I%9%1%8%e!<%i$,2DG=$G!"$=$l$i$O8_$$$KFHN)$7$F(B
+$BA`:n$9$k$3$H$,$G$-$^$9!#(B
 .El
 .\"
-.Ss Definitions
+.Ss $BDj5A(B
 .\"
-KSE allows a user process to have multiple
-.Sy threads
-of execution in existence at the same time, some of which may be blocked
-in the kernel while others may be executing or blocked in user space.
-A
-.Sy "kernel scheduling entity"
-(KSE) is a
-.Dq "virtual CPU"
-granted to the process for the purpose of executing threads.
-A thread that is currently executing is always associated with
-exactly one KSE, whether executing in user space or in the kernel.
-The KSE is said to be
-.Sy assigned
-to the thread.
-.Pp
-The KSE becomes
-.Sy unassigned ,
-and the associated thread is suspended, when the KSE has an associated
-.Sy mailbox ,
-(see below) the thread has an associated
-.Sy thread mailbox ,
-(also see below) and any of the following occurs:
+KSE $B$O%f!<%6%W%m%;%9$,<B:]$KF1;~$NJ#?t$N(B
+.Sy $B%9%l%C%I(B
+$B$N<B9T$r2DG=$K$7$^$9!#(B
+$B$3$l$i$N4v$D$+$O!"$=$NB>$N%9%l%C%I$,<B9TCf$^$?$O%f!<%66u4V$G(B
+$B%V%C%m%/$5$l$F$$$k4V$K!"%+!<%M%k$NCf$G%V%m%C%/$5$l$k$3$H$,2DG=$G$9!#(B
+.Sy $B%+!<%M%k%9%1%8%e!<%j%s%0$N<BBN(B
+(kernel scheduling entity, KSE) $B$O%9%l%C%I$N<B9T$N$?$a$K%W%m%;%9$K>5Bz$5$l$?(B
+.Dq "$B2>A[(B CPU"
+$B$G$9!#(B
+$B8=:_<B9T$5$l$F$$$k%9%l%C%I$O>o$K!"87L)$K(B 1 $B$D$N%f!<%66u4V$^$?$O(B
+$B%+!<%M%k$NCf$GF0:n$7$F$$$k$I$A$i$+$N(B KSE $B$K4XO"IU$1$i$l$F$$$^$9!#(B
+$B$=$N(B KSE $B$O$=$N%9%l%C%I$K(B
+.Sy $B3d$jEv$F$i$l$F$$$k(B
+$B$H8@$o$l$^$9!#(B
+.Pp
+$B$=$N(B KSE $B$,4XO"IU$1$i$l$?(B
+.Sy $B%a!<%k%\%C%/%9(B
+($B2<5-;2>H(B) $B$r;}$C$F$$$F!"$=$N%9%l%C%I$,4XO"IU$1$i$l$?(B
+.Sy $B%9%l%C%I%a!<%k%\%C%/%9(B
+($B$3$l$b2<5-;2>H(B) $B$r;}$C$F$$$F!"$5$i$K0J2<$N$I$l$+$,H/@8$7$?$H$-$K!"$=$N(B KSE $B$,(B
+.Sy $B3d$jEv$F$i$l$F$$$J$$(B
+$B>uBV$K$J$j!"4XO"IU$1$i$l$?%9%l%C%I$ODd;_$5$l$^$9(B:
 .Bl -bullet
 .It
-The thread invokes a system call that blocks.
+$B$=$N%9%l%C%I$,%V%m%C%/$rH<$&%7%9%F%`%3!<%k$r<B9T$9$k!#(B
 .It
-The thread makes any other demand of the kernel that cannot be immediately
-satisfied, e.g., touches a page of memory that needs to be fetched from disk,
-causing a page fault.
+$B%9%l%C%I$,!"Nc$($P%G%#%9%/$+$i%G!<%?$rFI$_=P$9$?$a$KI,MW$J%a%b%j%Z!<%8$K(B
+$B%"%/%;%9$9$k$3$H$G%Z!<%8%U%)%k%HH/@8$5$;$k$h$&$J!"(B
+$B%+!<%M%k$,$9$0$K$OK~$?$9$3$H$,2DG=$G$O$J$$B>$NA4$F$NMW5a$r9T$J$&!#(B
 .It
-Another thread that was previously blocked in the kernel completes its
-work in the kernel (or is
-.Sy interrupted )
-and becomes ready to return to user space, and the current thread is returning
-to user space.
+$B%+!<%M%kFb$G@h$K%V%m%C%/$5$l$F$$$?B>$N%9%l%C%I$,!"%+!<%M%kFb$N$=$N:n6H$r(B
+$B40N;$7(B ($B$^$?$O(B
+.Sy $B3d$j9~$^$l(B )
+$B!"%f!<%66u4V$XLa$k=`Hw$,$G$-!"$5$i$K8=:_$N%9%l%C%I$,%f!<%66u4V$KLa$C$F$$$k!#(B
 .It
-A signal is delivered to the process, and this KSE is chosen to deliver it.
+$B%7%0%J%k$,%W%m%;%9$KG[?.$5$l!"$3$N(B KSE $B$,$=$N%7%0%J%k$rG[?.$9$k$?$a$K(B
+$BA*Br$5$l$k!#(B
 .El
 .Pp
-In other words, as soon as there is a scheduling decision to be made,
-the KSE becomes unassigned, because the kernel does not presume to know
-how the process' other runnable threads should be scheduled.
-Unassigned KSEs always return to user space as soon as possible via
-the
+$B8@$$49$($k$H!"%9%1%8%e!<%j%s%0$N7hDj$,9T$o$l$J$1$l$P$J$i$J$/$J$k$H$9$0$K!"(B
+$B$=$N(B KSE $B$O3d$jEv$F$i$l$F$$$J$$>uBV$K$J$j$^$9!#(B
+$B$J$<$J$i$P!"%+!<%M%k$O$=$N%W%m%;%9$NB>$N$I$N<B9T2DG=$J%9%l%C%I$r(B
+$B%9%1%8%e!<%k$9$k$Y$-$+$r?dDj$7$J$$$+$i$G$9!#(B
+$B3d$jEv$F$i$l$F$$$J$$(B KSE $B$O>o$K2DG=$J8B$jAa$/!"(B
+$B%f!<%6%W%m%;%9$,<!$KMxMQ$9$k$Y$-(B KSE $B$r$I$N$h$&$K7hDj$9$k$+$r2DG=$K$9$k(B
 .Sy upcall
-mechanism (described below), allowing the user process to decide how
-that KSE should be utilized next.
-KSEs always complete as much work as possible in the kernel before
-becoming unassigned.
-.Pp
-A
-.Sy "KSE group"
-is a collection of KSEs that are scheduled uniformly and which share
-access to the same pool of threads, which are associated with the KSE group.
-A KSE group is the smallest entity to which a kernel scheduling
-priority may be assigned.
-For the purposes of process scheduling and accounting, each
-KSE group
-counts similarly to a traditional unthreaded process.
-Individual KSEs within a KSE group are effectively indistinguishable,
-and any KSE in a KSE group may be assigned by the kernel to any runnable
-(in the kernel) thread associated with that KSE group.
-In practice, the kernel attempts to preserve the affinity between threads
-and actual CPUs to optimize cache behavior, but this is invisible to the
-user process.
-(Affinity is not yet implemented.)
-.Pp
-Each KSE has a unique
-.Sy "KSE mailbox"
-supplied by the user process.
-A mailbox consists of a control structure containing a pointer to an
-.Sy "upcall function"
-and a user stack.
-The KSE invokes this function whenever it becomes unassigned.
-The kernel updates this structure with information about threads that have
-become runnable and signals that have been delivered before each upcall.
-Upcalls may be temporarily blocked by the user thread scheduling code
-during critical sections.
-.Pp
-Each user thread has a unique
-.Sy "thread mailbox"
-as well.
-Threads are referred to using pointers to these mailboxes when communicating
-between the kernel and the user thread scheduler.
-Each KSE's mailbox contains a pointer to the mailbox of the user thread
-that the KSE is currently executing.
-This pointer is saved when the thread blocks in the kernel.
-.Pp
-Whenever a thread blocked in the kernel is ready to return to user space,
-it is added to the KSE group's list of
-.Sy completed
-threads.
-This list is presented to the user code at the next upcall as a linked list
-of thread mailboxes.
-.Pp
-There is a kernel-imposed limit on the number of threads in a KSE group
-that may be simultaneously blocked in the kernel (this number is not
-currently visible to the user).
-When this limit is reached, upcalls are blocked and no work is performed
-for the KSE group until one of the threads completes (or a signal is
-received).
-.\"
-.Ss Managing KSEs
-.\"
-To become multi-threaded, a process must first invoke
-.Fn kse_create .
-The
+$B5!9=(B ($B2<5-$K5-=R$5$l$$$^$9(B) $B$r2p$7$F%f!<%66u4V$KLa$j$^$9!#(B
+KSE $B$O>o$K!"3d$jEv$F$,2r=|$5$l$kA0$K!"%+!<%M%kFb$G2DG=$J8B$jB?$/$N:n6H$r(B
+$B40N;$5$;$^$9!#(B
+.Pp
+.Sy "KSE $B%0%k!<%W(B"
+$B$O6QEy$K%9%1%8%e!<%k$5$l!"$=$N(B KSE $B%0%k!<%W$K4XO"IU$1$i$l$?F10l$N%9%l%C%I$N(B
+$B%W!<%k$X$N%"%/%;%9$r6&M-$9$k(B KSE $B$N=89g$G$9!#(B
+KSE $B%0%k!<%W$O%+!<%M%k%9%1%8%e!<%j%s%0$NM%@hEY$,3d$jEv$F$i$l$k$3$H$,$G$-$k(B
+$B:G>.$N<BBN$G$9!#(B
+$B%W%m%;%9$N%9%1%8%e!<%j%s%0$H%"%+%&%s%F%#%s%0$N$?$a!"$=$l$>$l$N(B KSE $B%0%k!<%W$O(B
+$BEAE}E*$J%9%l%C%I2=$5$l$F$$$J$$%W%m%;%9$HF1MM$K%+%&%s%H$7$^$9!#(B
+KSE $B%0%k!<%W$NCf$N8D!9$N(B KSE $B$O<B:]>e!"8+J,$1$,$D$-$^$;$s!#(B
+$B$^$?!"(BKSE $B%0%k!<%W$NCf$N$"$i$f$k(B KSE $B$O!"$=$N(B KSE $B%0%k!<%W$K(B
+$B4XO"IU$1$i$l$?(B ($B%+!<%M%kFb$N(B) $B$"$i$f$k<B9T2DG=$J%9%l%C%I$K!"(B
+$B%+!<%M%k$K$h$C$F3d$jEv$F$i$l$k$3$H$,$G$-$^$9!#(B
+$B<B:]LdBj$H$7$F!"%+!<%M%k$O%-%c%C%7%e$NF0:n$r:GE,2=$9$k$?$a$K!"%9%l%C%I$H(B
+$B<B:]$N(B CPU $B$H$NL)@\$J4X78$rJ]B8$7$h$&$H;n$_$^$9$,!"(B
+$B$3$l$O%f!<%6%W%m%;%9$K$OIT2D;k$G$9!#(B
+($BL)@\$J4X78$O$^$@<BAu$5$l$F$$$^$;$s!#(B)
+.Pp
+$B$=$l$>$l$N(B KSE $B$O%f!<%6%W%m%;%9$K$h$C$F6!5k$5$l$?M#0l$N(B
+.Sy "KSE $B%a!<%k%\%C%/%9(B"
+$B$r;}$C$F$$$^$9!#(B
+$B%a!<%k%\%C%/%9$O(B
+.Sy "upcall $B4X?t(B"
+$B$X$N%]%$%s%?$r4^$`@)8f9=B$BN$H%f!<%6%9%?%C%/$G9=@.$5$l$F$$$^$9!#(B
+KSE $B$O3d$jEv$F$r2r=|$5$l$k$HI,$:$3$N4X?t$r<B9T$7$^$9!#(B
+$B%+!<%M%k$O$3$N9=B$BN$r!"<B9T2DG=$K$J$C$F$$$k%9%l%C%I!"$*$h$S$=$l$>$l$N(B
+upcall $B$NA0$KG[?.$5$l$?%7%0%J%k$K$D$$$F$N>pJs$r99?7$7$^$9!#(B
+upcall $B$O%/%j%F%#%+%k%;%/%7%g%s$N4V$O!"%f!<%6%9%l%C%I$N(B
+$B%9%1%8%e!<%j%s%0%3!<%I$K$h$C$F0l;~E*$K%V%m%C%/$5$l$k$3$H$,$"$j$^$9!#(B
+.Pp
+$BF1MM$K$=$l$>$l$N%f!<%6%9%l%C%I$OM#0l$N(B
+.Sy "$B%9%l%C%I%a!<%k%\%C%/%9(B"
+$B$r;}$C$F$$$^$9!#(B
+$B%+!<%M%k$H%f!<%6%9%l%C%I%9%1%8%e!<%i$,DL?.$9$k$H$-$K!"(B
+$B%9%l%C%I$O$3$l$i$N%a!<%k%\%C%/%9$X$N%]%$%s%?$r;HMQ$7$F;2>H$5$l$^$9!#(B
+$B$=$l$>$l$N(B KSE $B$N%a!<%k%\%C%/%9$O!"$=$N(B KSE $B$,8=:_<B9T$7$F$$$k(B
+$B%f!<%6%9%l%C%I$N%a!<%k%\%C%/%9$X$N%]%$%s%?$r4^$s$G$$$^$9!#(B
+$B$3$N%]%$%s%?$O%+!<%M%kFb$G%9%l%C%I$,%V%m%C%/$9$k$H$-$K!"J]B8$5$l$^$9!#(B
+.Pp
+$B%+!<%M%kFb$G%V%m%C%/$5$l$F$$$?%9%l%C%I$,%f!<%66u4V$KLa$k=`Hw$,$G$-$?$H$-$K$O(B
+$BI,$:!"$=$N%9%l%C%I$O(B KSE $B%0%k!<%W$N(B
+.Sy $B40N;$7$?(B
+$B%9%l%C%I$N%j%9%H$KDI2C$5$l$^$9!#(B
+$B$3$N%j%9%H$O%9%l%C%I%a!<%k%\%C%/%9$N%j%s%/$5$l$?%j%9%H$H$7$F!"(B
+$B<!$N(B upcall $B$G%f!<%6%3!<%I$K8x3+$5$l$^$9!#(B
+.Pp
+$B%+!<%M%k$NCf$GF1;~$K%V%m%C%/$5$l$k$3$H$,$G$-$k(B KSE $B%0%k!<%W$NCf$N(B
+$B%9%l%C%I?t$K$O!"%+!<%M%k$K5/0x$9$k@)8B$,$"$j$^$9(B ($B8=:_!"$3$N?t$O%f!<%6$K$O(B
+$BIT2D;k$G$9(B)$B!#(B
+$B$3$N@)8B$KC#$7$?$H$-$K$O!"%9%l%C%I$N(B 1 $B$D$,40N;$9$k$^$G$N4V(B ($B$^$?$O(B
+$B%7%0%J%k$,G[?.$5$l$k$^$G$N4V(B)$B!"(Bupcall $B$O%V%m%C%/$5$l!"(B
+$B$=$N(B KSE $B%0%k!<%W$N$?$a$N:n6H$O2?$b<B9T$5$l$^$;$s!#(B
+.\"
+.Ss KSE $B$N4IM}(B
+.\"
+$B%^%k%A%9%l%C%I2=$9$k$?$a$K$O!"%W%m%;%9$O=i$a$K(B
 .Fn kse_create
-system call
-creates a new KSE (except for the very first invocation; see below).
-The KSE will be associated with the mailbox pointed to by
-.Fa mbx .
-If
-.Fa newgroup
-is non-zero, a new KSE group is also created containing the KSE.
-Otherwise, the new KSE is added to the current KSE group.
-Newly created KSEs are initially unassigned; therefore,
-they will upcall immediately.
-.Pp
-Each process initially has a single KSE in a single KSE group executing
-a single user thread.
-Since the KSE does not have an associated mailbox, it must remain assigned
-to the thread and does not perform any upcalls.
-The result is the traditional, unthreaded mode of operation.
-Therefore, as a special case, the first call to
+$B$r<B9T$7$J$1$l$P$J$j$^$;$s!#(B
 .Fn kse_create
-by this initial thread with
+$B%7%9%F%`%3!<%k$O?7$7$$(B KSE $B$r(B
+$B:n@.$7$^$9(B ($BK\Ev$K:G=i$N<B9T$r=|$/!"2<5-$r;2>H$7$F$/$@$5$$(B)$B!#(B
+$B$=$N(B KSE $B$O(B
+.Fa mbx
+$B$K$h$C$F;X$5$l$k%a!<%k%\%C%/%9$H4XO"IU$1$i$l$^$9!#(B
 .Fa newgroup
-equal to zero does not create a new KSE; instead, it simply associates the
-current KSE with the supplied KSE mailbox, and no immediate upcall results.
-However, an upcall will be triggered the next time the thread blocks and
-the required conditions are met.
+$B$,(B 0 $B$G$O$J$$>l9g$K$O!"$=$N(B KSE $B$r4^$`?7$7$$(B KSE $B%0%k!<%W$b:n@.$5$l$^$9!#(B
+$B$=$&$G$J$$>l9g$K$O!"$=$N?7$7$$(B KSE $B$O8=:_$N(B KSE $B%0%k!<%W$KDI2C$5$l$^$9!#(B
+$B?7$7$/:n@.$5$l$k(B KSE $B$O:G=i$O3d$jEv$F$i$l$F$$$^$;$s!"$=$N$?$a!"(B
+$B$=$l$i$N(B KSE $B$OD>$A$K(B upcall $B$7$^$9!#(B
+.Pp
+$B$=$l$>$l$N%W%m%;%9$O=i$a$O(B 1 $B$D$N%f!<%6%9%l%C%I$r(B
+$B<B9T$9$k(B 1 $B$D$N(B KSE $B%0%k!<%W$NCf$N(B 1 $B$D$N(B KSE $B$r;}$C$F$$$^$9!#(B
+$B$=$N(B KSE $B$O4XO"IU$1$i$l$?%a!<%k%\%C%/%9$r;}$C$F$$$J$$$?$a!"$=$N%9%l%C%I$K(B
+$B3d$jEv$F$i$l$?$^$^$G$J$1$l$P$J$i$:!"(Bupcall $B$rA4$/<B9T$7$^$;$s!#(B
+$B$3$N7k2L$OEAE}E*$G!"%9%l%C%I2=$5$l$F$$$J$$MM<0$NA`:n$G$9!#(B
+$B$=$N$?$a!"FCJL$J>l9g$H$7$F!"(B
+.Fa newgroup
+$B$r(B 0 $B$K$7$?$3$N:G=i$N%9%l%C%I$K$h$k(B
+.Fn kse_create
+$B$N:G=i$N8F$S=P$7$O!"?7$7$$(B KSE $B$r:n@.$7$^$;$s!#(B
+$BBe$o$j$K!"C1$K8=:_$N(B KSE $B$rM?$($i$l$?(B KSE $B%a!<%k%\%C%/%9$K4XO"IU$1!"(B
+$BD>$A$K(B upcall $B$7$J$$7k2L$H$J$j$^$9!#(B
+$B$7$+$7$J$,$i!"<!$K$=$N%9%l%C%I$,%V%m%C%/$7!"MW5a$5$l$?>r7o$K$J$C$?$H$-$K!"(B
+upcall $B$,%H%j%,$5$l$^$9!#(B
 .Pp
-The kernel does not allow more KSEs to exist in a KSE group than the
-number of physical CPUs in the system (this number is available as the
+$B%+!<%M%k$O(B 1 $B$D$N(B KSE $B%0%k!<%W$NCf$K%7%9%F%`$NJ*M}E*$J(B CPU $B$N?t(B ($B$3$N?t$O(B
 .Xr sysctl 3
-variable
-.Va hw.ncpu ) .
-Having more KSEs than CPUs would not add any value to the user process,
-as the additional KSEs would just compete with each other for access to
-the real CPUs.
-Since the extra KSEs would always be side-lined, the result
-to the application would be exactly the same as having fewer KSEs.
-There may however be arbitrarily many user threads, and it is up to the
-user thread scheduler to handle mapping the application's user threads
-onto the available KSEs.
+$BJQ?t$N(B
+.Va hw.ncpu
+$B$H$7$FMxMQ2DG=$G$9(B) $B$h$jB?$$(B KSE $B$NB8:_$r5v2D$7$^$;$s!#(B
+CPU $B$h$jB?$$(B KSE $B$r;}$D$3$H$O!"$=$NDI2C$N(B KSE $B$,C1$K(B
+$B$=$NB>$N(B KSE $B$H<B(B CPU $B$X$N%"%/%;%9$r6%9g$9$k$@$1$G$"$k$?$a!"(B
+$B%f!<%6%W%m%;%9$K$H$C$FA4$/2ACM$rA}$d$5$J$$$G$7$g$&!#(B
+$B$=$N$?$a!"M>J,$J(B KSE $B$O>o$KOF$KDI$$$d$i$l!"$=$N7k2L%"%W%j%1!<%7%g%s$O(B
+$B$^$5$K$h$j>/$J$$(B KSE $B$r;}$C$F$$$k$3$H$HF1$8$K$J$k$G$7$g$&!#(B
+$B$I$s$J$KB?$/$NG$0U$N%f!<%6%9%l%C%I$,B8:_$9$k$3$H$K$J$C$F$b!"(B
+$BMxMQ2DG=$J(B KSE $B$X$N%"%W%j%1!<%7%g%s$N%f!<%6%9%l%C%I$N3d$jEv$F$r<h$j07$&(B
+$B$?$a$N%f!<%6%9%l%C%I%9%1%8%e!<%i$KEO$j$^$9!#(B
 .Pp
-The
 .Fn kse_exit
-system call
-causes the KSE assigned to the currently running thread to be destroyed.
-If this KSE is the last one in the KSE group, there must be no remaining
-threads associated with the KSE group blocked in the kernel.
-This system call does not return unless there is an error.
-.Pp
-As a special case, if the last remaining KSE in the last remaining KSE group
-invokes this system call, then the KSE is not destroyed;
-instead, the KSE just looses the association with its mailbox and
+$B%7%9%F%`%3!<%k$O!"8=:_<B9T$7$F$$$k%9%l%C%I$K3d$jEv$F$i$l$F$$$k(B KSE $B$r(B
+$BGK2u$5$;$^$9!#(B
+$B$3$N(B KSE $B$,$3$N(B KSE $B%0%k!<%W$NCf$N:G8e$N(B 1 $B$D$N>l9g$K$O!"$=$N(B KSE $B%0%k!<%W$K(B
+$B4XO"IU$1$i$l$F$$$k%9%l%C%I$,%+!<%M%kFb$G%V%m%C%/$5$l$?$^$^;D$C$F$O$J$j$^$;$s!#(B
+$B$3$N%7%9%F%`%3!<%k$O%(%i!<$,L5$$>l9g$K$O!"La$j$^$;$s!#(B
+.Pp
+$BFCJL$J>l9g$H$7$F!":G8e$K;D$C$F$$$k(B KSE $B%0%k!<%W$NCf$N:G8e$K;D$C$F$$$k(B KSE $B$,(B
+$B$3$N%7%9%F%`%3!<%k$r<B9T$9$k>l9g$K$O!"$=$N(B KSE $B$OGK2u$5$l$^$;$s!#(B
+$BBe$o$j$K!"$=$N(B KSE $B$O$=$N%a!<%k%\%C%/%9$H$N4XO"IU$1$r<:$&$@$1$G!"(B
 .Fn kse_exit
-returns normally.
-This returns the process to its original, unthreaded state.
-(This is not yet implemented.)
+$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
-The
 .Fn kse_release
-system call
-is used to
-.Dq park
-the KSE assigned to the currently running thread when it is not needed,
-e.g., when there are more available KSEs than runnable user threads.
-The thread converts to an upcall but does not get scheduled until
-there is a new reason to do so, e.g., a previously
-blocked thread becomes runnable, or the timeout expires.
-If successful,
+$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
+$B4XO"IU$1$i$l$F$$$k(B KSE $B$r(B
+.Dq $B0l;~J]4I(B
+$B$9$k$?$a$K;HMQ$5$l$^$9!#(B
+$BNc$($P!"<B9T2DG=$J%f!<%6%9%l%C%I$h$j$bMxMQ2DG=$J(B KSE $B$NJ}$,B?$$$H$-$G$9!#(B
+$B$=$N%9%l%C%I$O(B upcall $B$KJQ2=$7$^$9$,!"$=$N$h$&$K$9$k$?$a$N?7$7$$M}M3$,(B
+$BH/@8$9$k$^$G$N4V%9%1%8%e!<%k$5$l$k$3$H$O$"$j$^$;$s!#(B
+$BNc$($P!"0JA0$K%V%m%C%/$5$l$F$$$?%9%l%C%I$,<B9T2DG=$K$J$k!"$^$?$O(B
+$B%?%$%`%"%&%H$,H/@8$9$k$J$I$G$9!#(B
+$B@.8y$N>l9g$K$O!"(B
 .Fn kse_release
-does not return to the caller.
+$B$O8F$S=P$7B&$KLa$j$^$;$s!#(B
 .Pp
-The
 .Fn kse_wakeup
-system call
-is the opposite of
-.Fn kse_release .
-It causes the (parked) KSE associated with the mailbox pointed to by
+$B%7%9%F%`%3!<%k$O(B
+.Fn kse_release
+$B$NH?BP$G$9!#(B
 .Fa mbx
-to be woken up, causing it to upcall.
-If the KSE has already woken up for another reason, this system call has no
-effect.
-The
+$B$K$h$C$F;X$5$l$F$$$k%a!<%k%\%C%/%9$K4XO"IU$1$i$l$?(B ($B0l;~J]4I$5$l$?(B) KSE $B$r(B
+upcall $B$K$9$k$3$H$G5/$3$7$^$9!#(B
+$B$=$N(B KSE $B$,$9$G$KB>$NM}M3$G5/$3$5$l$F$$$?>l9g$K$O!"$3$N%7%9%F%`%3!<%k$O(B
+$B2?$b5/$3$j$^$;$s!#(B
 .Fa mbx
-argument
-may be
+$B0z?t$O(B
+.Dq "$B8=:_$N(B KSE $B%0%k!<%W$NCf$NA4$F$N(B KSE"
+$B$r;XDj$9$k$?$a$K(B
 .Dv NULL
-to specify
-.Dq "any KSE in the current KSE group" .
+$B$K$9$k$3$H$,$G$-$^$9!#(B
 .Pp
-The
 .Fn kse_thr_interrupt
-system call
-is used to interrupt a currently blocked thread.
-The thread must either be blocked in the kernel or assigned to a KSE
-(i.e., executing).
-The thread is then marked as interrupted.
-As soon as the thread invokes an interruptible system call (or immediately
-for threads already blocked in one), the thread will be made runnable again,
-even though the kernel operation may not have completed.
-The effect on the interrupted system call is the same as if it had been
-interrupted by a signal; typically this means an error is returned with
+$B%7%9%F%`%3!<%k$O!"8=:_%V%m%C%/$5$l$F$$$k%9%l%C%I$K(B
+$B3d$j9~$`$?$a$K;HMQ$5$l$^$9!#(B
+$B$=$N%9%l%C%I$O%+!<%M%k$NCf$G%V%m%C%/$5$l$F$$$k$+!"(B
+KSE $B$K3d$jEv$F$i$l$F(B ($BNc$($P!"<B9TCf(B) $B$$$J$1$l$P$J$j$^$;$s!#(B
+$B$=$N%9%l%C%I$O$=$N8e!"3d$j9~$^$l$?$H$$$&0u$rIU$1$i$l$^$9!#(B
+$B%9%l%C%I$,3d$j9~$_$rH/@8$5$;$k%7%9%F%`%3!<%k$r<B9T$9$k$H$G$-$k$@$1(B
+$BAa$/(B ($B$^$?$O!"%9%l%C%I$,%+!<%M%k$NCf$G$9$G$K%V%m%C%/$5$l$F$k$HD>$A$K(B)$B!"(B
+$B%+!<%M%kA`:n$,40N;$7$F$$$J$$$+$b$7$l$J$$$N$K$b$+$+$o$i$:!"(B
+$B$=$N%9%l%C%I$O:FEY<B9T2DG=$K$5$l$^$9!#(B
+$B3d$j9~$^$l$?%7%9%F%`%3!<%k>e$N$3$N8z2L$O!"$9$G$K%7%0%J%k$K$h$C$F(B
+$B3d$j9~$^$l$F$$$?>l9g$HF1MM$G$9!#(B
+$BDL>o!"$3$l$O(B
 .Va errno
-set to
-.Er EINTR .
-.\"
-.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.)
+$B$K(B
+.Er EINTR
+$B$,@_Dj$5$l$F%(%i!<$,JV$5$l$?$3$H$r0UL#$7$^$9!#(B
+.\"
+.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
-If there are multiple KSE groups in the process, which KSE group is
-chosen to deliver the signal is indeterminate.
+$B$=$N%W%m%;%9$NCf$KJ#?t$N(B KSE $B%0%k!<%W$,B8:_$9$k>l9g$K$O!"$=$N%7%0%J%k$r(B
+$BG[?.$9$k$?$a$K$I$N(B KSE $B%0%k!<%W$,A*$P$l$k$N$+$O!"L@3N$G$O$"$j$^$;$s!#(B
 .\"
-.Ss KSE Mailboxes
+.Ss KSE $B%a!<%k%\%C%/%9(B
 .\"
-Each KSE has a unique mailbox for user-kernel communication:
+$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 function type */
+/* upcall $B4X?t7?(B */
 typedef void	kse_func_t(struct kse_mailbox *);

-/* KSE mailbox */
+/* KSE $B%a!<%k%\%C%/%9(B */
 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 */
+	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
 .Pp
 .Va km_version
-describes the version of this structure and must be equal to
-.Dv KSE_VER_0 .
+$B$O$3$N9=B$BN$N%P!<%8%g%s$rI=$7!"(B
+.Dv KSE_VER_0
+$B$G$J$1$l$P$J$j$^$;$s!#(B
 .Va km_udata
-is an opaque pointer ignored by the kernel.
+$B$O%+!<%M%k$K$h$C$FL5;k$5$l$kITF)L@$J%]%$%s%?$G$9!#(B
 .Pp
 .Va km_func
-points to the KSE's upcall function;
-it will be invoked using
-.Va km_stack ,
-which must remain valid for the lifetime of the KSE.
+$B$O$=$N(B KSE $B$N(B upcall $B4X?t$r;X$7$^$9!#(B
+$B$3$l$O!"$=$N(B KSE $B$,B8:_$7$F$$$k4V$OM-8z$G$"$jB3$1$J$1$l$P$J$i$J$$(B
+.Va km_stack
+$B$r;HMQ$7$F<B9T$5$l$^$9!#(B
 .Pp
 .Va km_curthread
-always points to the thread that is currently assigned to this KSE if any,
-or
+$B$O>o$K!"$b$7$"$l$P8=:_$3$N(B KSE $B$K3d$jEv$F$i$l$F$$$k%9%l%C%I$r!"$^$?$O(B
+$B$=$&$G$J$1$l$P(B
 .Dv NULL
-otherwise.
-This field is modified by both the kernel and the user process as follows.
+$B$r;X$7$F$$$^$9!#(B
+$B$3$N%U%#!<%k%I$O!"%+!<%M%k$H%f!<%6%W%m%;%9$NN>J}$K$h$C$F0J2<$N$h$&$K(B
+$B99?7$5$l$^$9!#(B
 .Pp
-When
 .Va km_curthread
-is not
-.Dv NULL ,
-it is assumed to be pointing at the mailbox for the currently executing
-thread, and the KSE may be unassigned, e.g., if the thread blocks in the
-kernel.
-The kernel will then save the contents of
+$B$,(B
+.Dv NULL
+$B$G$O$J$$$H$-$K$O!"(B
+$B8=:_<B9TCf$N%9%l%C%I$N%a!<%k%\%C%/%9$r;X$=$&$H;n$_!"$=$N(B KSE $B$O(B
+$B3d$jEv$F2r=|$5$l$k$3$H$,$G$-$^$9!#(B
+$BNc$($P!"%9%l%C%I$,%+!<%M%kFb$G%V%m%C%/$9$k>l9g$G$9!#(B
+$B$=$l$+$i!"%+!<%M%k$O%V%m%C%/$5$l$?%9%l%C%I$N(B
 .Va km_curthread
-with the blocked thread, set
+$B$NFbMF$rJ]B8$7$F(B
 .Va km_curthread
-to
-.Dv NULL ,
-and upcall to invoke
-.Fn km_func .
+$B$r(B
+.Dv NULL
+$B$K@_Dj$7!"(B
+.Fn km_func
+$B$r<B9T$9$k$?$a$K(B upcall $B$7$^$9!#(B
 .Pp
-When
 .Va km_curthread
-is
-.Dv NULL ,
-the kernel will never perform any upcalls with this KSE; in other words,
-the KSE remains assigned to the thread even if it blocks.
-.Va km_curthread
-must be
+$B$,(B
 .Dv NULL
-while the KSE is executing critical user thread scheduler
-code that would be disrupted by an intervening upcall;
-in particular, while
+$B$N$H$-$K$O!"%+!<%M%k$O$3$N(B KSE $B$N(B upcall $B$r7h$7$F<B9T$7$^$;$s!#(B
+$B8@$$49$($k$H!"(BKSE $B$O$?$H$(%V%m%C%/$7$?$H$7$F$b!"$=$N%9%l%C%I$K(B
+$B3d$jEv$F$i$l$?$^$^$H$J$j$^$9!#(B
+$B$=$N(B KSE $B$,4V$KF~$j9~$`(B upcall $B$K$h$C$F:.Mp$9$k$G$"$m$&%/%j%F%#%+%k$J(B
+$B%f!<%6%9%l%C%I%9%1%8%e!<%i$N%3!<%I$r<B9T$7$F$$$k4V!"FC$K(B
 .Fn km_func
-itself is executing.
+$B$=$l<+?H$r<B9T$7$F$$$k4V$O!"(B
+.Va km_curthread
+$B$O(B
+.Dv NULL
+$B$G$J$1$l$P$J$j$^$;$s!#(B
 .Pp
-Before invoking
+$BA4$F$N(B upcall $B$NCf$G(B
 .Fn km_func
-in any upcall, the kernel always sets
+$B$r<B9T$9$kA0$K!"%+!<%M%k$O>o$K(B
 .Va km_curthread
-to
-.Dv NULL .
-Once the user thread scheduler has chosen a new thread to run,
-it should point
+$B$r(B
+.Dv NULL
+$B$K@_Dj$7$^$9!#(B
+$B0lEY!"%f!<%6%9%l%C%I%9%1%8%e!<%i$,<B9T$9$k$Y$-?7$7$$%9%l%C%I$rA*$s$@$i!"(B
+$B$=$N%9%l%C%I$N%a!<%k%\%C%/%9$N(B
 .Va km_curthread
-at the thread's mailbox, re-enabling upcalls, and then resume the thread.
-.Em Note :
-modification of
+$B$r;X$9$h$&$K$7!"(Bupcall $B$r:FEYM-8z2=$7!"$=$l$+$i$=$N%9%l%C%I$r:F3+$9$k$Y$-$G$9!#(B
+.Em $BCm0U(B :
+$B%f!<%6%9%l%C%I%9%1%8%e!<%i$K$h$k(B
 .Va km_curthread
-by the user thread scheduler must be atomic
-with the loading of the context of the new thread, to avoid
-the situation where the thread context area
-may be modified by a blocking async operation, while there
-is still valid information to be read out of it.
+$B$NJQ99$O!"0MA3$H$7$FM-8z$J>pJs$,$=$3$+$iFI$_=P$5$l$k$Y$-;~$K(B
+$B%V%m%C%-%s%0HsF14|A`:n$K$h$C$F!"%9%l%C%I$N%3%s%F%-%9%HNN0h$,(B
+$BJQ99$5$l$k$+$b$7$l$J$$>u67$rHr$1$k$?$a$K!"(B
+$B?7$7$$%9%l%C%I$N%3%s%F%-%9%H$N%m!<%I$K$D$$$FIT2DJ,$G$J$1$l$P$J$j$^$;$s!#(B
 .Pp
 .Va km_completed
-points to a linked list of user threads that have completed their work
-in the kernel since the last upcall.
-The user thread scheduler should put these threads back into its
-own runnable queue.
-Each thread in a KSE group that completes a kernel operation
-(synchronous or asynchronous) that results in an upcall is guaranteed to be
-linked into exactly one KSE's
+$B$O:G6a$N(B upcall $B0J9_$K%+!<%M%kFb$G$N=hM}$r=*$($?%f!<%6%9%l%C%I$N(B
+$B%j%s%/$5$l$?%j%9%H$r;X$7$F$$$^$9!#(B
+$B$=$N%f!<%6%9%l%C%I%9%1%8%e!<%i$O!"$3$l$i$N%9%l%C%I$r(B
+$B%9%1%8%e!<%i$,=jM-$9$k<B9T2DG=%-%e!<$KLa$9$Y$-$G$9!#(B
+upcall $B$K5"Ce$9$k(B ($BF14|$^$?$OHsF14|$K(B) $B%+!<%M%kA`:n$r(B
+$B40N;$7$?(B KSE $B%0%k!<%WFb$N3F!9$N%9%l%C%I$O!"3N<B$K(B 1 $B$D$N(B KSE $B$N(B
 .Va km_completed
-list; which KSE in the group, however, is indeterminate.
-Furthermore, the completion will be reported in only one upcall.
+$B$K%j%s%/$5$l$k$3$H$,J]>Z$5$l$^$9!#(B
+$B$7$+$7$J$,$i!"$=$N%0%k!<%W$NCf$N$I$N(B KSE $B$+$OITDj$G$9!#(B
+$B$=$N>e!"$=$N40N;$O$?$C$?(B 1 $B$D$N(B upcall $B$G$7$+Js9p$5$l$^$;$s!#(B
 .Pp
 .Va km_sigscaught
-contains the list of signals caught by this process since the previous
-upcall to any KSE in the process.
-As long as there exists one or more KSEs with an associated mailbox in
-the user process, signals are delivered this way rather than the
-traditional way.
-(This has not been implemented and may change.)
+$B$O$=$NA0$N%W%m%;%9Fb$NA4$F$N(B KSE $B$X$N(B upcall $B0J9_$K!"(B
+$B$3$N%W%m%;%9$K$h$C$FJa$^$($i$l$?%7%0%J%k$N%j%9%H$,4^$^$l$F$$$^$9!#(B
+$B$=$N%f!<%6%W%m%;%9$NCf$K(B 1 $B$D0J>e$N%a!<%k%\%C%/%9$K(B
+$B4XO"IU$1$i$l$?(B KSE $B$,B8:_$9$k8B$j$O!"(B
+$B%7%0%J%k$OEAE}E*$JJ}K!$G$O$J$/$3$NJ}K!$GG[?.$5$l$^$9!#(B
+($B$3$l$O$^$@<BAu$5$l$F$*$i$:!"JQ99$5$l$k$+$b$7$l$^$;$s!#(B)
 .Pp
 .Va km_timeofday
-is set by the kernel to the current system time before performing
-each upcall.
+$B$O!"$=$l$>$l$N(B upcall $B$NA0$K%+!<%M%k$K$h$C$F8=:_$N%7%9%F%`;~9o$K@_Dj$5$l$^$9!#(B
 .Pp
 .Va km_flags
-may contain any of the following bits OR'ed together:
+$B$O0J2<$NA4$F$N%S%C%HKh$N(B OR $B$r4^$`$3$H$,$G$-$^$9(B:
 .Bl -tag -width indent
 .It \&
-(No flags are defined yet.)
+($B$^$@%U%i%0$OA4$/Dj5A$5$l$F$$$^$;$s!#(B)
 .El
 .\"
-.Ss Thread Mailboxes
+.Ss $B%9%l%C%I%a!<%k%\%C%/%9(B
 .\"
-Each user thread must have associated with it a unique
-.Vt "struct kse_thr_mailbox" :
+$B$=$l$>$l$N%f!<%6%9%l%C%I$O$=$l$K4XO"IU$1$i$l$?M#0l$N(B
+.Vt "struct kse_thr_mailbox"
+$B$r;}$?$J$1$l$P$J$j$^$;$s(B:
 .Bd -literal
-/* Thread mailbox */
+/* $B%9%l%C%I%a!<%k%\%C%/%9(B */
 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 */
+	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
 .Pp
 .Va tm_udata
-is an opaque pointer ignored by the kernel.
+$B$O%+!<%M%k$K$h$C$FL5;k$5$l$?ITL@NF$J%]%$%s%?$G$9!#(B
 .Pp
 .Va tm_context
-stores the context for the thread when the thread is blocked in user space.
-This field is also updated by the kernel before a completed thread is returned
-to the user thread scheduler via
-.Va km_completed .
+$B$O%f!<%66u4VFb$G%9%l%C%I$,%V%m%C%/$5$l$?;~$K!"$=$N%9%l%C%I$N$?$a$N(B
+$B%3%s%F%-%9%H$rJ]B8$7$^$9!#(B
+$B$3$N%U%#!<%k%I$O40N;$7$?%9%l%C%I$,(B
+.Va km_completed
+$B$r2p$7$F%f!<%6%9%l%C%I%9%1%8%e!<%i$KLa$kA0$K!"%+!<%M%k$K$h$C$F$b99?7$5$l$^$9!#(B
 .Pp
 .Va tm_next
-links the
+$B$O%+!<%M%k$N(B upcall $B$K$h$jLa$C$?;~$K!"(B
 .Va km_completed
-threads together when returned by the kernel with an upcall.
-The end of the list is marked with a
+$B%9%l%C%I$K%j%s%/$7$^$9!#(B
+$B$3$N%j%9%H$N:G8e$O(B
 .Dv NULL
-pointer.
+$B$G%^!<%/$5$l$^$9!#(B
 .Pp
 .Va tm_uticks
-and
+$B$*$h$S(B
 .Va tm_sticks
-are time counters for user mode and kernel mode execution, respectively.
-These counters count ticks of the statistics clock (see
-.Xr clocks 7 ) .
-While any thread is actively executing in the kernel, the corresponding
+$B$O$=$l$>$l!"%f!<%6%b!<%I$*$h$S%+!<%M%k%b!<%I$N<B9T$N$?$a$N;~4V%+%&%s%?$G$9!#(B
+$B$3$l$i$N%+%&%s%?$OE}7W%/%m%C%/(B
+.Xr ( clocks 7
+$B$r;2>H$7$F$/$@$5$$(B) $B$N9o$_$r%+%&%s%H$7$^$9!#(B
+$B%+!<%M%kFb$G$$$:$l$+$N%9%l%C%I$,%"%/%F%#%V$K<B9TCf$N4V$O!"BP1~$9$k(B
 .Va tm_sticks
-counter is incremented.
-While any KSE is executing in user space and that KSE's
+$B%+%&%s%?$,%$%s%/%j%a%s%H$5$l$^$9!#(B
+$B%f!<%66u4V$G$$$:$l$+$N(B KSE $B<B9TCf$G!"$=$N(B KSE $B$N(B
 .Va km_curthread
-pointer is not equal to
-.Dv NULL ,
-the corresponding
+$B%]%$%s%?$,(B
+.Dv NULL
+$B$HEy$7$/$J$$4V$O!"BP1~$9$k(B
 .Va tm_uticks
-counter is incremented.
+$B%+%&%s%?$,%$%s%/%j%a%s%H$5$l$^$9!#(B
 .Pp
 .Va tm_flags
-may contain any of the following bits OR'ed together:
+$B$O0J2<$NA4$F$N%S%C%HKh$N(B OR $B$r4^$`$3$H$,$G$-$^$9(B:
 .Bl -tag -width indent
 .It \&
-(No flags are defined yet.)
+($B$^$@%U%i%0$OA4$/Dj5A$5$l$F$$$^$;$s!#(B)
 .El
-.Sh RETURN VALUES
-The
+.Sh $BLa$jCM(B
+$B@.8y$N>l9g$K$O(B
 .Fn kse_create ,
 .Fn kse_wakeup ,
-and
+$B$*$h$S(B
 .Fn kse_thr_interrupt
-system calls
-return zero if successful.
-The
+$B%7%9%F%`%3!<%k$O(B 0 $B$rJV$7$^$9!#(B
+$B@.8y$N>l9g$K$O(B
 .Fn kse_exit
-and
+$B$*$h$S(B
 .Fn kse_release
-system calls
-do not return if successful.
+$B%7%9%F%`%3!<%k$OLa$j$^$;$s!#(B
 .Pp
-All of these system calls return a non-zero error code in case of an error.
-.Sh ERRORS
-The
+$B%(%i!<$N>l9g$K$O!"$3$l$iA4$F$N%7%9%F%`%3!<%k$O(B 0 $B$G$O$J$$(B
+$B%(%i!<%3!<%I$rJV$7$^$9!#(B
+.Sh $B%(%i!<(B
 .Fn kse_create
-system call
-will fail if:
+$B%7%9%F%`%3!<%k$O<!$N>l9g$K<:GT$7$^$9(B:
 .Bl -tag -width Er
 .It Bq Er ENXIO
-There are already as many KSEs in the KSE group as hardware processors.
+$B4{$K(B KSE $B%0%k!<%W$NCf$K%O!<%I%&%'%"%W%m%;%C%5$HF1$8?t$N(B KSE $B$,B8:_$7$F$$$^$9!#(B
 .It Bq Er EAGAIN
-The system-imposed limit on the total number of KSE groups under
-execution would be exceeded.
-The limit is given by the
+$B<B9T2<$N(B KSE $B%0%k!<%W$N%H!<%?%k?t$K$D$$$F$N%7%9%F%`$K2]$;$i$l$?@)8B$r(B
+$BD62a$7$^$9!#(B
+$B$3$N@)8B$O(B
 .Xr sysctl 3
-MIB variable
-.Dv KERN_MAXPROC .
-(The limit is actually ten less than this
-except for the super user.)
+MIB $BJQ?t(B
+.Dv KERN_MAXPROC
+$B$K$h$C$FM?$($i$l$^$9!#(B
+($B$3$N@)8B$O%9!<%Q%f!<%6$N$?$a$r=|$-!"<B:]$K$O$3$l$h$j(B 10 $B>.$5$$CM$G$9!#(B)
 .It Bq Er EAGAIN
-The user is not the super user, and the system-imposed limit on the total
-number of KSE groups under execution by a single user would be exceeded.
-The limit is given by the
+$B%f!<%6$,%9!<%Q%f!<%6$G$O$J$/!"(B1 $B%f!<%6$K$h$k<B9T2<$N(B KSE $B%0%k!<%W$N(B
+$B%H!<%?%k?t$K$D$$$F$N%7%9%F%`$K2]$;$i$l$?@)8B$rD62a$7$^$9!#(B
+$B$3$N@)8B$O(B
 .Xr sysctl 3
-MIB variable
-.Dv KERN_MAXPROCPERUID .
+MIB $BJQ?t(B
+.Dv KERN_MAXPROCPERUID
+$B$K$h$C$FM?$($i$l$^$9!#(B
 .It Bq Er EAGAIN
-The user is not the super user, and the soft resource limit corresponding
-to the
+$B%f!<%6$,%9!<%Q%f!<%6$G$O$J$/!"(B
 .Fa resource
-argument
+$B0z?t(B
 .Dv RLIMIT_NPROC
-would be exceeded (see
-.Xr getrlimit 2 ) .
+$B$KBP1~$9$k%=%U%H%j%=!<%9@)8B$rD62a$7$^$9(B
+.Xr ( getrlimit 2
+$B$r;2>H$7$F$/$@$5$$(B)$B!#(B
 .It Bq Er EFAULT
-The
 .Fa mbx
-argument
-points to an address which is not a valid part of the process address space.
+$B0z?t$,%W%m%;%9$N%"%I%l%96u4V$NM-8z$G$O$J$$ItJ,$N%"%I%l%9$r;X$7$F$$$^$9!#(B
 .El
 .Pp
-The
 .Fn kse_exit
-system call
-will fail if:
+$B%7%9%F%`%3!<%k$O<!$N>l9g$K<:GT$7$^$9(B:
 .Bl -tag -width Er
 .It Bq Er EDEADLK
-The current KSE is the last in its KSE group and there are still one or more
-threads associated with the KSE group blocked in the kernel.
+$B8=:_$N(B KSE $B$O$=$N(B KSE $B%0%k!<%WFb$N:G8e$G!"0MA3$H$7$F(B 1 $B$D0J>e$N%+!<%M%kFb$G(B
+$B%V%m%C%/$5$l$?$=$N(B KSE $B%0%k!<%W$K4XO"IU$1$i$l$?%9%l%C%I$,B8:_$7$F$$$^$9!#(B
 .It Bq Er ESRCH
-The current KSE has no associated mailbox, i.e., the process is operating
-in traditional, unthreaded mode (in this case use
+$B8=:_$N(B KSE $B$O4XO"IU$1$i$l$?%a!<%k%\%C%/%9$r;}$C$F$$$^$;$s!#(B
+$BNc$($P!"$=$N%W%m%;%9$,EAE}E*$J%9%l%C%I2=$5$l$F$$$J$$%b!<%I$G!"(B
+$B<B9T$7$F$$$^$9(B ($B$3$N>l9g$O%W%m%;%9$r=*N;$9$k$?$a$K(B
 .Xr _exit 2
-to exit the process).
+$B$r;HMQ$7$^$9(B)$B!#(B
 .El
 .Pp
-The
 .Fn kse_release
-system call
-will fail if:
+$B%7%9%F%`%3!<%k$O<!$N>l9g$K<:GT$7$^$9(B:
 .Bl -tag -width Er
 .It Bq Er ESRCH
-The current KSE has no associated mailbox, i.e., the process is operating is
-traditional, unthreaded mode.
+$B8=:_$N(B KSE $B$O4XO"IU$1$i$l$?%a!<%k%\%C%/%9$r;}$C$F$$$^$;$s!#(B
+$BNc$($P!"$=$N%W%m%;%9$,EAE}E*$J%9%l%C%I2=$5$l$F$$$J$$%b!<%I$G!"(B
+$B<B9T$7$F$$$^$9!#(B
 .El
 .Pp
-The
 .Fn kse_wakeup
-system call
-will fail if:
+$B%7%9%F%`%3!<%k$O<!$N>l9g$K<:GT$7$^$9(B:
 .Bl -tag -width Er
 .It Bq Er ESRCH
-The
 .Fa mbx
-argument
-is not
+$B0z?t$,(B
 .Dv NULL
-and the mailbox pointed to by
+$B$G$O$J$/!"(B
 .Fa mbx
-is not associated with any KSE in the process.
+$B$K$h$C$F;X$5$l$k%a!<%k%\%C%/%9$=$N%a!<%k%\%C%/%9$,!"$=$N%W%m%;%9Fb$N(B
+$B$$$:$l$N(B KSE $B$K$b4XO"IU$1$i$l$F$$$^$;$s!#(B
 .It Bq Er ESRCH
-The
 .Fa mbx
-argument
-is
+$B0z?t$,(B
 .Dv NULL
-and the current KSE has no associated mailbox, i.e., the process is operating
-in traditional, unthreaded mode.
+$B$G!"8=:_$N(B KSE $B$,4XO"IU$1$i$l$?%a!<%k%\%C%/%9$r;}$C$F$$$^$;$s!#(B
+$BNc$($P!"$=$N%W%m%;%9$,EAE}E*$J%9%l%C%I2=$5$l$F$$$J$$%b!<%I$G!"(B
+$B<B9T$7$F$$$^$9!#(B
 .El
 .Pp
-The
 .Fn kse_thr_interrupt
-system call
-will fail if:
+$B%7%9%F%`%3!<%k$O<!$N>l9g$K<:GT$7$^$9(B:
 .Bl -tag -width Er
 .It Bq Er ESRCH
-The thread corresponding to
 .Fa tmbx
-is neither currently assigned to any KSE in the process nor blocked in the
-kernel.
+$B$KBP1~$9$k%9%l%C%I$,!"8=:_%W%m%;%9Fb$N$$$:$l$N(B KSE $B$K$b3d$jEv$F$i$l$F$$$J$$$+!"(B
+$B%+!<%M%kFb$G%V%m%C%/$5$l$F$$$^$9!#(B
 .El
-.Sh SEE ALSO
+.Sh $B4XO"9`L\(B
 .Xr rfork 2 ,
 .Xr pthread 3 ,
 .Xr ucontext 3
@@ -639,21 +635,25 @@
 .%P pp. 53-79
 .%T "Scheduler activations: effective kernel support for the user-level management of parallelism"
 .Re
-.Sh HISTORY
-The KSE system calls first appeared in
-.Fx 5.0 .
-.Sh AUTHORS
-KSE was originally implemented by
+.Sh $BNr;K(B
+KSE $B%7%9%F%`%3!<%k72$O(B
+.Fx 5.0
+$B$G$O$8$a$FEP>l$7$^$7$?!#(B
+.Sh $B:n<T(B
+KSE $B$O=i$a$K(B
 .An -nosplit
 .An "Julian Elischer" Aq julian@FreeBSD.org ,
-with additional contributions by
+$B$,<BAu$7!"(B
 .An "Jonathan Mini" Aq mini@FreeBSD.org ,
 .An "Daniel Eischen" Aq deischen@FreeBSD.org ,
-and
-.An "David Xu" Aq davidxu@FreeBSD.org .
-.Pp
-This manual page was written by
-.An "Archie Cobbs" Aq archie@FreeBSD.org .
-.Sh BUGS
-The KSE code is
-.Ud .
+$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
+.Sh $B%P%0(B
+KSE $B$N%3!<%I$O3+H/Cf$G$9!#(B
+.\" .Ud .
+.\" .Ud $B%^%/%m$OF|K\8l$G$O<BAu$5$l$F$$$^$;$s!#(B($BCSFb(B)

