Source-Changes-HG archive

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

[src/trunk]: src/share/man/man9 Document the details of the scheduler.



details:   https://anonhg.NetBSD.org/src/rev/cdf86d2b1e9a
branches:  trunk
changeset: 536794:cdf86d2b1e9a
user:      gmcgarry <gmcgarry%NetBSD.org@localhost>
date:      Sun Sep 22 06:26:33 2002 +0000

description:
Document the details of the scheduler.

diffstat:

 share/man/man9/Makefile       |   20 ++++--
 share/man/man9/SCHED_LOCK.9   |   85 +++++++++++++++++++++++++++++
 share/man/man9/chooseproc.9   |   75 +++++++++++++++++++++++++
 share/man/man9/cpu_idle.9     |   93 +++++++++++++++++++++++++++++++
 share/man/man9/ctxsw.9        |  116 ++++++++++++++++----------------------
 share/man/man9/need_resched.9 |   69 +++++++++++++++++++++++
 share/man/man9/preempt.9      |   66 ++++++++++++++++++++++
 share/man/man9/scheduler.9    |  123 ++++++++++++++++++++++++++++++++++++++++++
 share/man/man9/setrunqueue.9  |   79 +++++++++++++++++++-------
 share/man/man9/suspendsched.9 |   58 +++++++++++++++++++
 share/man/man9/userret.9      |   87 +++++++++++++++++++++++++++++
 11 files changed, 776 insertions(+), 95 deletions(-)

diffs (truncated from 1024 to 300 lines):

diff -r d98a4dc7df44 -r cdf86d2b1e9a share/man/man9/Makefile
--- a/share/man/man9/Makefile   Sun Sep 22 06:22:50 2002 +0000
+++ b/share/man/man9/Makefile   Sun Sep 22 06:26:33 2002 +0000
@@ -1,12 +1,13 @@
-#       $NetBSD: Makefile,v 1.122 2002/08/28 07:56:31 gmcgarry Exp $
+#       $NetBSD: Makefile,v 1.123 2002/09/22 06:26:33 gmcgarry Exp $
 
 #      Makefile for section 9 (kernel function and variable) manual pages.
 
 MAN=   access.9 altq.9 arc4random.9 arp.9 audio.9 autoconf.9 \
        bitmask_snprintf.9 bcmp.9 bcopy.9 bzero.9 \
        bufq.9 bus_dma.9 bus_space.9 \
-       callout.9 cardbus.9 cnmagic.9 config.9 cons.9 copy.9 \
-       cpu_configure.9 cpu_coredump.9 cpu_dumpconf.9 cpu_exit.9 cpu_fork.9 \
+       callout.9 cardbus.9 chooseproc.9 cnmagic.9 config.9 cons.9 copy.9 \
+       cpu_configure.9 cpu_coredump.9 cpu_dumpconf.9 cpu_exit.9 cpu_idle.9 \
+       cpu_fork.9 \
        cpu_initclocks.9 cpu_number.9 cpu_reboot.9 cpu_rootconf.9 \
        cpu_startup.9 cpu_swapout.9 cpu_sysctl.9 cpu_wait.9 \
        ctxsw.9 curproc.9 delay.9 disk.9 disklabel.9 \
@@ -17,14 +18,17 @@
        isapnp.9 itimerfix.9 kcopy.9 \
        kprintf.9 kthread.9 linedisc.9 lock.9 log.9 malloc.9 mbuf.9 \
        mca.9 memcmp.9 memcpy.9 memmove.9 memset.9 \
-       microtime.9 mstohz.9 namecache.9 namei.9 \
+       microtime.9 mstohz.9 namecache.9 namei.9 need_resched.9 \
        panic.9 pci.9 pci_configure_bus.9 pci_intr.9 \
        pcmcia.9 pfil.9 physio.9 \
        pmap.9 pmc.9 pool.9 powerhook_establish.9 ppsratecheck.9 properties.9 \
