changeset 1400:3152bb4429da draft

add gettime
author Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
date Tue, 14 Feb 2012 16:22:16 +0900
parents d6170e1200a0
children 2187bd10f16d
files TaskManager/Fifo/FifoDmaManager.cc TaskManager/Fifo/gettime.h TaskManager/Makefile.fifo TaskManager/Makefile.parallel
diffstat 4 files changed, 43 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Fifo/FifoDmaManager.cc	Mon Feb 06 16:29:26 2012 +0900
+++ b/TaskManager/Fifo/FifoDmaManager.cc	Tue Feb 14 16:22:16 2012 +0900
@@ -4,7 +4,7 @@
 #include "FifoDmaManager.h"
 #include "Scheduler.h"
 #include "TaskManagerImpl.h"
-#include "rdtsc.h"
+#include "gettime.h"
 
 void *
 FifoDmaManager::dma_load(Scheduler *s, void *buf, memaddr addr, uint32 size, uint32 mask)
@@ -237,13 +237,13 @@
 	start_dmawait_profile = &FifoDmaManager::do_start_dmawait_profile;
 	end_dmawait_profile = &FifoDmaManager::do_end_dmawait_profile;
 
-	stop_time = rdtsc();
+	stop_time = gettime();
 }
 
 void
 FifoDmaManager::stop_profile()
 {
-	start_time = rdtsc();
+	start_time = gettime();
 	global_busy_time += start_time - stop_time;
 
 	start_dmawait_profile = &FifoDmaManager::null_start_dmawait_profile;
@@ -253,14 +253,14 @@
 void
 FifoDmaManager::do_start_dmawait_profile()
 {
-	start_time = rdtsc();
+	start_time = gettime();
 	global_busy_time += start_time - stop_time;
 }
 
 void
 FifoDmaManager::do_end_dmawait_profile(unsigned long long *counter)
 {
-	stop_time = rdtsc();
+	stop_time = gettime();
 	*counter += stop_time - start_time;
 }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/Fifo/gettime.h	Tue Feb 14 16:22:16 2012 +0900
@@ -0,0 +1,30 @@
+#ifndef GETTIME_H_
+#define GETTIME_H_
+
+#include <time.h>
+
+/**
+ *  Mac OS X側には、clock_gettimeがないので、gettimeofdayを使う
+ */
+inline unsigned long long gettime() {
+
+	unsigned long long time;
+#ifdef __CERIUM_FIFO__
+	struct timespec ts;
+
+#ifndef __APPLE__
+	clock_gettime(CLOCK_REALTIME, &ts);
+#else
+	struct timeval tv;
+	gettimeofday(&tv, NULL);
+	ts.tv_sec = tv.tv_sec;
+	ts.tv_nsec = tv.tv_usec * 1000;
+#endif
+
+	time = ((ts.tv_sec << 32) | ts.tv_nsec );
+#endif // __CERIUM_FIFO__
+	return time;
+
+}
+
+#endif
--- a/TaskManager/Makefile.fifo	Mon Feb 06 16:29:26 2012 +0900
+++ b/TaskManager/Makefile.fifo	Tue Feb 14 16:22:16 2012 +0900
@@ -5,6 +5,10 @@
 
 EXTRA_CFLAGS = -D__CERIUM_FIFO__ 
 
+#ifndef __APPLE__
+CFLAGS += -lrt
+#endif
+
 .cc.o:
 	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) -c $< -o $@
 
--- a/TaskManager/Makefile.parallel	Mon Feb 06 16:29:26 2012 +0900
+++ b/TaskManager/Makefile.parallel	Tue Feb 14 16:22:16 2012 +0900
@@ -1,6 +1,10 @@
 include ./Makefile.def
 TARGET = libFifoManager.a
 CFLAGS += -DHAS_POSIX_MEMALIGN
+#ifndef __APPLE__
+CFLAGS += -lrt
+#endif
+
 
 .SUFFIXES: .cc .o