| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | .\" $NetBSD: csf.9,v 1.4 2008/04/30 13:10:58 martin Exp $ | | 1 | .\" $NetBSD: csf.9,v 1.5 2009/03/15 14:05:18 joerg Exp $ |
2 | .\" | | 2 | .\" |
3 | .\" Copyright (c) 2002 The NetBSD Foundation, Inc. | | 3 | .\" Copyright (c) 2002 The NetBSD Foundation, Inc. |
4 | .\" All rights reserved. | | 4 | .\" All rights reserved. |
5 | .\" | | 5 | .\" |
6 | .\" This code is derived from software contributed to The NetBSD Foundation | | 6 | .\" This code is derived from software contributed to The NetBSD Foundation |
7 | .\" by Daniel Sieger. | | 7 | .\" by Daniel Sieger. |
8 | .\" | | 8 | .\" |
9 | .\" Redistribution and use in source and binary forms, with or without | | 9 | .\" Redistribution and use in source and binary forms, with or without |
10 | .\" modification, are permitted provided that the following conditions | | 10 | .\" modification, are permitted provided that the following conditions |
11 | .\" are met: | | 11 | .\" are met: |
12 | .\" 1. Redistributions of source code must retain the above copyright | | 12 | .\" 1. Redistributions of source code must retain the above copyright |
13 | .\" notice, this list of conditions and the following disclaimer. | | 13 | .\" notice, this list of conditions and the following disclaimer. |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright |
| @@ -89,88 +89,88 @@ provides a modular and self-contained in | | | @@ -89,88 +89,88 @@ provides a modular and self-contained in |
89 | implementing different thread scheduling algorithms. | | 89 | implementing different thread scheduling algorithms. |
90 | The different schedulers can be selected at compile-time. | | 90 | The different schedulers can be selected at compile-time. |
91 | Currently, the only scheduler available is | | 91 | Currently, the only scheduler available is |
92 | .Xr sched_4bsd 9 , | | 92 | .Xr sched_4bsd 9 , |
93 | the traditional 4.4BSD thread scheduler. | | 93 | the traditional 4.4BSD thread scheduler. |
94 | .Pp | | 94 | .Pp |
95 | The interface is divided into two parts: A set of functions each | | 95 | The interface is divided into two parts: A set of functions each |
96 | scheduler needs to implement and common functions used by all | | 96 | scheduler needs to implement and common functions used by all |
97 | schedulers. | | 97 | schedulers. |
98 | .Sh Scheduler-specific functions | | 98 | .Sh Scheduler-specific functions |
99 | The following functions have to be implemented by the individual | | 99 | The following functions have to be implemented by the individual |
100 | scheduler. | | 100 | scheduler. |
101 | .Ss Scheduler initialization | | 101 | .Ss Scheduler initialization |
102 | .Bl -tag | | 102 | .Bl -tag -width compact |
103 | .It Ft void Fn sched_cpuattach "struct cpu_info *" | | 103 | .It Ft void Fn sched_cpuattach "struct cpu_info *" |
104 | Per-CPU scheduler initialization routine. | | 104 | Per-CPU scheduler initialization routine. |
105 | .It Ft void Fn sched_rqinit "void" | | 105 | .It Ft void Fn sched_rqinit "void" |
106 | Initialize the scheduler's runqueue data structures. | | 106 | Initialize the scheduler's runqueue data structures. |
107 | .It Ft void Fn sched_setup "void" | | 107 | .It Ft void Fn sched_setup "void" |
108 | Setup initial scheduling parameters and kick off timeout driven | | 108 | Setup initial scheduling parameters and kick off timeout driven |
109 | events. | | 109 | events. |
110 | .El | | 110 | .El |
111 | .Ss Runqueue handling | | 111 | .Ss Runqueue handling |
112 | Runqueue handling is completely internal to the scheduler. | | 112 | Runqueue handling is completely internal to the scheduler. |
113 | Other parts of the kernel should access runqueues only through the | | 113 | Other parts of the kernel should access runqueues only through the |
114 | following functions: | | 114 | following functions: |
115 | .Bl -tag | | 115 | .Bl -tag -width compact |
116 | .It Ft void Fn sched_enqueue "lwp_t *" "bool" | | 116 | .It Ft void Fn sched_enqueue "lwp_t *" "bool" |
117 | Place an LWP within the scheduler's runqueue structures. | | 117 | Place an LWP within the scheduler's runqueue structures. |
118 | .It Ft void Fn sched_dequeue "lwp_t *" | | 118 | .It Ft void Fn sched_dequeue "lwp_t *" |
119 | Remove an LWP from the scheduler's runqueue structures. | | 119 | Remove an LWP from the scheduler's runqueue structures. |
120 | .It Ft lwp_t * Fn sched_nextlwp "void" | | 120 | .It Ft lwp_t * Fn sched_nextlwp "void" |
121 | Return the LWP that should run the CPU next. | | 121 | Return the LWP that should run the CPU next. |
122 | .It Ft bool Fn sched_curcpu_runnable_p "void" | | 122 | .It Ft bool Fn sched_curcpu_runnable_p "void" |
123 | Indicate if there is a runnable LWP for the current CPU. | | 123 | Indicate if there is a runnable LWP for the current CPU. |
124 | .It Ft void Fn sched_print_runqueue "void (*pr)(const char *, ...)" | | 124 | .It Ft void Fn sched_print_runqueue "void (*pr)(const char *, ...)" |
125 | Print runqueues in DDB. | | 125 | Print runqueues in DDB. |
126 | .El | | 126 | .El |
127 | .Ss Core scheduler functions | | 127 | .Ss Core scheduler functions |
128 | .Bl -tag | | 128 | .Bl -tag -width compact |
129 | .It Ft void Fn sched_tick "struct cpu_info *" | | 129 | .It Ft void Fn sched_tick "struct cpu_info *" |
130 | Periodically called from | | 130 | Periodically called from |
131 | .Xr hardclock 9 . | | 131 | .Xr hardclock 9 . |
132 | Determines if a reschedule is necessary, if the running LWP has | | 132 | Determines if a reschedule is necessary, if the running LWP has |
133 | used up its quantum. | | 133 | used up its quantum. |
134 | .It Ft void Fn sched_schedclock "lwp_t *" | | 134 | .It Ft void Fn sched_schedclock "lwp_t *" |
135 | Periodically called from | | 135 | Periodically called from |
136 | .Fn schedclock | | 136 | .Fn schedclock |
137 | in order to handle priority adjustment. | | 137 | in order to handle priority adjustment. |
138 | .El | | 138 | .El |
139 | .Ss Priority adjustment | | 139 | .Ss Priority adjustment |
140 | .Bl -tag | | 140 | .Bl -tag -width compact |
141 | .It Ft void Fn sched_nice "struct proc *, int" | | 141 | .It Ft void Fn sched_nice "struct proc *, int" |
142 | Recalculate the process priority according to its nice value. | | 142 | Recalculate the process priority according to its nice value. |
143 | .El | | 143 | .El |
144 | .Ss General helper functions | | 144 | .Ss General helper functions |
145 | .Bl -tag | | 145 | .Bl -tag -width compact |
146 | .It Ft void Fn sched_proc_fork "struct proc *" "struct proc *" | | 146 | .It Ft void Fn sched_proc_fork "struct proc *" "struct proc *" |
147 | Inherit the scheduling history of the parent process after | | 147 | Inherit the scheduling history of the parent process after |
148 | .Fn fork . | | 148 | .Fn fork . |
149 | .It Ft void Fn sched_proc_exit "struct proc *" "struct proc *" | | 149 | .It Ft void Fn sched_proc_exit "struct proc *" "struct proc *" |
150 | Charge back a processes parent for its resource usage. | | 150 | Charge back a processes parent for its resource usage. |
151 | .It Ft void Fn sched_lwp_fork "lwp_t *" | | 151 | .It Ft void Fn sched_lwp_fork "lwp_t *" |
152 | LWP-specific version of the above | | 152 | LWP-specific version of the above |
153 | .It Ft void Fn sched_lwp_exit "lwp_t *" | | 153 | .It Ft void Fn sched_lwp_exit "lwp_t *" |
154 | LWP-specific version of the above | | 154 | LWP-specific version of the above |
155 | .It Ft void Fn sched_setrunnable "lwp_t *" | | 155 | .It Ft void Fn sched_setrunnable "lwp_t *" |
156 | Scheduler-specific actions for | | 156 | Scheduler-specific actions for |
157 | .Fn setrunnable . | | 157 | .Fn setrunnable . |
158 | .It Ft void Fn sched_pstats_hook "struct proc *" "int" | | 158 | .It Ft void Fn sched_pstats_hook "struct proc *" "int" |
159 | Scheduler-specific actions for | | 159 | Scheduler-specific actions for |
160 | .Fn sched_pstats . | | 160 | .Fn sched_pstats . |
161 | .El | | 161 | .El |
162 | .Sh Common scheduler functions | | 162 | .Sh Common scheduler functions |
163 | .Bl -tag | | 163 | .Bl -tag -width compact |
164 | .It Ft pri_t Fn sched_kpri "lwp_t *" | | 164 | .It Ft pri_t Fn sched_kpri "lwp_t *" |
165 | Scale a priority level to a kernel priority level, usually for an LWP | | 165 | Scale a priority level to a kernel priority level, usually for an LWP |
166 | that is about to sleep. | | 166 | that is about to sleep. |
167 | .It Ft void Fn sched_pstats "void *" | | 167 | .It Ft void Fn sched_pstats "void *" |
168 | Update process statistics and check CPU resource allocation. | | 168 | Update process statistics and check CPU resource allocation. |
169 | .It Ft inline void Fn resched_cpu "lwp_t *" | | 169 | .It Ft inline void Fn resched_cpu "lwp_t *" |
170 | Arrange for a reschedule. | | 170 | Arrange for a reschedule. |
171 | .It Ft void Fn setrunnable "lwp_t *" | | 171 | .It Ft void Fn setrunnable "lwp_t *" |
172 | Change process state to be runnable, placing it on a runqueue if it | | 172 | Change process state to be runnable, placing it on a runqueue if it |
173 | is in memory, awakening the swapper otherwise. | | 173 | is in memory, awakening the swapper otherwise. |
174 | .It Ft void Fn schedclock "lwp_t *" | | 174 | .It Ft void Fn schedclock "lwp_t *" |
175 | Scheduler clock. | | 175 | Scheduler clock. |
176 | Periodically called from | | 176 | Periodically called from |