sched.h revision 135076
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 135076 2004-09-11 10:07:22Z scottl $ 27104964Sjeff */ 28104964Sjeff 29104964Sjeff#ifndef _SYS_SCHED_H_ 30104964Sjeff#define _SYS_SCHED_H_ 31104964Sjeff 32104964Sjeff/* 33104964Sjeff * General scheduling info. 34125287Sjeff * 35125287Sjeff * sched_load: 36125287Sjeff * Total runnable non-ithread threads in the system. 37125287Sjeff * 38125287Sjeff * sched_runnable: 39125287Sjeff * Runnable threads for this processor. 40104964Sjeff */ 41125287Sjeffint sched_load(void); 42104964Sjeffint sched_rr_interval(void); 43104964Sjeffint sched_runnable(void); 44104964Sjeff 45113355Sjeff/* 46113355Sjeff * Proc related scheduling hooks. 47113355Sjeff */ 48132372Sjulianvoid sched_exit(struct proc *p, struct thread *childtd); 49134791Sjulianvoid sched_fork(struct thread *td, struct thread *childtd); 50113355Sjeff 51104964Sjeff/* 52104964Sjeff * KSE Groups contain scheduling priority information. They record the 53104964Sjeff * behavior of groups of KSEs and threads. 54104964Sjeff */ 55113355Sjeffvoid sched_class(struct ksegrp *kg, int class); 56132372Sjulianvoid sched_exit_ksegrp(struct ksegrp *kg, struct thread *childtd); 57132372Sjulianvoid sched_fork_ksegrp(struct thread *td, struct ksegrp *child); 58130551Sjulianvoid sched_nice(struct proc *p, int nice); 59104964Sjeff 60104964Sjeff/* 61122036Sjeff * Threads are switched in and out, block on resources, have temporary 62122036Sjeff * priorities inherited from their ksegs, and use up cpu time. 63104964Sjeff */ 64113355Sjeffvoid sched_exit_thread(struct thread *td, struct thread *child); 65113355Sjeffvoid sched_fork_thread(struct thread *td, struct thread *child); 66122036Sjefffixpt_t sched_pctcpu(struct thread *td); 67113355Sjeffvoid sched_prio(struct thread *td, u_char prio); 68126326Sjhbvoid sched_sleep(struct thread *td); 69135051Sjulianvoid sched_switch(struct thread *td, struct thread *newtd, int flags); 70113355Sjeffvoid sched_userret(struct thread *td); 71104964Sjeffvoid sched_wakeup(struct thread *td); 72104964Sjeff 73104964Sjeff/* 74122036Sjeff * Threads are moved on and off of run queues 75104964Sjeff */ 76134586Sjulianvoid sched_add(struct thread *td, int flags); 77121127Sjeffvoid sched_clock(struct thread *td); 78121127Sjeffvoid sched_rem(struct thread *td); 79104964Sjeff 80107126Sjeff/* 81122036Sjeff * Binding makes cpu affinity permanent while pinning is used to temporarily 82122036Sjeff * hold a thread on a particular CPU. 83107137Sjeff */ 84122036Sjeffvoid sched_bind(struct thread *td, int cpu); 85135076Sscottlstatic __inline void sched_pin(void); 86122036Sjeffvoid sched_unbind(struct thread *td); 87135076Sscottlstatic __inline void sched_unpin(void); 88107137Sjeff 89135056Sjulian 90122036Sjeff/* 91107126Sjeff * These procedures tell the process data structure allocation code how 92107126Sjeff * many bytes to actually allocate. 93107126Sjeff */ 94107126Sjeffint sched_sizeof_ksegrp(void); 95107126Sjeffint sched_sizeof_proc(void); 96107126Sjeffint sched_sizeof_thread(void); 97107126Sjeff 98135076Sscottlstatic __inline void 99135076Sscottlsched_pin(void) 100135076Sscottl{ 101135076Sscottl curthread->td_pinned++; 102135076Sscottl} 103135076Sscottl 104135076Sscottlstatic __inline void 105135076Sscottlsched_unpin(void) 106135076Sscottl{ 107135076Sscottl curthread->td_pinned--; 108135076Sscottl} 109135076Sscottl 110134791Sjulian/* temporarily here */ 111134791Sjulianvoid schedinit(void); 112134791Sjulianvoid sched_destroyproc(struct proc *p); 113134791Sjulianvoid sched_init_concurrency(struct ksegrp *kg); 114134791Sjulianvoid sched_set_concurrency(struct ksegrp *kg, int cuncurrency); 115134791Sjulianvoid sched_schedinit(void); 116134791Sjulianvoid sched_newproc(struct proc *p, struct ksegrp *kg, struct thread *td); 117134791Sjulianvoid sched_thread_exit(struct thread *td); 118134791Sjulianvoid sched_newthread(struct thread *td); 119104964Sjeff#endif /* !_SYS_SCHED_H_ */ 120