summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorkato <kato@FreeBSD.org>2000-09-22 12:54:50 +0000
committerkato <kato@FreeBSD.org>2000-09-22 12:54:50 +0000
commitc8adbcf10a862b60e19c57b87e8c9163fe9ebe81 (patch)
tree0793f127a04ba88b7be97c9a477872f5744434e3 /sys
parent1757f776ca198a772424004b9b3d4806a6c4fe3e (diff)
downloadFreeBSD-src-c8adbcf10a862b60e19c57b87e8c9163fe9ebe81.zip
FreeBSD-src-c8adbcf10a862b60e19c57b87e8c9163fe9ebe81.tar.gz
Merged from sys/i386/i386/machdep.c revision 1.410.
Diffstat (limited to 'sys')
-rw-r--r--sys/pc98/i386/machdep.c37
-rw-r--r--sys/pc98/pc98/machdep.c37
2 files changed, 74 insertions, 0 deletions
diff --git a/sys/pc98/i386/machdep.c b/sys/pc98/i386/machdep.c
index 6baeebe..b8224b0 100644
--- a/sys/pc98/i386/machdep.c
+++ b/sys/pc98/i386/machdep.c
@@ -73,6 +73,7 @@
#include <sys/sysctl.h>
#include <sys/vmmeter.h>
#include <sys/bus.h>
+#include <sys/eventhandler.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
@@ -1006,6 +1007,42 @@ cpu_halt(void)
}
/*
+ * Hook to idle the CPU when possible. This currently only works in
+ * the !SMP case, as there is no clean way to ensure that a CPU will be
+ * woken when there is work available for it.
+ */
+#ifndef SMP
+static int cpu_idle_hlt = 1;
+SYSCTL_INT(_machdep, OID_AUTO, cpu_idle_hlt, CTLFLAG_RW, &cpu_idle_hlt, 0, "Idle loop HLT enable");
+
+/*
+ * Note that we have to be careful here to avoid a race between checking
+ * procrunnable() and actually halting. If we don't do this, we may waste
+ * the time between calling hlt and the next interrupt even though there
+ * is a runnable process.
+ */
+static void
+cpu_idle(void *junk, int count)
+{
+ if (cpu_idle_hlt){
+ disable_intr();
+ if (procrunnable()) {
+ enable_intr();
+ } else {
+ enable_intr();
+ __asm__ ("hlt");
+ }
+ }
+}
+
+static void cpu_idle_register(void *junk)
+{
+ EVENTHANDLER_FAST_REGISTER(idle_event, cpu_idle, NULL, IDLE_PRI_LAST);
+}
+SYSINIT(cpu_idle_register, SI_SUB_SCHED_IDLE, SI_ORDER_SECOND, cpu_idle_register, NULL)
+#endif /* !SMP */
+
+/*
* Clear registers on exec
*/
void
diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c
index 6baeebe..b8224b0 100644
--- a/sys/pc98/pc98/machdep.c
+++ b/sys/pc98/pc98/machdep.c
@@ -73,6 +73,7 @@
#include <sys/sysctl.h>
#include <sys/vmmeter.h>
#include <sys/bus.h>
+#include <sys/eventhandler.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
@@ -1006,6 +1007,42 @@ cpu_halt(void)
}
/*
+ * Hook to idle the CPU when possible. This currently only works in
+ * the !SMP case, as there is no clean way to ensure that a CPU will be
+ * woken when there is work available for it.
+ */
+#ifndef SMP
+static int cpu_idle_hlt = 1;
+SYSCTL_INT(_machdep, OID_AUTO, cpu_idle_hlt, CTLFLAG_RW, &cpu_idle_hlt, 0, "Idle loop HLT enable");
+
+/*
+ * Note that we have to be careful here to avoid a race between checking
+ * procrunnable() and actually halting. If we don't do this, we may waste
+ * the time between calling hlt and the next interrupt even though there
+ * is a runnable process.
+ */
+static void
+cpu_idle(void *junk, int count)
+{
+ if (cpu_idle_hlt){
+ disable_intr();
+ if (procrunnable()) {
+ enable_intr();
+ } else {
+ enable_intr();
+ __asm__ ("hlt");
+ }
+ }
+}
+
+static void cpu_idle_register(void *junk)
+{
+ EVENTHANDLER_FAST_REGISTER(idle_event, cpu_idle, NULL, IDLE_PRI_LAST);
+}
+SYSINIT(cpu_idle_register, SI_SUB_SCHED_IDLE, SI_ORDER_SECOND, cpu_idle_register, NULL)
+#endif /* !SMP */
+
+/*
* Clear registers on exec
*/
void
OpenPOWER on IntegriCloud