usched_bsd4 - Topology-aware scheduling
[dragonfly.git] / sys / sys / usched.h
CommitLineData
a77ac49d
MD
1/*
2 * SYS/USCHED.H
3 *
4 * Userland scheduler API
5 *
c3149361 6 * $DragonFly: src/sys/sys/usched.h,v 1.15 2008/04/21 15:24:47 dillon Exp $
a77ac49d
MD
7 */
8
9#ifndef _SYS_USCHED_H_
10#define _SYS_USCHED_H_
11
cb7f4ab1
MD
12#if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
13
1bd40720
MD
14#ifndef _SYS_TYPES_H_
15#include <sys/types.h>
16#endif
a77ac49d
MD
17#ifndef _SYS_QUEUE_H_
18#include <sys/queue.h>
19#endif
1bd40720
MD
20#ifndef _SYS_SYSTIMER_H_
21#include <sys/systimer.h>
22#endif
a77ac49d 23
1b31454e
DR
24#define NAME_LENGTH 32
25
1bd40720 26struct lwp;
a77ac49d
MD
27struct proc;
28struct globaldata;
29
30struct usched {
31 TAILQ_ENTRY(usched) entry;
32 const char *name;
33 const char *desc;
cb7f4ab1
MD
34 void (*usched_register)(void);
35 void (*usched_unregister)(void);
553ea3c8
SS
36 void (*acquire_curproc)(struct lwp *);
37 void (*release_curproc)(struct lwp *);
553ea3c8 38 void (*setrunqueue)(struct lwp *);
553ea3c8
SS
39 void (*schedulerclock)(struct lwp *, sysclock_t, sysclock_t);
40 void (*recalculate)(struct lwp *);
41 void (*resetpriority)(struct lwp *);
42 void (*heuristic_forking)(struct lwp *, struct lwp *);
52cac9fb 43 void (*heuristic_exiting)(struct lwp *, struct proc *);
cb7f4ab1 44 void (*setcpumask)(struct usched *, cpumask_t);
c3149361 45 void (*yield)(struct lwp *);
352f5709
MD
46};
47
48union usched_data {
49 /*
50 * BSD4 scheduler.
51 */
52 struct {
53 short priority; /* lower is better */
52eedfb5 54 char unused01; /* (currently not used) */
352f5709 55 char rqindex;
52cac9fb 56 int batch; /* batch mode heuristic */
dcc99b62 57 int estcpu; /* dynamic priority modification */
52eedfb5
MD
58 u_short rqtype; /* protected copy of rtprio type */
59 u_short unused02;
352f5709
MD
60 } bsd4;
61
62 int pad[4]; /* PAD for future expansion */
a77ac49d
MD
63};
64
cb7f4ab1
MD
65/*
66 * Flags for usched_ctl()
67 */
68#define USCH_ADD 0x00000001
69#define USCH_REM 0x00000010
70
71#endif /* _KERNEL || _KERNEL_STRUCTURES */
72
a60ccb85
DX
73#define USCHED_SET_SCHEDULER 0
74#define USCHED_SET_CPU 1
75#define USCHED_ADD_CPU 2
76#define USCHED_DEL_CPU 3
dcf3266e 77#define USCHED_GET_CPU 4
a60ccb85 78
cb7f4ab1
MD
79/*
80 * Kernel variables and procedures, or user system calls.
81 */
82#ifdef _KERNEL
83
a77ac49d 84extern struct usched usched_bsd4;
52eedfb5 85extern struct usched usched_dummy;
a5ae2446 86extern cpumask_t usched_mastermask;
d6d39bc7 87extern int sched_ticks; /* From sys/kern/kern_clock.c */
a77ac49d 88
cb7f4ab1
MD
89int usched_ctl(struct usched *, int);
90struct usched *usched_init(void);
91
702acf06
JT
92#endif
93
94#if !defined(_KERNEL) || defined(_KERNEL_VIRTUAL)
cb7f4ab1 95
a60ccb85 96int usched_set(pid_t, int, void *, int);
cb7f4ab1
MD
97
98#endif
99
a77ac49d
MD
100#endif
101