+       preempt.9 \
        radio.9 ras.9 rasops.9 ratecheck.9 resettodr.9 rnd.9 rt_timer.9 \
+       SCHED_LOCK.9 scheduler.9 \
        scsipi.9 setjmp.9 setrunqueue.9 shutdownhook_establish.9 \
        signal.9 sleep.9 softintr.9 \
-       spl.9 store.9 suser.9 tc.9 time.9 todr.9 uiomove.9 ucom.9 \
+       spl.9 store.9 suser.9 suspendsched.9 \
+       tc.9 time.9 todr.9 uiomove.9 ucom.9 userret.9 \
        vattr.9 vfs.9 vfsops.9 vme.9 vnode.9 vnodeops.9 vnsubr.9 \
        usbdi.9 uvm.9 wdc.9 wscons.9 wsdisplay.9 wsfont.9 wskbd.9 wsmouse.9
 
@@ -311,8 +315,12 @@
 MLINKS+=rt_timer.9 rt_timer_queue_create.9 rt_timer.9 rt_timer_queue_change.9 \
        rt_timer.9 rt_timer_queue_destroy.9 rt_timer.9 rt_timer_add.9 \
        rt_timer.9 rt_timer_remove_all.9
+MLINKS+=SCHED_LOCK.9 SCHED_UNLOCK.9 \
+       SCHED_LOCK.9 sched_lock_idle.9 \
+       SCHED_LOCK.9 sched_unlock_idle.9
 MLINKS+=setjmp.9 longjmp.9
-MLINKS+=setrunqueue.9 remrunqueue.9
+MLINKS+=setrunqueue.9 remrunqueue.9 \
+       setrunqueue.9 nextrunqueue.9
 MLINKS+=shutdownhook_establish.9 shutdownhook_disestablish.9
 MLINKS+=signal.9 siginit.9 \
        signal.9 sigactsinit.9 \
