Merge from vendor branch OPENSSH:
[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.7 2005/11/16 02:24:33 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_QUEUE_H_
15 #include <sys/queue.h>
16 #endif
17
18 struct proc;
19 struct globaldata;
20
21 struct usched {
22     TAILQ_ENTRY(usched) entry;
23     const char *name;
24     const char *desc;
25     void (*usched_register)(void);
26     void (*usched_unregister)(void);
27     void (*acquire_curproc)(struct lwp *);
28     void (*release_curproc)(struct lwp *);
29     void (*select_curproc)(struct globaldata *);
30     void (*setrunqueue)(struct lwp *);
31     void (*remrunqueue)(struct lwp *);
32     void (*schedulerclock)(struct lwp *, sysclock_t, sysclock_t);
33     void (*recalculate)(struct lwp *);
34     void (*resetpriority)(struct lwp *);
35     void (*heuristic_forking)(struct lwp *, struct lwp *);
36     void (*heuristic_exiting)(struct lwp *, struct lwp *);
37     void (*setcpumask)(struct usched *, cpumask_t);
38 };
39
40 union usched_data {
41     /*
42      * BSD4 scheduler. 
43      */
44     struct {
45         short   priority;       /* lower is better */
46         char    interactive;    /* (currently not used) */
47         char    rqindex;
48         int     origcpu;
49         int     estcpu;         /* dynamic priority modification */
50     } bsd4;
51
52     int         pad[4];         /* PAD for future expansion */
53 };
54
55 /*
56  * Flags for usched_ctl()
57  */
58 #define        USCH_ADD        0x00000001
59 #define        USCH_REM        0x00000010
60
61 #endif  /* _KERNEL || _KERNEL_STRUCTURES */
62
63 /*
64  * Kernel variables and procedures, or user system calls.
65  */
66 #ifdef _KERNEL
67
68 extern struct usched    usched_bsd4;
69
70 int usched_ctl(struct usched *, int);
71 struct usched *usched_init(void);
72
73 #else
74
75 int usched_set(const char *, int);
76
77 #endif
78
79 #endif
80