1 /* Problem 1-2: Join tests.
3 Based on a test originally submitted for Stanford's CS 140 in
4 winter 1998 by Rob Baesman <rbaesman@cs.stanford.edu>, Ben
5 Taskar <btaskar@cs.stanford.edu>, and Toli Kuznets
6 <tolik@cs.stanford.edu>. Later modified by shiangc, yph, and
8 #include "threads/test.h"
10 #include "threads/interrupt.h"
11 #include "threads/thread.h"
13 static void nested_test (void);
21 static thread_func nested_thread_func;
30 "Testing nested join.\n"
31 "Threads 0 to 7 should start in numerical order\n"
32 "and finish in reverse order.\n");
33 tid0 = thread_create ("0", PRI_DEFAULT, nested_thread_func, &zero);
35 printf ("Nested join test done.\n");
39 nested_thread_func (void *valuep_)
41 int *valuep = valuep_;
44 printf ("Thread %d starting.\n", value);
50 snprintf (name_next, sizeof name_next, "%d", next);
52 tid_next = thread_create (name_next, PRI_DEFAULT,
53 nested_thread_func, &next);
55 thread_join (tid_next);
57 printf ("Thread %d done.\n", value);