diff -r d98a4dc7df44 -r cdf86d2b1e9a share/man/man9/SCHED_LOCK.9
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/share/man/man9/SCHED_LOCK.9       Sun Sep 22 06:26:33 2002 +0000
@@ -0,0 +1,85 @@
+.\"     $NetBSD: SCHED_LOCK.9,v 1.1 2002/09/22 06:27:17 gmcgarry Exp $
+.\"
+.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Gregory McGarry.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"        This product includes software developed by the NetBSD
+.\"        Foundation, Inc. and its contributors.
+.\" 4. Neither the name of The NetBSD Foundation nor the names of its
+.\"    contributors may be used to endorse or promote products derived
+.\"    from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd September 21, 2002
+.Dt SCHED_LOCK 9
+.Os
+.Sh NAME
+.Nm SCHED_LOCK ,
+.Nm SCHED_UNLOCK ,
+.Nm sched_lock_idle ,
+.Nm sched_unlock_idle
+.Nd scheduler lock operations
+.Sh SYNOPSIS
+.Fd #include \*[Lt]sys/sched.h\*[Gt]
+.Ft void
+.Fn sched_lock_idle "void"
+.Ft void
+.Fn sched_unlock_idle "void"
+.Ft int
+.Fn SCHED_LOCK "void"
+.Ft void
+.Fn SCHED_UNLOCK "s"
+.Sh DESCRIPTION
+Access to the system run queue within the scheduler is protected by
+the
+.Va sched_lock
+simplelock and the
+.Xr splsched
+interrupt priority level.  The
+.Fn sched_lock_idle
+and
+.Fn sched_unlock_idle
+are simple functions without arguments which can be called easily from
+machine-dependent assembler routines
+.Pq such as from Xr cpu_idle 9
+to lock and unlock the scheduler.
+The macros
+.Fn SCHED_LOCK
+and
+.Fn SCHED_UNLOCK
+provide a simple interface for machine-independent routines to
+simultaneously acquire
+.Va sched_lock
+and raise the interrupt priority level to
+.Xr splsched 9 .
+.Fn SCHED_LOCK
+returns the current interrupt priority level which is later passed to
+.Fn SCHED_UNLOCK
+when the scheduler lock is released.
+.Sh SEE ALSO
+.Xr scheduler 9 ,
+.Xr splsched 9
diff -r d98a4dc7df44 -r cdf86d2b1e9a share/man/man9/chooseproc.9
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/share/man/man9/chooseproc.9       Sun Sep 22 06:26:33 2002 +0000
@@ -0,0 +1,75 @@
+.\"     $NetBSD: chooseproc.9,v 1.1 2002/09/22 06:26:34 gmcgarry Exp $
+.\"
+.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Gregory McGarry.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"        This product includes software developed by the NetBSD
+.\"        Foundation, Inc. and its contributors.
+.\" 4. Neither the name of The NetBSD Foundation nor the names of its
+.\"    contributors may be used to endorse or promote products derived
+.\"    from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd September 21, 2002
+.Dt CHOOSEPROC 9
+.Os
+.Sh NAME
+.Nm chooseproc
+.Nd select next process from system run queue
+.Sh SYNOPSIS
+.Fd #include \*[Lt]sys/proc.h\*[Gt]
+.Ft struct proc *
+.Fn chooseproc "void"
+.Sh DESCRIPTION
+The
+.Fn chooseproc
+function is invoked by the scheduler to select the highest priority
+process from the system run queue.  If a process is not available on
+the system run queue,
+.Fn chooseproc
+shall go into an ``idle'' loop by invoking
+.Xr cpu_idle 9 .
+The variable
+.Va curproc
+is set to
+.Dv NULL
+while
+.Fn chooseproc
+is idle so that CPU time is not allocated to the outgoing process.
+.Pp
+The
+.Fn chooseproc
+function must be called with the scheduler lock held
+.Pq see Xr SCHED_LOCK 9
+and at the
+.Xr splsched 9
+interrupt protection level.
+.Sh SEE ALSO
+.Xr cpu_idle 9 ,
+.Xr mi_switch 9 ,
+.Xr scheduler 9 ,
+.Xr splsched 9
\ No newline at end of file
diff -r d98a4dc7df44 -r cdf86d2b1e9a share/man/man9/cpu_idle.9
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/share/man/man9/cpu_idle.9 Sun Sep 22 06:26:33 2002 +0000
@@ -0,0 +1,93 @@
+.\"     $NetBSD: cpu_idle.9,v 1.1 2002/09/22 06:26:34 gmcgarry Exp $
+.\"
+.\" Copyright (c) 2002 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Gregory McGarry.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\"    must display the following acknowledgement:
+.\"        This product includes software developed by the NetBSD
+.\"        Foundation, Inc. and its contributors.
+.\" 4. Neither the name of The NetBSD Foundation nor the names of its
+.\"    contributors may be used to endorse or promote products derived
+.\"    from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd September 21, 2002
+.Dt CPU_IDLE 9
+.Os
+.Sh NAME
+.Nm cpu_idle
+.Nd idle CPU while waiting for work
+.Sh SYNOPSIS
+.Fd #include \*[Lt]sys/proc.h\*[Gt]
+.Ft void
+.Fn cpu_idle "void"
+.Sh DESCRIPTION
+The
+.Fn cpu_idle
+function is invoked to idle the current CPU while waiting for work to
+be done.  It is primarily called by the scheduler if no processes are
+available on the system run queue.  The
+.Fn cpu_idle
+function is a machine-dependent implementations in order to permit
+low-level CPU control.
+.Pp
+The
+.Fn cpu_idle
+function must be called with the scheduler lock held
+.P see Xr SCHED_LOCK 9
+and at the
+.Xr splsched 9
+interrupt protection level.  It performs the following operations:
+.Bl -bullet
+.It
+Release the scheduler lock.
+.It
+Lower the current interrupt priority level to permit interrupts to be
+taken that will eventually cause processes to appear again on the
+system run queue.
+.It
+Try to zero some pages for the virtual memory system.
+.It



Home | Main Index | Thread Index | Old Index