summaryrefslogtreecommitdiffstats
path: root/sys/sys/sched.h
diff options
context:
space:
mode:
authorart <art@openbsd.org>2004-06-21 23:12:14 +0000
committerart <art@openbsd.org>2004-06-21 23:12:14 +0000
commit346b4f84f5d8ddb9fac738f6f10892d9ce9774a8 (patch)
treedf0ea559b60b4cab1372d5a4f310a8ceda72f0af /sys/sys/sched.h
parentdon't send UDP encapsulated packets w/o UDP header if encap is disabled; ok ho@ (diff)
downloadwireguard-openbsd-346b4f84f5d8ddb9fac738f6f10892d9ce9774a8.tar.xz
wireguard-openbsd-346b4f84f5d8ddb9fac738f6f10892d9ce9774a8.zip
Put back the moving of schedstate_percpu into sched.h. This time expose
it to userland so that i386 builds (other architectures didn't show the problem). deraadt@ ok
Diffstat (limited to 'sys/sys/sched.h')
-rw-r--r--sys/sys/sched.h64
1 files changed, 41 insertions, 23 deletions
diff --git a/sys/sys/sched.h b/sys/sys/sched.h
index 65a35b4e7cd..97c68dce08b 100644
--- a/sys/sys/sched.h
+++ b/sys/sys/sched.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sched.h,v 1.8 2004/06/20 08:25:30 deraadt Exp $ */
+/* $OpenBSD: sched.h,v 1.9 2004/06/21 23:12:14 art Exp $ */
/* $NetBSD: sched.h,v 1.2 1999/02/28 18:14:58 ross Exp $ */
/*-
@@ -80,8 +80,40 @@
* Posix defines a <sched.h> which may want to include <sys/sched.h>
*/
+/*
+ * CPU states.
+ * XXX Not really scheduler state, but no other good place to put
+ * it right now, and it really is per-CPU.
+ */
+#define CP_USER 0
+#define CP_NICE 1
+#define CP_SYS 2
+#define CP_INTR 3
+#define CP_IDLE 4
+#define CPUSTATES 5
+
+/*
+ * Per-CPU scheduler state.
+ * XXX - expose to userland for now.
+ */
+struct schedstate_percpu {
+ struct timeval spc_runtime; /* time curproc started running */
+ __volatile int spc_schedflags; /* flags; see below */
+ u_int spc_schedticks; /* ticks for schedclock() */
+ u_int64_t spc_cp_time[CPUSTATES]; /* CPU state statistics */
+ u_char spc_curpriority; /* usrpri of curproc */
+ int spc_rrticks; /* ticks until roundrobin() */
+ int spc_pscnt; /* prof/stat counter */
+ int spc_psdiv; /* prof/stat divisor */
+};
+
#ifdef _KERNEL
+/* spc_flags */
+#define SPCF_SEENRR 0x0001 /* process has seen roundrobin() */
+#define SPCF_SHOULDYIELD 0x0002 /* process should yield the CPU */
+#define SPCF_SWITCHCLEAR (SPCF_SEENRR|SPCF_SHOULDYIELD)
+
#define PPQ (128 / NQS) /* priorities per queue */
#define NICE_WEIGHT 2 /* priorities per nice level */
#define ESTCPULIM(e) min((e), NICE_WEIGHT * PRIO_MAX - PPQ)
@@ -89,36 +121,22 @@
extern int schedhz; /* ideally: 16 */
extern int rrticks_init; /* ticks per roundrobin() */
-#ifdef _SYS_PROC_H_
+struct proc;
void schedclock(struct proc *);
#ifdef __HAVE_CPUINFO
+struct cpu_info;
void roundrobin(struct cpu_info *);
#endif
-static __inline void scheduler_fork_hook(
- struct proc *parent, struct proc *child);
-static __inline void scheduler_wait_hook(
- struct proc *parent, struct proc *child);
/* Inherit the parent's scheduler history */
-
-static __inline void
-scheduler_fork_hook(parent, child)
- struct proc *parent, *child;
-{
- child->p_estcpu = parent->p_estcpu;
-}
+#define scheduler_fork_hook(parent, child) do { \
+ (child)->p_estcpu = (parent)->p_estcpu; \
+} while (0)
/* Chargeback parents for the sins of their children. */
-
-static __inline void
-scheduler_wait_hook(parent, child)
- struct proc *parent, *child;
-{
- /* XXX just return if parent == init?? */
-
- parent->p_estcpu = ESTCPULIM(parent->p_estcpu + child->p_estcpu);
-}
-#endif /* _SYS_PROC_H_ */
+#define scheduler_wait_hook(parent, child) do { \
+ (parent)->p_estcpu = ESTCPULIM((parent)->p_estcpu + (child)->p_estcpu);\
+} while (0)
#ifndef splsched
#define splsched() splhigh()