Update license section.
[pintos-anon] / grading / threads / join-no.c
1 /* Problem 1-2: Join tests.
2
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
7    arens. */
8
9 #include "threads/test.h"
10 #include <stdio.h>
11 #include "threads/interrupt.h"
12 #include "threads/thread.h"
13
14 static void no_test (void);
15
16 void
17 test (void) 
18 {
19   no_test ();
20 }
21
22 static thread_func simple_thread_func;
23
24 static void
25 no_test (void) 
26 {
27   tid_t tid0;
28   
29   printf ("\n"
30           "Testing no join.\n"
31           "Should just not crash.\n");
32   tid0 = thread_create ("0", PRI_DEFAULT, simple_thread_func, "0");
33   simple_thread_func ("1");
34   printf ("No join test done.\n");
35 }
36
37 void 
38 simple_thread_func (void *name_) 
39 {
40   const char *name = name_;
41   int i;
42   
43   for (i = 0; i < 5; i++) 
44     {
45       printf ("Thread %s iteration %d\n", name, i);
46       thread_yield ();
47     }
48   printf ("Thread %s done!\n", name);
49 }