Cleaned up the 'timer interfaces'
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 1 Aug 2011 21:58:13 +0000 (14:58 -0700)
committerKevin Klues <klueska@cs.berkeley.edu>
Thu, 3 Nov 2011 00:36:05 +0000 (17:36 -0700)
Things were a bit ghetto.  Now there is just time.h, one for ros/, one
for kern, and one for the arches.  x86 still uses apic.h for all its
crap, but no one else in kern/ needs to know about that.

32 files changed:
kern/arch/i686/apic.c
kern/arch/i686/ne2k.c
kern/arch/i686/smp_boot.c
kern/arch/i686/time.h [new file with mode: 0644]
kern/arch/riscv/Makefrag
kern/arch/riscv/arch.h
kern/arch/riscv/time.c [new file with mode: 0644]
kern/arch/riscv/time.h [new file with mode: 0644]
kern/arch/riscv/timer.c [deleted file]
kern/arch/riscv/timer.h [deleted file]
kern/arch/sparc/Makefrag
kern/arch/sparc/arch.h
kern/arch/sparc/sparc.h
kern/arch/sparc/time.c [new file with mode: 0644]
kern/arch/sparc/time.h [new file with mode: 0644]
kern/arch/sparc/timer.c [deleted file]
kern/arch/sparc/timer.h [deleted file]
kern/include/ros/fs.h
kern/include/ros/time.h [new file with mode: 0644]
kern/include/ros/timer.h [deleted file]
kern/include/time.h [new file with mode: 0644]
kern/include/timing.h [deleted file]
kern/include/vfs.h
kern/src/Makefrag
kern/src/init.c
kern/src/manager.c
kern/src/monitor.c
kern/src/process.c
kern/src/syscall.c
kern/src/testing.c
kern/src/time.c [new file with mode: 0644]
kern/src/timer.c [deleted file]

index c6411e7..7f9fcb0 100644 (file)
@@ -13,7 +13,7 @@
 #include <arch/x86.h>
 #include <arch/arch.h>
 #include <arch/apic.h>
-#include <ros/timer.h>
+#include <ros/time.h>
 #include <assert.h>
 #include <stdio.h>
 
@@ -159,7 +159,7 @@ static int getpit()
     return ((high << 8) | low);
 }
 
