bb9e9cd43ae72084ca137e8d9e85b7ee9fc784f1
[dragonfly.git] / sys / sys / usched.h
1 /*
2  * SYS/USCHED.H
3  *
4  *      Userland scheduler API
5  * 
6  * $DragonFly: src/sys/sys/usched.h,v 1.15 2008/04/21 15:24:47 dillon Exp $
7  */
8
9 #ifndef _SYS_USCHED_H_
10 #define _SYS_USCHED_H_
11
12 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
13
14 #ifndef _SYS_TYPES_H_
15 #include <sys/types.h>
16 #endif
17 #ifndef _SYS_QUEUE_H_
18 #include <sys/queue.h>
19 #endif
20 #ifndef _SYS_SYSTIMER_H_
21 #include <sys/systimer.h>
22 #endif
23
24 #define NAME_LENGTH 32
25
26 struct lwp;
27 struct proc;
28 struct globaldata;
29
30 struct usched {
31     TAILQ_ENTRY(usched) entry;
32     const char *name;
33     const char *desc;
34     void (*usched_register)(void);
35     void (*usched_unregister)(void);
36     void (*acquire_curproc)(struct lwp *);
37     void (*release_curproc)(struct lwp *);
38     void (*setrunqueue)(struct lwp *);
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 *);
43     void (*heuristic_exiting)(struct lwp *, struct proc *);
44     void (*uload_update)(struct lwp *);
45     void (*setcpumask)(struct usched *, cpumask_t);
46     void (*yield)(struct lwp *);
47 };
48
49 union usched_data {
50     /*
51      * BSD4 scheduler. 
52      */
53     struct {
54         short   priority;       /* lower is better */
55         char    unused01;       /* (currently not used) */
56         char    rqindex;
57         int     batch;          /* batch mode heuristic */
58         int     estcpu;         /* dynamic priority modification */
59         u_short rqtype;         /* protected copy of rtprio type */
60         u_short unused02;
61     } bsd4;
62     struct {
63         short   priority;       /* lower is better */
64         char    forked;         /* lock cpu during fork */
65         char    rqindex;
66         short   estfast;        /* fast estcpu collapse mode */
67         short   unused01;
68         int     estcpu;         /* dynamic priority modification */
69         u_short rqtype;         /* protected copy of rtprio type */
70         u_short qcpu;           /* which cpu are we enqueued on? */
71     } dfly;
72
73     int         pad[4];         /* PAD for future expansion */
74 };
75
76 /*
77  * Flags for usched_ctl()
78  */
79 #define        USCH_ADD        0x00000001
80 #define        USCH_REM        0x00000010
81
82 #endif  /* _KERNEL || _KERNEL_STRUCTURES */
83
84 #define USCHED_SET_SCHEDULER    0
85 #define USCHED_SET_CPU          1
86 #define USCHED_ADD_CPU          2
87 #define USCHED_DEL_CPU          3
88 #define USCHED_GET_CPU          4
89
90 /*
91  * Kernel variables and procedures, or user system calls.
92  */
93 #ifdef _KERNEL
94
95 extern struct usched    usched_bsd4;
96 extern struct usched    usched_dfly;
97 extern struct usched    usched_dummy;
98 extern cpumask_t usched_mastermask;
99 extern int sched_ticks; /* From sys/kern/kern_clock.c */
100
101 int usched_ctl(struct usched *, int);
102 struct usched *usched_init(void);
103 void usched_schedulerclock(struct lwp *, sysclock_t, sysclock_t);
104
105 #endif
106
107 #if !defined(_KERNEL) || defined(_KERNEL_VIRTUAL)
108
109 int usched_set(pid_t, int, void *, int);
110
111 #endif
112
113 #endif
114