257 */
258
259 static pri_t fss_init(id_t, int, classfuncs_t **);
260
261 static struct sclass fss = {
262 "FSS",
263 fss_init,
264 0
265 };
266
267 extern struct mod_ops mod_schedops;
268
269 /*
270 * Module linkage information for the kernel.
271 */
272 static struct modlsched modlsched = {
273 &mod_schedops, "fair share scheduling class", &fss
274 };
275
276 static struct modlinkage modlinkage = {
277 MODREV_1, (void *)&modlsched, NULL
278 };
279
280 #define FSS_MAXUPRI 60
281
282 /*
283 * The fssproc_t structures are kept in an array of circular doubly linked
284 * lists. A hash on the thread pointer is used to determine which list each
285 * thread should be placed in. Each list has a dummy "head" which is never
286 * removed, so the list is never empty. fss_update traverses these lists to
287 * update the priorities of threads that have been waiting on the run queue.
288 */
289 #define FSS_LISTS 16 /* number of lists, must be power of 2 */
290 #define FSS_LIST_HASH(t) (((uintptr_t)(t) >> 9) & (FSS_LISTS - 1))
291 #define FSS_LIST_NEXT(i) (((i) + 1) & (FSS_LISTS - 1))
292
293 #define FSS_LIST_INSERT(fssproc) \
294 { \
295 int index = FSS_LIST_HASH(fssproc->fss_tp); \
296 kmutex_t *lockp = &fss_listlock[index]; \
297 fssproc_t *headp = &fss_listhead[index]; \
378 static void fss_stop(kthread_t *, int, int);
379 static void fss_exit(kthread_t *);
380 static void fss_active(kthread_t *);
381 static void fss_inactive(kthread_t *);
382 static pri_t fss_swapin(kthread_t *, int);
383 static pri_t fss_swapout(kthread_t *, int);
384 static void fss_trapret(kthread_t *);
385 static void fss_preempt(kthread_t *);
386 static void fss_setrun(kthread_t *);
387 static void fss_sleep(kthread_t *);
388 static void fss_tick(kthread_t *);
389 static void fss_wakeup(kthread_t *);
390 static int fss_donice(kthread_t *, cred_t *, int, int *);
391 static int fss_doprio(kthread_t *, cred_t *, int, int *);
392 static pri_t fss_globpri(kthread_t *);
393 static void fss_yield(kthread_t *);
394 static void fss_nullsys();
395
396 static struct classfuncs fss_classfuncs = {
397 /* class functions */
398 fss_admin,
399 fss_getclinfo,
400 fss_parmsin,
401 fss_parmsout,
402 fss_vaparmsin,
403 fss_vaparmsout,
404 fss_getclpri,
405 fss_alloc,
406 fss_free,
407
408 /* thread functions */
409 fss_enterclass,
410 fss_exitclass,
411 fss_canexit,
412 fss_fork,
413 fss_forkret,
414 fss_parmsget,
415 fss_parmsset,
416 fss_stop,
417 fss_exit,
418 fss_active,
419 fss_inactive,
420 fss_swapin,
421 fss_swapout,
422 fss_trapret,
423 fss_preempt,
424 fss_setrun,
425 fss_sleep,
426 fss_tick,
427 fss_wakeup,
428 fss_donice,
429 fss_globpri,
430 fss_nullsys, /* set_process_group */
431 fss_yield,
432 fss_doprio,
433 };
434
435 int
436 _init()
437 {
438 return (mod_install(&modlinkage));
439 }
440
441 int
442 _fini()
443 {
444 return (EBUSY);
445 }
446
447 int
448 _info(struct modinfo *modinfop)
449 {
450 return (mod_info(&modlinkage, modinfop));
451 }
452
|
257 */
258
259 static pri_t fss_init(id_t, int, classfuncs_t **);
260
261 static struct sclass fss = {
262 "FSS",
263 fss_init,
264 0
265 };
266
267 extern struct mod_ops mod_schedops;
268
269 /*
270 * Module linkage information for the kernel.
271 */
272 static struct modlsched modlsched = {
273 &mod_schedops, "fair share scheduling class", &fss
274 };
275
276 static struct modlinkage modlinkage = {
277 MODREV_1, { (void *)&modlsched, NULL }
278 };
279
280 #define FSS_MAXUPRI 60
281
282 /*
283 * The fssproc_t structures are kept in an array of circular doubly linked
284 * lists. A hash on the thread pointer is used to determine which list each
285 * thread should be placed in. Each list has a dummy "head" which is never
286 * removed, so the list is never empty. fss_update traverses these lists to
287 * update the priorities of threads that have been waiting on the run queue.
288 */
289 #define FSS_LISTS 16 /* number of lists, must be power of 2 */
290 #define FSS_LIST_HASH(t) (((uintptr_t)(t) >> 9) & (FSS_LISTS - 1))
291 #define FSS_LIST_NEXT(i) (((i) + 1) & (FSS_LISTS - 1))
292
293 #define FSS_LIST_INSERT(fssproc) \
294 { \
295 int index = FSS_LIST_HASH(fssproc->fss_tp); \
296 kmutex_t *lockp = &fss_listlock[index]; \
297 fssproc_t *headp = &fss_listhead[index]; \
378 static void fss_stop(kthread_t *, int, int);
379 static void fss_exit(kthread_t *);
380 static void fss_active(kthread_t *);
381 static void fss_inactive(kthread_t *);
382 static pri_t fss_swapin(kthread_t *, int);
383 static pri_t fss_swapout(kthread_t *, int);
384 static void fss_trapret(kthread_t *);
385 static void fss_preempt(kthread_t *);
386 static void fss_setrun(kthread_t *);
387 static void fss_sleep(kthread_t *);
388 static void fss_tick(kthread_t *);
389 static void fss_wakeup(kthread_t *);
390 static int fss_donice(kthread_t *, cred_t *, int, int *);
391 static int fss_doprio(kthread_t *, cred_t *, int, int *);
392 static pri_t fss_globpri(kthread_t *);
393 static void fss_yield(kthread_t *);
394 static void fss_nullsys();
395
396 static struct classfuncs fss_classfuncs = {
397 /* class functions */
398 { fss_admin,
399 fss_getclinfo,
400 fss_parmsin,
401 fss_parmsout,
402 fss_vaparmsin,
403 fss_vaparmsout,
404 fss_getclpri,
405 fss_alloc,
406 fss_free },
407
408 /* thread functions */
409 { fss_enterclass,
410 fss_exitclass,
411 fss_canexit,
412 fss_fork,
413 fss_forkret,
414 fss_parmsget,
415 fss_parmsset,
416 fss_stop,
417 fss_exit,
418 fss_active,
419 fss_inactive,
420 fss_swapin,
421 fss_swapout,
422 fss_trapret,
423 fss_preempt,
424 fss_setrun,
425 fss_sleep,
426 fss_tick,
427 fss_wakeup,
428 fss_donice,
429 fss_globpri,
430 fss_nullsys, /* set_process_group */
431 fss_yield,
432 fss_doprio },
433 };
434
435 int
436 _init()
437 {
438 return (mod_install(&modlinkage));
439 }
440
441 int
442 _fini()
443 {
444 return (EBUSY);
445 }
446
447 int
448 _info(struct modinfo *modinfop)
449 {
450 return (mod_info(&modlinkage, modinfop));
451 }
452
|