summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2009-04-03 09:29:16 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2009-04-03 09:29:16 +0000
commite4df77f03a368ba0deaac527960a8bab6cef77c1 (patch)
treeb8cc22bf63e9a33016e7c6bafb0f90586aaee080 /sys
parent39f97fc6ec43587a094733fca5d740e3e1e31cdf (diff)
sched_peg_curproc_to_cpu() - function to force a proc to stay on a cpu
forever.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_sched.c28
-rw-r--r--sys/sys/proc.h3
-rw-r--r--sys/sys/sched.h3
3 files changed, 31 insertions, 3 deletions
diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c
index 1b921159985..29dd5793efe 100644
--- a/sys/kern/kern_sched.c
+++ b/sys/kern/kern_sched.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sched.c,v 1.9 2009/03/23 13:25:11 art Exp $ */
+/* $OpenBSD: kern_sched.c,v 1.10 2009/04/03 09:29:15 art Exp $ */
/*
* Copyright (c) 2007, 2008 Artur Grabowski <art@openbsd.org>
*
@@ -291,6 +291,12 @@ sched_choosecpu(struct proc *p)
struct cpu_info *ci;
struct cpuset set;
+ /*
+ * If pegged to a cpu, don't allow it to move.
+ */
+ if (p->p_flag & P_CPUPEG)
+ return;
+
sched_choose++;
/*
@@ -482,6 +488,26 @@ sched_proc_to_cpu_cost(struct cpu_info *ci, struct proc *p)
}
/*
+ * Peg a proc to a cpu.
+ */
+void
+sched_peg_curproc(struct cpu_info *ci)
+{
+ struct proc *p = curproc;
+ int s;
+
+ SCHED_LOCK(s);
+ p->p_priority = p->p_usrpri;
+ p->p_stat = SRUN;
+ p->p_cpu = ci;
+ atomic_setbits_int(&p->p_flag, P_CPUPEG);
+ setrunqueue(p);
+ p->p_stats->p_ru.ru_nvcsw++;
+ mi_switch();
+ SCHED_UNLOCK(s);
+}
+
+/*
* Functions to manipulate cpu sets.
*/
struct cpu_info *cpuset_infos[MAXCPUS];
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 2031c6f1870..2bfc6e308e5 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.h,v 1.114 2009/03/26 17:24:33 oga Exp $ */
+/* $OpenBSD: proc.h,v 1.115 2009/04/03 09:29:15 art Exp $ */
/* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */
/*-
@@ -305,6 +305,7 @@ struct proc {
#define P_IGNEXITRV 0x8000000 /* For thread kills */
#define P_SOFTDEP 0x10000000 /* Stuck processing softdep worklist */
#define P_STOPPED 0x20000000 /* Just stopped. */
+#define P_CPUPEG 0x40000000 /* Do not move to another cpu. */
#define P_BITS \
("\20\01ADVLOCK\02CTTY\04NOCLDSTOP\05PPWAIT\06PROFIL\07SELECT" \
diff --git a/sys/sys/sched.h b/sys/sys/sched.h
index 151adc9af37..7766f4da093 100644
--- a/sys/sys/sched.h
+++ b/sys/sys/sched.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sched.h,v 1.20 2009/03/23 13:25:11 art Exp $ */
+/* $OpenBSD: sched.h,v 1.21 2009/04/03 09:29:15 art Exp $ */
/* $NetBSD: sched.h,v 1.2 1999/02/28 18:14:58 ross Exp $ */
/*-
@@ -144,6 +144,7 @@ void sched_choosecpu(struct proc *);
void cpu_idle_enter(void);
void cpu_idle_cycle(void);
void cpu_idle_leave(void);
+void sched_peg_curproc(struct cpu_info *ci);
#define curcpu_is_idle() (curcpu()->ci_schedstate.spc_whichqs == 0)