sched.h revision 121127
1104964Sjeff/*- 2104964Sjeff * Copyright (c) 2002, Jeffrey Roberson <jeff@freebsd.org> 3104964Sjeff * All rights reserved. 4104964Sjeff * 5104964Sjeff * Redistribution and use in source and binary forms, with or without 6104964Sjeff * modification, are permitted provided that the following conditions 7104964Sjeff * are met: 8104964Sjeff * 1. Redistributions of source code must retain the above copyright 9104964Sjeff * notice unmodified, this list of conditions, and the following 10104964Sjeff * disclaimer. 11104964Sjeff * 2. Redistributions in binary form must reproduce the above copyright 12104964Sjeff * notice, this list of conditions and the following disclaimer in the 13104964Sjeff * documentation and/or other materials provided with the distribution. 14104964Sjeff * 15104964Sjeff * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16104964Sjeff * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17104964Sjeff * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18104964Sjeff * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19104964Sjeff * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20104964Sjeff * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21104964Sjeff * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22104964Sjeff * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23104964Sjeff * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24104964Sjeff * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25104964Sjeff * 26104964Sjeff * $FreeBSD: head/sys/sys/sched.h 121127 2003-10-16 08:39:15Z jeff $ 27104964Sjeff */ 28104964Sjeff 29104964Sjeff#ifndef _SYS_SCHED_H_ 30104964Sjeff#define _SYS_SCHED_H_ 31104964Sjeff 32104964Sjeff/* 33104964Sjeff * General scheduling info. 34104964Sjeff */ 35104964Sjeffint sched_rr_interval(void); 36104964Sjeffint sched_runnable(void); 37104964Sjeff 38113355Sjeff/* 39113355Sjeff * Proc related scheduling hooks. 40113355Sjeff */ 41113355Sjeffvoid sched_exit(struct proc *p, struct proc *child); 42113355Sjeffvoid sched_fork(struct proc *p, struct proc *child); 43113355Sjeff 44104964Sjeff/* 45104964Sjeff * KSE Groups contain scheduling priority information. They record the 46104964Sjeff * behavior of groups of KSEs and threads. 47104964Sjeff */ 48113355Sjeffvoid sched_class(struct ksegrp *kg, int class); 49113355Sjeffvoid sched_exit_ksegrp(struct ksegrp *kg, struct ksegrp *child); 50113355Sjeffvoid sched_fork_ksegrp(struct ksegrp *kg, struct ksegrp *child); 51104964Sjeffvoid sched_nice(struct ksegrp *kg, int nice); 52104964Sjeff 53104964Sjeff/* 54104964Sjeff * Threads are switched in and out, block on resources, and have temporary 55104964Sjeff * priorities inherited from their ksegs. 56104964Sjeff */ 57113355Sjeffvoid sched_exit_thread(struct thread *td, struct thread *child); 58113355Sjeffvoid sched_fork_thread(struct thread *td, struct thread *child); 59113355Sjeffvoid sched_prio(struct thread *td, u_char prio); 60104964Sjeffvoid sched_sleep(struct thread *td, u_char prio); 61104964Sjeffvoid sched_switchin(struct thread *td); 62104964Sjeffvoid sched_switchout(struct thread *td); 63113355Sjeffvoid sched_userret(struct thread *td); 64104964Sjeffvoid sched_wakeup(struct thread *td); 65104964Sjeff 66104964Sjeff/* 67104964Sjeff * KSEs are moved on and off of run queues. 68104964Sjeff */ 69121127Sjeffvoid sched_add(struct thread *td); 70113355Sjeffstruct kse *sched_choose(void); 71121127Sjeffvoid sched_clock(struct thread *td); 72113355Sjeffvoid sched_exit_kse(struct kse *ke, struct kse *child); 73113355Sjeffvoid sched_fork_kse(struct kse *ke, struct kse *child); 74121127Sjeffvoid sched_rem(struct thread *td); 75104964Sjeff 76107126Sjeff/* 77107137Sjeff * and they use up cpu time. 78107137Sjeff */ 79121127Sjefffixpt_t sched_pctcpu(struct thread *td); 80107137Sjeff 81107137Sjeff/* 82107126Sjeff * These procedures tell the process data structure allocation code how 83107126Sjeff * many bytes to actually allocate. 84107126Sjeff */ 85107126Sjeffint sched_sizeof_kse(void); 86107126Sjeffint sched_sizeof_ksegrp(void); 87107126Sjeffint sched_sizeof_proc(void); 88107126Sjeffint sched_sizeof_thread(void); 89107126Sjeff 90107126Sjeffextern struct ke_sched *kse0_sched; 91107126Sjeffextern struct kg_sched *ksegrp0_sched; 92107126Sjeffextern struct p_sched *proc0_sched; 93107126Sjeffextern struct td_sched *thread0_sched; 94107126Sjeff 95104964Sjeff#endif /* !_SYS_SCHED_H_ */ 96