164 /* callbacks */
165
166 static int fx_admin(caddr_t, cred_t *);
167 static int fx_getclinfo(void *);
168 static int fx_parmsin(void *);
169 static int fx_parmsout(void *, pc_vaparms_t *);
170 static int fx_vaparmsin(void *, pc_vaparms_t *);
171 static int fx_vaparmsout(void *, pc_vaparms_t *);
172 static int fx_getclpri(pcpri_t *);
173 static int fx_alloc(void **, int);
174 static void fx_free(void *);
175 static int fx_enterclass(kthread_t *, id_t, void *, cred_t *, void *);
176 static void fx_exitclass(void *);
177 static int fx_canexit(kthread_t *, cred_t *);
178 static int fx_fork(kthread_t *, kthread_t *, void *);
179 static void fx_forkret(kthread_t *, kthread_t *);
180 static void fx_parmsget(kthread_t *, void *);
181 static int fx_parmsset(kthread_t *, void *, id_t, cred_t *);
182 static void fx_stop(kthread_t *, int, int);
183 static void fx_exit(kthread_t *);
184 static pri_t fx_swapin(kthread_t *, int);
185 static pri_t fx_swapout(kthread_t *, int);
186 static void fx_trapret(kthread_t *);
187 static void fx_preempt(kthread_t *);
188 static void fx_setrun(kthread_t *);
189 static void fx_sleep(kthread_t *);
190 static void fx_tick(kthread_t *);
191 static void fx_wakeup(kthread_t *);
192 static int fx_donice(kthread_t *, cred_t *, int, int *);
193 static int fx_doprio(kthread_t *, cred_t *, int, int *);
194 static pri_t fx_globpri(kthread_t *);
195 static void fx_yield(kthread_t *);
196 static void fx_nullsys();
197
198 extern fxdpent_t *fx_getdptbl(void);
199
200 static void fx_change_priority(kthread_t *, fxproc_t *);
201 static fxproc_t *fx_list_lookup(kt_did_t);
202 static void fx_list_release(fxproc_t *);
203
204
205 static struct classfuncs fx_classfuncs = {
209 fx_parmsin,
210 fx_parmsout,
211 fx_vaparmsin,
212 fx_vaparmsout,
213 fx_getclpri,
214 fx_alloc,
215 fx_free,
216
217 /* thread functions */
218 fx_enterclass,
219 fx_exitclass,
220 fx_canexit,
221 fx_fork,
222 fx_forkret,
223 fx_parmsget,
224 fx_parmsset,
225 fx_stop,
226 fx_exit,
227 fx_nullsys, /* active */
228 fx_nullsys, /* inactive */
229 fx_swapin,
230 fx_swapout,
231 fx_trapret,
232 fx_preempt,
233 fx_setrun,
234 fx_sleep,
235 fx_tick,
236 fx_wakeup,
237 fx_donice,
238 fx_globpri,
239 fx_nullsys, /* set_process_group */
240 fx_yield,
241 fx_doprio,
242 };
243
244
245 int
246 _init()
247 {
248 return (mod_install(&modlinkage));
249 }
250
1207 /*
1208 * Prepare thread for sleep. We reset the thread priority so it will
1209 * run at the kernel priority level when it wakes up.
1210 */
1211 static void
1212 fx_sleep(kthread_t *t)
1213 {
1214 fxproc_t *fxpp = (fxproc_t *)(t->t_cldata);
1215
1216 ASSERT(t == curthread);
1217 ASSERT(THREAD_LOCK_HELD(t));
1218
1219 /*
1220 * Account for time spent on CPU before going to sleep.
1221 */
1222 (void) CPUCAPS_CHARGE(t, &fxpp->fx_caps, CPUCAPS_CHARGE_ENFORCE);
1223
1224 if (FX_HAS_CB(fxpp)) {
1225 FX_CB_SLEEP(FX_CALLB(fxpp), fxpp->fx_cookie);
1226 }
1227 t->t_stime = ddi_get_lbolt(); /* time stamp for the swapper */
1228 }
1229
1230
1231 /*
1232 * Return Values:
1233 *
1234 * -1 if the thread is loaded or is not eligible to be swapped in.
1235 *
1236 * FX and RT threads are designed so that they don't swapout; however,
1237 * it is possible that while the thread is swapped out and in another class, it
1238 * can be changed to FX or RT. Since these threads should be swapped in
1239 * as soon as they're runnable, rt_swapin returns SHRT_MAX, and fx_swapin
1240 * returns SHRT_MAX - 1, so that it gives deference to any swapped out
1241 * RT threads.
1242 */
1243 /* ARGSUSED */
1244 static pri_t
1245 fx_swapin(kthread_t *t, int flags)
1246 {
1247 pri_t tpri = -1;
1248
1249 ASSERT(THREAD_LOCK_HELD(t));
1250
1251 if (t->t_state == TS_RUN && (t->t_schedflag & TS_LOAD) == 0) {
1252 tpri = (pri_t)SHRT_MAX - 1;
1253 }
1254
1255 return (tpri);
1256 }
1257
1258 /*
1259 * Return Values
1260 * -1 if the thread isn't loaded or is not eligible to be swapped out.
1261 */
1262 /* ARGSUSED */
1263 static pri_t
1264 fx_swapout(kthread_t *t, int flags)
1265 {
1266 ASSERT(THREAD_LOCK_HELD(t));
1267
1268 return (-1);
1269
1270 }
1271
1272 /* ARGSUSED */
1273 static void
1274 fx_stop(kthread_t *t, int why, int what)
1275 {
1276 fxproc_t *fxpp = (fxproc_t *)(t->t_cldata);
1277
1278 ASSERT(THREAD_LOCK_HELD(t));
1279
1280 if (FX_HAS_CB(fxpp)) {
1281 FX_CB_STOP(FX_CALLB(fxpp), fxpp->fx_cookie);
1282 }
1283 }
1284
1285 /*
1286 * Check for time slice expiration. If time slice has expired
1287 * set runrun to cause preemption.
1288 */
1289 static void
1379 {
1380 cpu_t *cp = CPU;
1381
1382 ASSERT(THREAD_LOCK_HELD(t));
1383 ASSERT(t == curthread);
1384 ASSERT(cp->cpu_dispthread == t);
1385 ASSERT(t->t_state == TS_ONPROC);
1386 }
1387
1388
1389 /*
1390 * Processes waking up go to the back of their queue.
1391 */
1392 static void
1393 fx_wakeup(kthread_t *t)
1394 {
1395 fxproc_t *fxpp = (fxproc_t *)(t->t_cldata);
1396
1397 ASSERT(THREAD_LOCK_HELD(t));
1398
1399 t->t_stime = ddi_get_lbolt(); /* time stamp for the swapper */
1400 if (FX_HAS_CB(fxpp)) {
1401 clock_t new_quantum = (clock_t)fxpp->fx_pquantum;
1402 pri_t newpri = fxpp->fx_pri;
1403 FX_CB_WAKEUP(FX_CALLB(fxpp), fxpp->fx_cookie,
1404 &new_quantum, &newpri);
1405 FX_ADJUST_QUANTUM(new_quantum);
1406 if ((int)new_quantum != fxpp->fx_pquantum) {
1407 fxpp->fx_pquantum = (int)new_quantum;
1408 fxpp->fx_timeleft = fxpp->fx_pquantum;
1409 }
1410
1411 FX_ADJUST_PRI(newpri);
1412 if (newpri != fxpp->fx_pri) {
1413 fxpp->fx_pri = newpri;
1414 THREAD_CHANGE_PRI(t, fx_dptbl[fxpp->fx_pri].fx_globpri);
1415 }
1416 }
1417
1418 fxpp->fx_flags &= ~FXBACKQ;
1419
|
164 /* callbacks */
165
166 static int fx_admin(caddr_t, cred_t *);
167 static int fx_getclinfo(void *);
168 static int fx_parmsin(void *);
169 static int fx_parmsout(void *, pc_vaparms_t *);
170 static int fx_vaparmsin(void *, pc_vaparms_t *);
171 static int fx_vaparmsout(void *, pc_vaparms_t *);
172 static int fx_getclpri(pcpri_t *);
173 static int fx_alloc(void **, int);
174 static void fx_free(void *);
175 static int fx_enterclass(kthread_t *, id_t, void *, cred_t *, void *);
176 static void fx_exitclass(void *);
177 static int fx_canexit(kthread_t *, cred_t *);
178 static int fx_fork(kthread_t *, kthread_t *, void *);
179 static void fx_forkret(kthread_t *, kthread_t *);
180 static void fx_parmsget(kthread_t *, void *);
181 static int fx_parmsset(kthread_t *, void *, id_t, cred_t *);
182 static void fx_stop(kthread_t *, int, int);
183 static void fx_exit(kthread_t *);
184 static void fx_trapret(kthread_t *);
185 static void fx_preempt(kthread_t *);
186 static void fx_setrun(kthread_t *);
187 static void fx_sleep(kthread_t *);
188 static void fx_tick(kthread_t *);
189 static void fx_wakeup(kthread_t *);
190 static int fx_donice(kthread_t *, cred_t *, int, int *);
191 static int fx_doprio(kthread_t *, cred_t *, int, int *);
192 static pri_t fx_globpri(kthread_t *);
193 static void fx_yield(kthread_t *);
194 static void fx_nullsys();
195
196 extern fxdpent_t *fx_getdptbl(void);
197
198 static void fx_change_priority(kthread_t *, fxproc_t *);
199 static fxproc_t *fx_list_lookup(kt_did_t);
200 static void fx_list_release(fxproc_t *);
201
202
203 static struct classfuncs fx_classfuncs = {
207 fx_parmsin,
208 fx_parmsout,
209 fx_vaparmsin,
210 fx_vaparmsout,
211 fx_getclpri,
212 fx_alloc,
213 fx_free,
214
215 /* thread functions */
216 fx_enterclass,
217 fx_exitclass,
218 fx_canexit,
219 fx_fork,
220 fx_forkret,
221 fx_parmsget,
222 fx_parmsset,
223 fx_stop,
224 fx_exit,
225 fx_nullsys, /* active */
226 fx_nullsys, /* inactive */
227 fx_trapret,
228 fx_preempt,
229 fx_setrun,
230 fx_sleep,
231 fx_tick,
232 fx_wakeup,
233 fx_donice,
234 fx_globpri,
235 fx_nullsys, /* set_process_group */
236 fx_yield,
237 fx_doprio,
238 };
239
240
241 int
242 _init()
243 {
244 return (mod_install(&modlinkage));
245 }
246
1203 /*
1204 * Prepare thread for sleep. We reset the thread priority so it will
1205 * run at the kernel priority level when it wakes up.
1206 */
1207 static void
1208 fx_sleep(kthread_t *t)
1209 {
1210 fxproc_t *fxpp = (fxproc_t *)(t->t_cldata);
1211
1212 ASSERT(t == curthread);
1213 ASSERT(THREAD_LOCK_HELD(t));
1214
1215 /*
1216 * Account for time spent on CPU before going to sleep.
1217 */
1218 (void) CPUCAPS_CHARGE(t, &fxpp->fx_caps, CPUCAPS_CHARGE_ENFORCE);
1219
1220 if (FX_HAS_CB(fxpp)) {
1221 FX_CB_SLEEP(FX_CALLB(fxpp), fxpp->fx_cookie);
1222 }
1223 }
1224
1225 /* ARGSUSED */
1226 static void
1227 fx_stop(kthread_t *t, int why, int what)
1228 {
1229 fxproc_t *fxpp = (fxproc_t *)(t->t_cldata);
1230
1231 ASSERT(THREAD_LOCK_HELD(t));
1232
1233 if (FX_HAS_CB(fxpp)) {
1234 FX_CB_STOP(FX_CALLB(fxpp), fxpp->fx_cookie);
1235 }
1236 }
1237
1238 /*
1239 * Check for time slice expiration. If time slice has expired
1240 * set runrun to cause preemption.
1241 */
1242 static void
1332 {
1333 cpu_t *cp = CPU;
1334
1335 ASSERT(THREAD_LOCK_HELD(t));
1336 ASSERT(t == curthread);
1337 ASSERT(cp->cpu_dispthread == t);
1338 ASSERT(t->t_state == TS_ONPROC);
1339 }
1340
1341
1342 /*
1343 * Processes waking up go to the back of their queue.
1344 */
1345 static void
1346 fx_wakeup(kthread_t *t)
1347 {
1348 fxproc_t *fxpp = (fxproc_t *)(t->t_cldata);
1349
1350 ASSERT(THREAD_LOCK_HELD(t));
1351
1352 if (FX_HAS_CB(fxpp)) {
1353 clock_t new_quantum = (clock_t)fxpp->fx_pquantum;
1354 pri_t newpri = fxpp->fx_pri;
1355 FX_CB_WAKEUP(FX_CALLB(fxpp), fxpp->fx_cookie,
1356 &new_quantum, &newpri);
1357 FX_ADJUST_QUANTUM(new_quantum);
1358 if ((int)new_quantum != fxpp->fx_pquantum) {
1359 fxpp->fx_pquantum = (int)new_quantum;
1360 fxpp->fx_timeleft = fxpp->fx_pquantum;
1361 }
1362
1363 FX_ADJUST_PRI(newpri);
1364 if (newpri != fxpp->fx_pri) {
1365 fxpp->fx_pri = newpri;
1366 THREAD_CHANGE_PRI(t, fx_dptbl[fxpp->fx_pri].fx_globpri);
1367 }
1368 }
1369
1370 fxpp->fx_flags &= ~FXBACKQ;
1371
|