-// forces cpu to relax for usec miliseconds.  declared in kern/include/timing.h
+// forces cpu to relax for usec miliseconds.  declared in kern/include/time.h
 void udelay(uint64_t usec)
 {
        #if !defined(__BOCHS__)
index 2c2005d..2241e5e 100644 (file)
@@ -23,7 +23,7 @@
 #include <kmalloc.h>
 
 #include <pmap.h>
-#include <timing.h>
+#include <time.h>
 
 /** @file
  * @brief NE2K Driver Sketch
index cb0dbe6..4c13660 100644 (file)
@@ -15,7 +15,7 @@
 #include <arch/console.h>
 #include <arch/apic.h>
 #include <arch/perfmon.h>
-#include <timing.h>
+#include <time.h>
 
 #include <bitmask.h>
 #include <atomic.h>
@@ -26,7 +26,6 @@
 #include <pmap.h>
 #include <env.h>
 #include <trap.h>
-#include <timing.h>
 #include <kmalloc.h>
 
 extern handler_wrapper_t (RO handler_wrappers)[NUM_HANDLER_WRAPPERS];
diff --git a/kern/arch/i686/time.h b/kern/arch/i686/time.h
new file mode 100644 (file)
index 0000000..7976c9b
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef ROS_KERN_ARCH_TIME_H
+#define ROS_KERN_ARCH_TIME_H
+
+#include <arch/apic.h>
+
+#endif /* ROS_KERN_ARCH_TIME_H */
index a4709fa..836ce9d 100644 (file)
@@ -18,7 +18,7 @@ KERN_ARCH_SRCFILES := $(KERN_ARCH_SRC_DIR)/boot.S \
                       $(KERN_ARCH_SRC_DIR)/cpuinfo.c \
                       $(KERN_ARCH_SRC_DIR)/console.c \
                       $(KERN_ARCH_SRC_DIR)/pmap.c \
-                      $(KERN_ARCH_SRC_DIR)/timer.c \
+                      $(KERN_ARCH_SRC_DIR)/time.c \
                       $(KERN_ARCH_SRC_DIR)/atomic.c \
                       $(KERN_ARCH_SRC_DIR)/smp.c \
                       $(KERN_ARCH_SRC_DIR)/colored_caches.c \
index 7c0412a..90f21e9 100644 (file)
@@ -7,7 +7,7 @@
 #include <ros/arch/membar.h>
 #include <arch/riscv.h>
 #include <arch/trap.h>
-#include <arch/timer.h>
+#include <arch/time.h>
 
 /* Arch Constants */
 #define HW_CACHE_ALIGN 64
diff --git a/kern/arch/riscv/time.c b/kern/arch/riscv/time.c
new file mode 100644 (file)
index 0000000..2059017
--- /dev/null
@@ -0,0 +1,54 @@
+#include <arch/time.h>
+#include <ros/common.h>
+#include <arch/trap.h>
+#include <arch/arch.h>
+#include <stdio.h>
+#include <assert.h>
+
+system_timing_t system_timing = {0};
+
+void
+timer_init(void)
+{      
+  mtpcr(PCR_COUNT, 0);
+  mtpcr(PCR_COMPARE, 0);
+       mtpcr(PCR_SR, mfpcr(PCR_SR) | (SR_IM & (1 << (TIMER_IRQ+SR_IM_SHIFT))));
+
+       system_timing.tsc_freq = TSC_HZ;
+       cprintf("TSC Frequency: %llu\n", system_timing.tsc_freq);
+}
+
+/* Warning: one-shot timers are unsupported; all timers are periodic.
+ * Perhaps this support could be added with a per_cpu boolean, set
+ * by set_core_timer, and interpreted by the interrupt handler. */
+void
+set_core_timer(uint32_t usec, bool periodic)
+{
+       uint32_t clocks =  (uint64_t)usec*TSC_HZ/1000000;
+
+  int8_t irq_state = 0;
+       disable_irqsave(&irq_state);
+
+  mtpcr(PCR_COMPARE, mfpcr(PCR_COUNT) + clocks);
+
+       enable_irqsave(&irq_state);
+}
+
+void
+udelay(uint64_t usec)
+{
+       if (system_timing.tsc_freq != 0)
+       {
+               uint64_t start, end, now;
+        
+               start = read_tsc();
+               end = start + (system_timing.tsc_freq * usec) / 1000000;
+
+               do
+               {
+                       cpu_relax();
+                       now = read_tsc();
+               } while (now < end || (now > start && end < start));
+       }
+       else panic("udelay() was called before timer_init(), moron!");
+}
diff --git a/kern/arch/riscv/time.h b/kern/arch/riscv/time.h
new file mode 100644 (file)
index 0000000..d4ec70d
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef ROS_KERN_ARCH_TIME_H
+#define ROS_KERN_ARCH_TIME_H
+
+#define TSC_HZ 1000000000 // really, this is the core clock frequency
+
+#include <ros/common.h>
+
+typedef struct system_timing {
+       uint64_t tsc_freq;
+} system_timing_t;
+
+extern system_timing_t system_timing;
+
+void timer_init(void);
+void set_timer(uint32_t usec);
+
+#endif /* ROS_KERN_ARCH_TIME_H */
diff --git a/kern/arch/riscv/timer.c b/kern/arch/riscv/timer.c
deleted file mode 100644 (file)
index 6cbb4cd..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-#include <arch/timer.h>
-#include <ros/common.h>
-#include <arch/trap.h>
-#include <arch/arch.h>
-#include <stdio.h>
-#include <assert.h>
-
-system_timing_t system_timing = {0};
-
-void
-timer_init(void)
-{      
-  mtpcr(PCR_COUNT, 0);
-  mtpcr(PCR_COMPARE, 0);
-       mtpcr(PCR_SR, mfpcr(PCR_SR) | (SR_IM & (1 << (TIMER_IRQ+SR_IM_SHIFT))));
-
-       system_timing.tsc_freq = TSC_HZ;
-       cprintf("TSC Frequency: %llu\n", system_timing.tsc_freq);
-}
-
-/* Warning: one-shot timers are unsupported; all timers are periodic.
- * Perhaps this support could be added with a per_cpu boolean, set
- * by set_core_timer, and interpreted by the interrupt handler. */
-void
-set_core_timer(uint32_t usec, bool periodic)
-{
-       uint32_t clocks =  (uint64_t)usec*TSC_HZ/1000000;
-
-  int8_t irq_state = 0;
-       disable_irqsave(&irq_state);
-
-  mtpcr(PCR_COMPARE, mfpcr(PCR_COUNT) + clocks);
-
-       enable_irqsave(&irq_state);
-}
-
-void
-udelay(uint64_t usec)
-{
-       if (system_timing.tsc_freq != 0)
-       {
-               uint64_t start, end, now;
-        
-               start = read_tsc();
-               end = start + (system_timing.tsc_freq * usec) / 1000000;
-
-               do
-               {
-                       cpu_relax();
-                       now = read_tsc();
-               } while (now < end || (now > start && end < start));
-       }
-       else panic("udelay() was called before timer_init(), moron!");
-}
diff --git a/kern/arch/riscv/timer.h b/kern/arch/riscv/timer.h
deleted file mode 100644 (file)
index 4ba459e..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef ROS_ARCH_TIMER_H
-#define ROS_ARCH_TIMER_H
-
-#define TSC_HZ 1000000000 // really, this is the core clock frequency
-
-#include <ros/common.h>
-
-typedef struct system_timing {
-       uint64_t tsc_freq;
-} system_timing_t;
-
-extern system_timing_t system_timing;
-
-void timer_init(void);
-void set_timer(uint32_t usec);
-
-#endif /* !ROS_ARCH_TIMER_H */
index a7f849f..2c373f4 100644 (file)
@@ -23,7 +23,7 @@ KERN_ARCH_SRCFILES := $(KERN_ARCH_SRC_DIR)/entry.S \
                       $(KERN_ARCH_SRC_DIR)/page_alloc.c \
                       $(KERN_ARCH_SRC_DIR)/process.c \
                       $(KERN_ARCH_SRC_DIR)/colored_caches.c \
-                      $(KERN_ARCH_SRC_DIR)/timer.c \
+                      $(KERN_ARCH_SRC_DIR)/time.c \
                       $(KERN_ARCH_SRC_DIR)/env.c \
                       $(KERN_ARCH_SRC_DIR)/init.c \
                       $(KERN_ARCH_SRC_DIR)/smp.c \
index 02bdef3..0028de0 100644 (file)
@@ -13,7 +13,7 @@
 #ifndef __ASSEMBLER__
 
 #include <ros/common.h>
-#include <arch/timer.h>
+#include <arch/time.h>
 
 static __inline void breakpoint(void) __attribute__((always_inline));
 static __inline void invlpg(void *addr) __attribute__((always_inline));
index 189e197..a1132ac 100644 (file)
@@ -23,7 +23,7 @@
 #define XSTR(arg) STR(arg)
 
 #include <ros/common.h>
-#include <arch/timer.h>
+#include <arch/time.h>
 
 static __inline uint32_t read_psr(void) __attribute__((always_inline));
 static __inline uint32_t read_wim(void) __attribute__((always_inline));
diff --git a/kern/arch/sparc/time.c b/kern/arch/sparc/time.c
new file mode 100644 (file)
index 0000000..329d218
--- /dev/null
@@ -0,0 +1,62 @@
+#include <arch/time.h>
+#include <ros/common.h>
+#include <arch/trap.h>
+#include <arch/arch.h>
+#include <stdio.h>
+#include <assert.h>
+
+#ifdef __SHARC__
+#pragma nosharc
+#endif
+
+system_timing_t system_timing = {0};
+
+void
+timer_init(void)
+{      
+       system_timing.tsc_freq = TSC_HZ;
+       cprintf("TSC Frequency: %llu\n", system_timing.tsc_freq);
+}
+
+/* Warning!  Sparc is unable to do a one-shot timer, so all timers are periodic,
+ * though that is not normally what we want. */
+void
+set_core_timer(uint32_t usec, bool periodic)
+{
+       set_timer(usec);
+}
+
+void
+set_timer(uint32_t usec)
+{
+       uint32_t clocks =  (uint64_t)usec*TSC_HZ/1000000;
+       if(clocks & (clocks-1))
+               clocks = ROUNDUPPWR2(clocks);
+
+       if(clocks > TIMER_MAX_PERIOD)
+       {
+               clocks = TIMER_MAX_PERIOD;
+               warn("set_timer: truncating to %d usec",
+                    (uint64_t)clocks*1000000/TSC_HZ);
+       }
+       sparc_set_timer(clocks,!!clocks);
+}
+
+void
+udelay(uint64_t usec)
+{
+       if (system_timing.tsc_freq != 0)
+       {
+               uint64_t start, end, now;
+        
+               start = read_tsc();
+               end = start + (system_timing.tsc_freq * usec) / 1000000;
+
+               do
+               {
+                       cpu_relax();
+                       now = read_tsc();
+               } while (now < end || (now > start && end < start));
+       }
+       else panic("udelay() was called before timer_init(), moron!");
+}
diff --git a/kern/arch/sparc/time.h b/kern/arch/sparc/time.h
new file mode 100644 (file)
index 0000000..8d3bef1
--- /dev/null
@@ -0,0 +1,19 @@
+#ifndef ROS_KERN_ARCH_TIME_H
+#define ROS_KERN_ARCH_TIME_H
+
+#define TSC_HZ 1000000000 // really, this is the core clock frequency
+#define TIMER_PERIOD_BITS 24
+#define TIMER_MAX_PERIOD (1 << TIMER_PERIOD_BITS) // in cycles
+
+#include <ros/common.h>
+
+typedef struct system_timing {
+       uint64_t tsc_freq;
+} system_timing_t;
+
+extern system_timing_t system_timing;
+
+void timer_init(void);
+void set_timer(uint32_t usec);
+
+#endif /* ROS_KERN_ARCH_TIME_H */
diff --git a/kern/arch/sparc/timer.c b/kern/arch/sparc/timer.c
deleted file mode 100644 (file)
index 0a30dc1..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-#include <arch/timer.h>
-#include <ros/common.h>
-#include <arch/trap.h>
-#include <arch/arch.h>
-#include <stdio.h>
-#include <assert.h>
-
-#ifdef __SHARC__
-#pragma nosharc
-#endif
-
-system_timing_t system_timing = {0};
-
-void
-timer_init(void)
-{      
-       system_timing.tsc_freq = TSC_HZ;
-       cprintf("TSC Frequency: %llu\n", system_timing.tsc_freq);
-}
-
-/* Warning!  Sparc is unable to do a one-shot timer, so all timers are periodic,
- * though that is not normally what we want. */
-void
-set_core_timer(uint32_t usec, bool periodic)
-{
-       set_timer(usec);
-}
-
-void
-set_timer(uint32_t usec)
-{
-       uint32_t clocks =  (uint64_t)usec*TSC_HZ/1000000;
-       if(clocks & (clocks-1))
-               clocks = ROUNDUPPWR2(clocks);
-
-       if(clocks > TIMER_MAX_PERIOD)
-       {
-               clocks = TIMER_MAX_PERIOD;
-               warn("set_timer: truncating to %d usec",
-                    (uint64_t)clocks*1000000/TSC_HZ);
-       }
-       sparc_set_timer(clocks,!!clocks);
-}
-
-void
-udelay(uint64_t usec)
-{
-       if (system_timing.tsc_freq != 0)
-       {
-               uint64_t start, end, now;
-        
-               start = read_tsc();
-               end = start + (system_timing.tsc_freq * usec) / 1000000;
-
-               do
-               {
-                       cpu_relax();
-                       now = read_tsc();
-               } while (now < end || (now > start && end < start));
-       }
-       else panic("udelay() was called before timer_init(), moron!");
-}
diff --git a/kern/arch/sparc/timer.h b/kern/arch/sparc/timer.h
deleted file mode 100644 (file)
index 4db89da..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef ROS_ARCH_TIMER_H
-#define ROS_ARCH_TIMER_H
-
-#define TSC_HZ 1000000000 // really, this is the core clock frequency
-#define TIMER_PERIOD_BITS 24
-#define TIMER_MAX_PERIOD (1 << TIMER_PERIOD_BITS) // in cycles
-
-#include <ros/common.h>
-
-typedef struct system_timing {
-       uint64_t tsc_freq;
-} system_timing_t;
-
-extern system_timing_t system_timing;
-
-void timer_init(void);
-void set_timer(uint32_t usec);
-
-#endif /* !ROS_ARCH_TIMER_H */
index c54b1f2..e1dfac2 100644 (file)
@@ -2,7 +2,7 @@
 #define _ROS_INC_STAT_H
 
 #include <sys/types.h>
-#include <timing.h>
+#include <time.h>
 
 /* Keep this 255 to stay in sync with glibc (expects d_name[256]) */
 #define MAX_FILENAME_SZ 255
diff --git a/kern/include/ros/time.h b/kern/include/ros/time.h
new file mode 100644 (file)
index 0000000..56f755b
--- /dev/null
@@ -0,0 +1,61 @@
+#ifndef ROS_INC_TIME_H
+#define ROS_INC_TIME_H
+
+#include <pool.h>
+#include <string.h>
+
+#define TIMER_TAG_SIZE 20
+#define MAX_TIMERS 20
+
+/* start_timing()
+ * This function simply reads the tsc in a serialized fashion and returns its
+ * value.  It is pusposefully annotated with a noinline so that the overheads 
+ * assocaited with calling it are as deterministic as possible.
+ */
+uint64_t start_timing() __attribute__((noinline));
+
+/* stop_timing()
+ * This function reads the tsc in a serialized fashion and subtracts the value
+ * it reads from the value passed in as a paramter in order to determine the 
+ * difference between the two values.  A global timing_overhead value is also 
+ * subtracted to compensate for the overhead associated with calling both
+ * start and stop timing and returning their values.
+ * This function is purposefully annotated with a noinline so that 
+ * the overheads assocaited with calling it are as deterministic as possible.
+ */
+uint64_t stop_timing(uint64_t val) __attribute__((noinline));
+
+/* train_timing()
+ * This function is intended to train the timing_overhead variable for use by
+ * stop_timing().  It runs through a loop calling start/stop and averaging the 
+ * overhead of calling them without doing any useful work in between.
+ */
+void train_timing();
+
+/* timer_t
+ * This struct is used to keep track of counter values as they are spread
+ * throughput code and timing measurements are made calling TAGGED_TIMING_BEGIN
+ * and TAGGED_TIMING_END
+ */
+typedef struct Timer{
+       uint64_t curr_run;
+       uint64_t aggr_run;
+       char label[TIMER_TAG_SIZE];
+} timer_t;
+
+//TODO: ifdef measurement? error check when pool runs low
+#define TAGGED_TIMING_BEGIN(tag)                    \
+       static timer_t* _timer_##tag = NULL;            \
+       if (_timer_##tag == NULL) {                     \
+               _timer_##tag = POOL_GET(&timer_pool);       \
+               strcpy((_timer_##tag->label), #tag);        \
+               _timer_##tag->aggr_run = 0;                 \
+       }                                               \
+       _timer_##tag->curr_run = start_timing();
+#define TAGGED_TIMING_END(tag)                                              \
+({                                                                          \
+       _timer_##tag->curr_run = stop_timing(_timer_##tag->curr_run);           \
+       _timer_##tag->aggr_run += _timer_##tag->curr_run;                       \
+})
+
+#endif /* ROS_INC_TIME_H */
diff --git a/kern/include/ros/timer.h b/kern/include/ros/timer.h
deleted file mode 100644 (file)
index 6d5115a..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef ROS_INC_TIMER_H
-#define ROS_INC_TIMER_H
-
-#include <pool.h>
-#include <string.h>
-
-#define TIMER_TAG_SIZE 20
-#define MAX_TIMERS 20
-
-/* start_timing()
- * This function simply reads the tsc in a serialized fashion and returns its
- * value.  It is pusposefully annotated with a noinline so that the overheads 
- * assocaited with calling it are as deterministic as possible.
- */
-uint64_t start_timing() __attribute__((noinline));
-
-/* stop_timing()
- * This function reads the tsc in a serialized fashion and subtracts the value
- * it reads from the value passed in as a paramter in order to determine the 
- * difference between the two values.  A global timing_overhead value is also 
- * subtracted to compensate for the overhead associated with calling both
- * start and stop timing and returning their values.
- * This function is purposefully annotated with a noinline so that 
- * the overheads assocaited with calling it are as deterministic as possible.
- */
-uint64_t stop_timing(uint64_t val) __attribute__((noinline));
-
-/* train_timing()
- * This function is intended to train the timing_overhead variable for use by
- * stop_timing().  It runs through a loop calling start/stop and averaging the 
- * overhead of calling them without doing any useful work in between.
- */
-void train_timing();
-
-/* timer_t
- * This struct is used to keep track of counter values as they are spread
- * throughput code and timing measurements are made calling TAGGED_TIMING_BEGIN
- * and TAGGED_TIMING_END
- */
-typedef struct Timer{
-       uint64_t curr_run;
-       uint64_t aggr_run;
-       char label[TIMER_TAG_SIZE];
-} timer_t;
-
-//TODO: ifdef measurement? error check when pool runs low
-#define TAGGED_TIMING_BEGIN(tag)                    \
-       static timer_t* _timer_##tag = NULL;            \
-       if (_timer_##tag == NULL) {                     \
-               _timer_##tag = POOL_GET(&timer_pool);       \
-               strcpy((_timer_##tag->label), #tag);        \
-               _timer_##tag->aggr_run = 0;                 \
-       }                                               \
-       _timer_##tag->curr_run = start_timing();
-#define TAGGED_TIMING_END(tag)                                              \
-({                                                                          \
-       _timer_##tag->curr_run = stop_timing(_timer_##tag->curr_run);           \
-       _timer_##tag->aggr_run += _timer_##tag->curr_run;                       \
-})
-
-#endif /* !ROS_INC_TIMER_H */
-
diff --git a/kern/include/time.h b/kern/include/time.h
new file mode 100644 (file)
index 0000000..3507e44
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef ROS_KERN_TIME_H
+#define ROS_KERN_TIME_H
+
+#include <ros/common.h>
+#include <arch/time.h>
+
+/* (newlib) Time Value Specification Structures, P1003.1b-1993, p. 261 */
+typedef long time_t;
+
+struct timespec {
+  time_t  tv_sec;   /* Seconds */
+  long    tv_nsec;  /* Nanoseconds */
+};
+
+struct itimerspec {
+  struct timespec  it_interval;  /* Timer period */
+  struct timespec  it_value;     /* Timer expiration */
+};
+
+void udelay(uint64_t usec);
+
+#endif /* ROS_KERN_TIME_H */
diff --git a/kern/include/timing.h b/kern/include/timing.h
deleted file mode 100644 (file)
index 59df592..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef ROS_INC_TIMING_H
-#define ROS_INC_TIMING_H
-
-#include <ros/common.h>
-
-/* (newlib) Time Value Specification Structures, P1003.1b-1993, p. 261 */
-typedef long time_t;
-
-struct timespec {
-  time_t  tv_sec;   /* Seconds */
-  long    tv_nsec;  /* Nanoseconds */
-};
-
-struct itimerspec {
-  struct timespec  it_interval;  /* Timer period */
-  struct timespec  it_value;     /* Timer expiration */
-};
-
-void udelay(uint64_t usec);
-
-#endif
index 4764bb4..6acb17e 100644 (file)
@@ -17,7 +17,7 @@
 #include <sys/queue.h>
 #include <bitmask.h>
 #include <kref.h>
-#include <timing.h>
+#include <time.h>
 #include <radix.h>
 #include <hashtable.h>
 #include <pagemap.h>
index 67bd0a3..88f5c7a 100644 (file)
@@ -29,7 +29,7 @@ KERN_SRCFILES := $(KERN_ARCH_SRCFILES) \
                  $(KERN_SRC_DIR)/env.c \
                  $(KERN_SRC_DIR)/manager.c \
                  $(KERN_SRC_DIR)/syscall.c \
-                 $(KERN_SRC_DIR)/timer.c \
+                 $(KERN_SRC_DIR)/time.c \
                  $(KERN_SRC_DIR)/kfs.c \
                  $(KERN_SRC_DIR)/process.c \
                  $(KERN_SRC_DIR)/kmalloc.c \
index 1bc7943..5cdbaf4 100644 (file)
@@ -8,7 +8,7 @@
 #error "Yeah, it's not possible to build ROS with BSD on Core 0, sorry......"
 #else
 
-#include <ros/timer.h>
+#include <ros/time.h>
 #include <arch/arch.h>
 #include <arch/console.h>
 #include <multiboot.h>
index 0bd4b85..c2e202c 100644 (file)
 #include <testing.h>
 #include <kfs.h>
 #include <stdio.h>
-#include <timing.h>
+#include <time.h>
 #include <resource.h>
 #include <monitor.h>
 #include <colored_caches.h>
 #include <string.h>
 #include <pmap.h>
-#include <ros/timer.h>
+#include <ros/time.h>
 #include <ros/arch/membar.h>
 
 /*
index 728b2f6..8c5a7b7 100644 (file)
@@ -28,7 +28,7 @@
 #include <event.h>
 #include <trap.h>
 
-#include <ros/timer.h>
+#include <ros/time.h>
 #include <ros/memlayout.h>
 #include <ros/event.h>
 
index a3a282a..e2bccf8 100644 (file)
@@ -19,7 +19,7 @@
 #include <manager.h>
 #include <stdio.h>
 #include <assert.h>
-#include <timing.h>
+#include <time.h>
 #include <hashtable.h>
 #include <slab.h>
 #include <sys/queue.h>
index 0d785ac..6d1b424 100644 (file)
@@ -9,7 +9,7 @@
 #include <arch/arch.h>
 #include <arch/mmu.h>
 #include <arch/console.h>
-#include <ros/timer.h>
+#include <ros/time.h>
 #include <error.h>
 
 #include <elf.h>
index e6e86af..226edb6 100644 (file)
@@ -22,7 +22,7 @@
 #include <arch/trap.h>
 #include <process.h>
 #include <syscall.h>
-#include <timing.h>
+#include <time.h>
 #include <kfs.h>
 #include <multiboot.h>
 #include <pmap.h>
diff --git a/kern/src/time.c b/kern/src/time.c
new file mode 100644 (file)
index 0000000..40bf131
--- /dev/null
@@ -0,0 +1,90 @@
+
+// zra: why is this in the kernel?
+
+#ifdef __SHARC__
+#pragma nosharc
+#endif
+
+#include <arch/arch.h>
+#include <ros/time.h>
+#include <stdio.h>
+#include <schedule.h>
+#include <multiboot.h>
+#include <pmap.h>
+#include <smp.h>
+
+/* timing_overhead
+ * Any user space process that links to this file will get its own copy.  
+ * This means it will manually have to call tune_timing itself before it 
+ * makes its first measurement.
+ */
+uint64_t timing_overhead = 0;
+
+/* start_timing()
+ * This function simply reads the tsc in a serialized fashion and returns its
+ * value.  It is pusposefully annotated with a noinline so that the overheads 
+ * assocaited with calling it are as deterministic as possible.
+ */
+uint64_t start_timing()
+{
+    return read_tsc_serialized();
+}
+
+/* stop_timing()
+ * This function reads the tsc in a serialized fashion and subtracts the value
+ * it reads from the value passed in as a paramter in order to determine the 
+ * difference between the two values.  A global timing_overhead value is also 
+ * subtracted to compensate for the overhead associated with calling both
+ * start and stop timing and returning their values.
+ * This function is purposefully annotated with a noinline so that 
+ * the overheads assocaited with calling it are as deterministic as possible.
+ */
+uint64_t stop_timing(uint64_t val)
+{
+    uint64_t diff = (read_tsc_serialized() - val - timing_overhead);
+       if ((int64_t) diff < 0) 
+               return 1;
+       return diff;
+}
+
+/* train_timing()
+ * This function is intended to train the timing_overhead variable for use by
+ * stop_timing().  It runs through a loop calling start/stop and averaging the 
+ * overhead of calling them without doing any useful work in between.
+ */
+void train_timing() 
+{
+       int i;
+       // set training overhead to be something large
+       register uint64_t training_overhead = 0xffffffff;
+       register uint64_t time, diff;
+
+       //Do this 3 times outside the loop to warm up cpuid
+       time = start_timing();
+       diff = stop_timing(time);
+       time = start_timing();
+       diff = stop_timing(time);
+       time = start_timing();
+       diff = stop_timing(time);
+       for(i=0; i<10000; i++) {
+               time = start_timing();
+               diff = stop_timing(time);
+               
+               /* In case diff was negative, I want to add its absolute value
+                * to the cumulative error, otherwise, just diff itself
+                */
+               if((int64_t)diff < 0)
+                       diff = (uint64_t)(~0) - diff + 1;
+               training_overhead = MIN(training_overhead, diff);
+       }
+       timing_overhead = training_overhead;
+}
+
+/* Convenience wrapper called when a core's timer interrupt goes off.  Not to be
+ * confused with global timers (like the PIC).  Do not put your code here.  If
+ * you want something to happen in the future, set an alarm. */
+void timer_interrupt(struct trapframe *tf, void *data)
+{
+       struct timer_chain *pcpui_tchain = &per_cpu_info[core_id()].tchain;
+       trigger_tchain(pcpui_tchain);
+}
diff --git a/kern/src/timer.c b/kern/src/timer.c
deleted file mode 100644 (file)
index 0170715..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-
-// zra: why is this in the kernel?
-
-#ifdef __SHARC__
-#pragma nosharc
-#endif
-
-#include <arch/arch.h>
-#include <ros/timer.h>
-#include <stdio.h>
-#include <schedule.h>
-#include <multiboot.h>
-#include <pmap.h>
-#include <smp.h>
-
-/* timing_overhead
- * Any user space process that links to this file will get its own copy.  
- * This means it will manually have to call tune_timing itself before it 
- * makes its first measurement.
- */
-uint64_t timing_overhead = 0;
-
-/* start_timing()
- * This function simply reads the tsc in a serialized fashion and returns its
- * value.  It is pusposefully annotated with a noinline so that the overheads 
- * assocaited with calling it are as deterministic as possible.
- */
-uint64_t start_timing()
-{
-    return read_tsc_serialized();
-}
-
-/* stop_timing()
- * This function reads the tsc in a serialized fashion and subtracts the value
- * it reads from the value passed in as a paramter in order to determine the 
- * difference between the two values.  A global timing_overhead value is also 
- * subtracted to compensate for the overhead associated with calling both
- * start and stop timing and returning their values.
- * This function is purposefully annotated with a noinline so that 
- * the overheads assocaited with calling it are as deterministic as possible.
- */
-uint64_t stop_timing(uint64_t val)
-{
-    uint64_t diff = (read_tsc_serialized() - val - timing_overhead);
-       if ((int64_t) diff < 0) 
-               return 1;
-       return diff;
-}
-
-/* train_timing()
- * This function is intended to train the timing_overhead variable for use by
- * stop_timing().  It runs through a loop calling start/stop and averaging the 
- * overhead of calling them without doing any useful work in between.
- */
-void train_timing() 
-{
-       int i;
-       // set training overhead to be something large
-       register uint64_t training_overhead = 0xffffffff;
-       register uint64_t time, diff;
-
-       //Do this 3 times outside the loop to warm up cpuid
-       time = start_timing();
-       diff = stop_timing(time);
-       time = start_timing();
-       diff = stop_timing(time);
-       time = start_timing();
-       diff = stop_timing(time);
-       for(i=0; i<10000; i++) {
-               time = start_timing();
-               diff = stop_timing(time);
-               
-               /* In case diff was negative, I want to add its absolute value
-                * to the cumulative error, otherwise, just diff itself
-                */
-               if((int64_t)diff < 0)
-                       diff = (uint64_t)(~0) - diff + 1;
-               training_overhead = MIN(training_overhead, diff);
-       }
-       timing_overhead = training_overhead;
-}
-
-/* Convenience wrapper called when a core's timer interrupt goes off.  Not to be
- * confused with global timers (like the PIC).  Do not put your code here.  If
- * you want something to happen in the future, set an alarm. */
-void timer_interrupt(struct trapframe *tf, void *data)
-{
-       struct timer_chain *pcpui_tchain = &per_cpu_info[core_id()].tchain;
-       trigger_tchain(pcpui_tchain);
-}