Rev 2229 | Rev 2479 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2229 | Rev 2230 | ||
---|---|---|---|
Line 31... | Line 31... | ||
31 | 31 | ||
32 | #include <atomic.h> |
32 | #include <atomic.h> |
33 | #include <thread.h> |
33 | #include <thread.h> |
34 | #include <stdio.h> |
34 | #include <stdio.h> |
35 | #include <unistd.h> |
35 | #include <unistd.h> |
36 | #include <futex.h> |
- | |
37 | #include "../tester.h" |
36 | #include "../tester.h" |
38 | 37 | ||
39 | static atomic_t finish; |
38 | static atomic_t finish; |
40 | static atomic_t threads_finished; |
39 | static atomic_t threads_finished; |
41 | static bool sh_quiet; |
40 | static bool sh_quiet; |
42 | 41 | ||
43 | static atomic_t srlz = FUTEX_INITIALIZER; |
- | |
44 | - | ||
45 | static void threadtest(void *data) |
42 | static void threadtest(void *data) |
46 | { |
43 | { |
47 | thread_detach(thread_get_id()); |
44 | thread_detach(thread_get_id()); |
48 | 45 | ||
49 | while (atomic_get(&finish)) { |
46 | while (atomic_get(&finish)) { |
50 | if (!sh_quiet) { |
47 | if (!sh_quiet) |
51 | futex_down(&srlz); |
- | |
52 | printf("%llu ", thread_get_id()); |
48 | printf("%llu ", thread_get_id()); |
53 | futex_up(&srlz); |
- | |
54 | } |
- | |
55 | usleep(100000); |
49 | usleep(100000); |
56 | } |
50 | } |
57 | atomic_inc(&threads_finished); |
51 | atomic_inc(&threads_finished); |
58 | } |
52 | } |
59 | 53 | ||
Line 72... | Line 66... | ||
72 | break; |
66 | break; |
73 | } |
67 | } |
74 | total++; |
68 | total++; |
75 | } |
69 | } |
76 | 70 | ||
77 | if (!quiet) { |
71 | if (!quiet) |
78 | futex_down(&srlz); |
- | |
79 | printf("Running threads for 10 seconds...\n"); |
72 | printf("Running threads for 10 seconds...\n"); |
80 | futex_up(&srlz); |
- | |
81 | } |
- | |
82 | sleep(10); |
73 | sleep(10); |
83 | 74 | ||
84 | atomic_set(&finish, 0); |
75 | atomic_set(&finish, 0); |
85 | while (atomic_get(&threads_finished) < total) { |
76 | while (atomic_get(&threads_finished) < total) { |
86 | if (!quiet) |
77 | if (!quiet) |