472351e13d
.In header.h instead of .Fd #include \*[Lt]header.h\*[Gt] Much easier to read and write, and supported by groff for ages. Okayed by ross.
120 lines
4.1 KiB
Groff
120 lines
4.1 KiB
Groff
.\" $NetBSD: setrunqueue.9,v 1.7 2003/04/16 13:35:33 wiz Exp $
|
|
.\"
|
|
.\" Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
|
|
.\" All rights reserved.
|
|
.\"
|
|
.\" 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 SETRUNQUEUE 9
|
|
.Os
|
|
.Sh NAME
|
|
.Nm setrunqueue ,
|
|
.Nm remrunqueue ,
|
|
.Nm nextrunqueue
|
|
.Nd manipulate system run queue
|
|
.Sh SYNOPSIS
|
|
.In sys/proc.h
|
|
.In sys/sched.h
|
|
.Ft void
|
|
.Fn setrunqueue "struct proc *p"
|
|
.Ft void
|
|
.Fn remrunqueue "struct proc *p"
|
|
.Ft struct proc *
|
|
.Fn nextrunqueue "void"
|
|
.Sh DESCRIPTION
|
|
The
|
|
.Fn setrunqueue ,
|
|
.Fn remrunqueue ,
|
|
and
|
|
.Fn nextrunqueue
|
|
functions manipulate the system queue of runnable processes.
|
|
The system scheduler uses this queue to find the highest-priority process
|
|
when a process switch occurs.
|
|
These functions are generally machine-dependent implementations in order
|
|
to permit efficient implementation of priority-based process selection.
|
|
.Pp
|
|
.Bf -symbolic
|
|
Currently, these functions are scheduler specific and correspond to
|
|
the default
|
|
.Dq time-sharing
|
|
scheduler in
|
|
.Nx .
|
|
Their implementation is likely to change in the future to cater for
|
|
different schedulers.
|
|
.Ef
|
|
.Pp
|
|
The priority queue consists of an array
|
|
.Va sched_qs[NQS]
|
|
of queue header structures each of which identifies a list of runnable
|
|
processes of equal priority.
|
|
Lower indices in
|
|
.Va sched_qs
|
|
indicate higher priority.
|
|
A single word
|
|
.Va sched_whichqs
|
|
containing a bit mask identifying non-empty queues assists in
|
|
selecting a process quickly.
|
|
The running process is on no queue, other processes are on a queue related
|
|
to p->p_priority, divided by 4 actually to shrink the 0-127 range of
|
|
priorities into the 32 available queues.
|
|
.Pp
|
|
The
|
|
.Fn setrunqueue
|
|
function places the given process on the system run queue.
|
|
It is an error to call
|
|
.Fn setrunqueue
|
|
with a process that is not runnable or that is already on the system
|
|
run queue or sleep queue.
|
|
.Pp
|
|
The
|
|
.Fn remrunqueue
|
|
function removes the given process from the system run queue.
|
|
It is an error to call
|
|
.Fn remrunqueue
|
|
with a process that is not on the system run queue.
|
|
.Pp
|
|
The
|
|
.Fn nextrunqueue
|
|
function will make a choice amongst the processes which are ready to
|
|
run from the priority run queue.
|
|
.Fn nextrunqueue
|
|
will remove the first process from the list on the queue with the
|
|
highest priority a return it.
|
|
.Pp
|
|
These functions 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 SCHED_LOCK 9 ,
|
|
.Xr scheduler 9 ,
|
|
.Xr splsched 9
|