mcs-lock: add trivial driver, link with build system
authorBrian Norris <banorris@uci.edu>
Wed, 10 Oct 2012 01:09:20 +0000 (18:09 -0700)
committerBrian Norris <banorris@uci.edu>
Wed, 10 Oct 2012 01:09:58 +0000 (18:09 -0700)
This benchmark doesn't do much yet.

Makefile
mcs-lock/Makefile [new file with mode: 0644]
mcs-lock/mcs-lock.cc [new file with mode: 0644]

index 26349f78d5f4852892bd87409c5e7a4caa360234..028a9466e4e660f520b300101f720553b8f3e01f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-DIRS := barrier
+DIRS := barrier mcs-lock
 
 .PHONY: subdirs $(DIRS)
 
diff --git a/mcs-lock/Makefile b/mcs-lock/Makefile
new file mode 100644 (file)
index 0000000..04d2398
--- /dev/null
@@ -0,0 +1,11 @@
+include ../benchmarks.mk
+
+TESTNAME = mcs-lock
+
+all: $(TESTNAME)
+
+$(TESTNAME): $(TESTNAME).cc $(TESTNAME).h
+       $(CXX) -o $@ $< $(CPPFLAGS) $(LDFLAGS)
+
+clean:
+       rm -f $(TESTNAME) *.o
diff --git a/mcs-lock/mcs-lock.cc b/mcs-lock/mcs-lock.cc
new file mode 100644 (file)
index 0000000..135085f
--- /dev/null
@@ -0,0 +1,14 @@
+#include <stdio.h>
+#include <threads.h>
+
+#include "mcs-lock.h"
+
+struct mcs_mutex *mutex;
+
+int user_main(int argc, char **argv)
+{
+       mcs_mutex::guard *g = new mcs_mutex::guard(mutex);
+       mutex->lock(g);
+       mutex->unlock(g);
+       return 0;
+}