Add some grading test programs.
[pintos-anon] / grading / threads / join-no.c
diff --git a/grading/threads/join-no.c b/grading/threads/join-no.c
new file mode 100644 (file)
index 0000000..32623e3
--- /dev/null
@@ -0,0 +1,49 @@
+/* Problem 1-2: Join tests.
+
+   Based on a test originally submitted for Stanford's CS 140 in
+   winter 1998 by Rob Baesman <rbaesman@cs.stanford.edu>, Ben
+   Taskar <btaskar@cs.stanford.edu>, and Toli Kuznets
+   <tolik@cs.stanford.edu>.  Later modified by shiangc, yph, and
+   arens. */
+
+#include "threads/test.h"
+#include <stdio.h>
+#include "threads/interrupt.h"
+#include "threads/thread.h"
+
+static void no_test (void);
+
+void
+test (void) 
+{
+  no_test ();
+}
+
+static thread_func simple_thread_func;
+
+static void
+no_test (void) 
+{
+  tid_t tid0;
+  
+  printf ("\n"
+          "Testing no join.\n"
+          "Should just not crash.\n");
+  tid0 = thread_create ("0", PRI_DEFAULT, simple_thread_func, "0");
+  simple_thread_func ("1");
+  printf ("Simple join test done.\n");
+}
+
+void 
+simple_thread_func (void *name_) 
+{
+  const char *name = name_;
+  int i;
+  
+  for (i = 0; i < 5; i++) 
+    {
+      printf ("Thread %s iteration %d\n", name, i);
+      thread_yield ();
+    }
+  printf ("Thread %s done!\n", name);
+}