4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
30 #include <sys/types.h>
31 #include <sys/param.h>
32 #include <sys/sysmacros.h>
33 #include <sys/signal.h>
36 #include <sys/systm.h>
37 #include <sys/sysinfo.h>
39 #include <sys/errno.h>
40 #include <sys/cmn_err.h>
42 #include <sys/debug.h>
43 #include <sys/inline.h>
45 #include <sys/class.h>
47 #include <sys/cpuvar.h>
48 #include <sys/priocntl.h>
51 * Class specific code for the sys class. There are no
52 * class specific data structures associated with
53 * the sys class and the scheduling policy is trivially
54 * simple. There is no time slicing.
57 pri_t
sys_init(id_t
, int, classfuncs_t
**);
58 static int sys_getclpri(pcpri_t
*);
59 static int sys_fork(kthread_t
*, kthread_t
*, void *);
60 static int sys_enterclass(kthread_t
*, id_t
, void *, cred_t
*, void *);
61 static int sys_canexit(kthread_t
*, cred_t
*);
62 static int sys_nosys();
63 static int sys_donice(kthread_t
*, cred_t
*, int, int *);
64 static int sys_doprio(kthread_t
*, cred_t
*, int, int *);
65 static void sys_forkret(kthread_t
*, kthread_t
*);
66 static void sys_nullsys();
67 static int sys_alloc(void **, int);
69 struct classfuncs sys_classfuncs
= {
70 /* messages to class manager */
72 sys_nosys
, /* admin */
73 sys_nosys
, /* getclinfo */
74 sys_nosys
, /* parmsin */
75 sys_nosys
, /* parmsout */
76 sys_nosys
, /* vaparmsin */
77 sys_nosys
, /* vaparmsout */
78 sys_getclpri
, /* getclpri */
80 sys_nullsys
, /* free */
82 /* operations on threads */
84 sys_enterclass
, /* enterclass */
85 sys_nullsys
, /* exitclass */
88 sys_forkret
, /* forkret */
89 sys_nullsys
, /* parmsget */
90 sys_nosys
, /* parmsset */
91 sys_nullsys
, /* stop */
92 sys_nullsys
, /* exit */
93 sys_nullsys
, /* active */
94 sys_nullsys
, /* inactive */
95 sys_nullsys
, /* trapret */
96 setfrontdq
, /* preempt */
97 setbackdq
, /* setrun */
98 sys_nullsys
, /* sleep */
99 sys_nullsys
, /* tick */
100 setbackdq
, /* wakeup */
102 (pri_t (*)())sys_nosys
, /* globpri */
103 sys_nullsys
, /* set_process_group */
104 sys_nullsys
, /* yield */
113 sys_init(cid
, clparmsz
, clfuncspp
)
116 classfuncs_t
**clfuncspp
;
118 *clfuncspp
= &sys_classfuncs
;
119 return ((pri_t
)v
.v_maxsyspri
);
123 * Get maximum and minimum priorities enjoyed by sysclass threads
126 sys_getclpri(pcpri_t
*pcprip
)
128 pcprip
->pc_clpmax
= maxclsyspri
;
129 pcprip
->pc_clpmin
= minclsyspri
;
135 sys_enterclass(t
, cid
, parmsp
, reqpcredp
, bufp
)
147 sys_canexit(kthread_t
*t
, cred_t
*reqpcredp
)
154 sys_fork(t
, ct
, bufp
)
160 * No class specific data structure
172 register proc_t
*pp
= ttoproc(t
);
173 register proc_t
*cp
= ttoproc(ct
);
175 ASSERT(t
== curthread
);
176 ASSERT(MUTEX_HELD(&pidlock
));
179 * Grab the child's p_lock before dropping pidlock to ensure
180 * the process does not disappear before we set it running.
182 mutex_enter(&cp
->p_lock
);
183 mutex_exit(&pidlock
);
185 mutex_exit(&cp
->p_lock
);
187 mutex_enter(&pp
->p_lock
);
189 mutex_exit(&pp
->p_lock
);
206 sys_donice(kthread_t
*t
, cred_t
*cr
, int incr
, int *retvalp
)
213 sys_doprio(kthread_t
*t
, cred_t
*cr
, int incr
, int *retvalp
)
220 sys_alloc(void **p
, int flag
)