patch-2.2.0-pre1 linux/include/asm-i386/timex.h

Next file: linux/include/asm-i386/uaccess.h
Previous file: linux/include/asm-i386/system.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.132/linux/include/asm-i386/timex.h linux/include/asm-i386/timex.h
@@ -12,4 +12,34 @@
 	(1000000/CLOCK_TICK_FACTOR) / (CLOCK_TICK_RATE/CLOCK_TICK_FACTOR)) \
 		<< (SHIFT_SCALE-SHIFT_HZ)) / HZ)
 
+/*
+ * Standard way to access the cycle counter on i586+ CPUs.
+ * Currently only used on SMP.
+ *
+ * If you really have a SMP machine with i486 chips or older,
+ * compile for that, and this will just always return zero.
+ * That's ok, it just means that the nicer scheduling heuristics
+ * won't work for you.
+ *
+ * We only use the low 32 bits, and we'd simply better make sure
+ * that we reschedule before that wraps. Scheduling at least every
+ * four billion cycles just basically sounds like a good idea,
+ * regardless of how fast the machine is. 
+ */
+typedef unsigned long cycles_t;
+
+extern cycles_t cacheflush_time;
+
+static inline cycles_t get_cycles (void)
+{
+#if CPU < 586
+	return 0;
+#else
+	unsigned long eax, edx;
+
+	__asm__("rdtsc":"=a" (eax), "=d" (edx));
+	return eax;
+#endif
+}
+
 #endif

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov