sched.h revision 159570
193139Sru/*- 2146515Sru * Copyright (c) 2002, Jeffrey Roberson <jeff@freebsd.org> 393139Sru * All rights reserved. 4146515Sru * 593139Sru * Redistribution and use in source and binary forms, with or without 693139Sru * modification, are permitted provided that the following conditions 793139Sru * are met: 893139Sru * 1. Redistributions of source code must retain the above copyright 993139Sru * notice unmodified, this list of conditions, and the following 1093139Sru * disclaimer. 1193139Sru * 2. Redistributions in binary form must reproduce the above copyright 1293139Sru * notice, this list of conditions and the following disclaimer in the 1393139Sru * documentation and/or other materials provided with the distribution. 1493139Sru * 1593139Sru * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1693139Sru * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1793139Sru * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1893139Sru * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1993139Sru * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20114472Sru * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2193139Sru * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2293139Sru * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2393139Sru * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2493139Sru * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25146515Sru * 26146515Sru * $FreeBSD: head/sys/sys/sched.h 159570 2006-06-13 13:12:56Z davidxu $ 2793139Sru */ 2893139Sru 2993139Sru#ifndef _SYS_SCHED_H_ 3093139Sru#define _SYS_SCHED_H_ 3193139Sru 3293139Sru/* 3393139Sru * General scheduling info. 3493139Sru * 3593139Sru * sched_load: 3693139Sru * Total runnable non-ithread threads in the system. 3793139Sru * 3893139Sru * sched_runnable: 3993139Sru * Runnable threads for this processor. 4093139Sru */ 41146515Sruint sched_load(void); 4293139Sruint sched_rr_interval(void); 4393139Sruint sched_runnable(void); 4493139Sru 45146515Sru/* 46146515Sru * Proc related scheduling hooks. 47146515Sru */ 48146515Sruvoid sched_exit(struct proc *p, struct thread *childtd); 49146515Sruvoid sched_fork(struct thread *td, struct thread *childtd); 5093139Sru 51146515Sru/* 52146515Sru * KSE Groups contain scheduling priority information. They record the 53146515Sru * behavior of groups of KSEs and threads. 54146515Sru */ 5593139Sruvoid sched_class(struct ksegrp *kg, int class); 56146515Sruvoid sched_exit_ksegrp(struct ksegrp *kg, struct thread *childtd); 57146515Sruvoid sched_fork_ksegrp(struct thread *td, struct ksegrp *child); 58146515Sruvoid sched_nice(struct proc *p, int nice); 59146515Sru 6093139Sru/* 61146515Sru * Threads are switched in and out, block on resources, have temporary 62146515Sru * priorities inherited from their ksegs, and use up cpu time. 63146515Sru */ 64146515Sruvoid sched_exit_thread(struct thread *td, struct thread *child); 65146515Sruvoid sched_fork_thread(struct thread *td, struct thread *child); 6693139Srufixpt_t sched_pctcpu(struct thread *td); 67146515Sruvoid sched_prio(struct thread *td, u_char prio); 68146515Sruvoid sched_lend_prio(struct thread *td, u_char prio); 69146515Sruvoid sched_sleep(struct thread *td); 70146515Sruvoid sched_switch(struct thread *td, struct thread *newtd, int flags); 7193139Sruvoid sched_unlend_prio(struct thread *td, u_char prio); 72146515Sruvoid sched_userret(struct thread *td); 73146515Sruvoid sched_wakeup(struct thread *td); 74146515Sru 75146515Sru/* 76146515Sru * Threads are moved on and off of run queues 7793139Sru */ 78146515Sruvoid sched_add(struct thread *td, int flags); 79146515Sruvoid sched_clock(struct thread *td); 80146515Sruvoid sched_rem(struct thread *td); 81146515Sruvoid sched_tick(void); 8293139Sru 83146515Sru/* 84146515Sru * Binding makes cpu affinity permanent while pinning is used to temporarily 85146515Sru * hold a thread on a particular CPU. 86146515Sru */ 87146515Sruvoid sched_bind(struct thread *td, int cpu); 88146515Srustatic __inline void sched_pin(void); 89146515Sruvoid sched_unbind(struct thread *td); 9093139Srustatic __inline void sched_unpin(void); 91146515Sruint sched_is_bound(struct thread *td); 92146515Sru 93146515Sru/* 9493139Sru * These procedures tell the process data structure allocation code how 95146515Sru * many bytes to actually allocate. 96146515Sru */ 97146515Sruint sched_sizeof_ksegrp(void); 9893139Sruint sched_sizeof_proc(void); 99146515Sruint sched_sizeof_thread(void); 100146515Sru 101146515Srustatic __inline void 102146515Srusched_pin(void) 103146515Sru{ 104146515Sru curthread->td_pinned++; 105146515Sru} 106146515Sru 107146515Srustatic __inline void 108146515Srusched_unpin(void) 109146515Sru{ 110146515Sru curthread->td_pinned--; 111146515Sru} 112146515Sru 113146515Sru/* temporarily here */ 114146515Sruvoid schedinit(void); 115146515Sruvoid sched_init_concurrency(struct ksegrp *kg); 116146515Sruvoid sched_set_concurrency(struct ksegrp *kg, int cuncurrency); 117146515Sruvoid sched_schedinit(void); 118146515Sruvoid sched_newproc(struct proc *p, struct ksegrp *kg, struct thread *td); 119146515Sruvoid sched_thread_exit(struct thread *td); 120146515Sruvoid sched_newthread(struct thread *td); 12193139Sru 122146515Sru#endif /* !_SYS_SCHED_H_ */ 12393139Sru