Rev 2071 | Rev 3069 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2071 | Rev 2216 | ||
|---|---|---|---|
| Line 72... | Line 72... | ||
| 72 | waitq_sleep(&can_start); |
72 | waitq_sleep(&can_start); |
| 73 | 73 | ||
| 74 | to = random(40000); |
74 | to = random(40000); |
| 75 | 75 | ||
| 76 | if (!sh_quiet) |
76 | if (!sh_quiet) |
| 77 | printf("cpu%d, tid %d w+ (%d)\n", CPU->id, THREAD->tid, to); |
77 | printf("cpu%d, tid %llu w+ (%d)\n", CPU->id, THREAD->tid, to); |
| 78 | 78 | ||
| 79 | rc = rwlock_write_lock_timeout(&rwlock, to); |
79 | rc = rwlock_write_lock_timeout(&rwlock, to); |
| 80 | if (SYNCH_FAILED(rc)) { |
80 | if (SYNCH_FAILED(rc)) { |
| 81 | if (!sh_quiet) |
81 | if (!sh_quiet) |
| 82 | printf("cpu%d, tid %d w!\n", CPU->id, THREAD->tid); |
82 | printf("cpu%d, tid %llu w!\n", CPU->id, THREAD->tid); |
| 83 | atomic_dec(&thread_count); |
83 | atomic_dec(&thread_count); |
| 84 | return; |
84 | return; |
| 85 | } |
85 | } |
| 86 | 86 | ||
| 87 | if (!sh_quiet) |
87 | if (!sh_quiet) |
| 88 | printf("cpu%d, tid %d w=\n", CPU->id, THREAD->tid); |
88 | printf("cpu%d, tid %llu w=\n", CPU->id, THREAD->tid); |
| 89 | 89 | ||
| 90 | if (rwlock.readers_in) { |
90 | if (rwlock.readers_in) { |
| 91 | if (!sh_quiet) |
91 | if (!sh_quiet) |
| 92 | printf("Oops."); |
92 | printf("Oops."); |
| 93 | atomic_inc(&threads_fault); |
93 | atomic_inc(&threads_fault); |
| Line 104... | Line 104... | ||
| 104 | } |
104 | } |
| 105 | 105 | ||
| 106 | rwlock_write_unlock(&rwlock); |
106 | rwlock_write_unlock(&rwlock); |
| 107 | 107 | ||
| 108 | if (!sh_quiet) |
108 | if (!sh_quiet) |
| 109 | printf("cpu%d, tid %d w-\n", CPU->id, THREAD->tid); |
109 | printf("cpu%d, tid %llu w-\n", CPU->id, THREAD->tid); |
| 110 | atomic_dec(&thread_count); |
110 | atomic_dec(&thread_count); |
| 111 | } |
111 | } |
| 112 | 112 | ||
| 113 | static void reader(void *arg) |
113 | static void reader(void *arg) |
| 114 | { |
114 | { |
| Line 117... | Line 117... | ||
| 117 | waitq_sleep(&can_start); |
117 | waitq_sleep(&can_start); |
| 118 | 118 | ||
| 119 | to = random(2000); |
119 | to = random(2000); |
| 120 | 120 | ||
| 121 | if (!sh_quiet) |
121 | if (!sh_quiet) |
| 122 | printf("cpu%d, tid %d r+ (%d)\n", CPU->id, THREAD->tid, to); |
122 | printf("cpu%d, tid %llu r+ (%d)\n", CPU->id, THREAD->tid, to); |
| 123 | 123 | ||
| 124 | rc = rwlock_read_lock_timeout(&rwlock, to); |
124 | rc = rwlock_read_lock_timeout(&rwlock, to); |
| 125 | if (SYNCH_FAILED(rc)) { |
125 | if (SYNCH_FAILED(rc)) { |
| 126 | if (!sh_quiet) |
126 | if (!sh_quiet) |
| 127 | printf("cpu%d, tid %d r!\n", CPU->id, THREAD->tid); |
127 | printf("cpu%d, tid %llu r!\n", CPU->id, THREAD->tid); |
| 128 | atomic_dec(&thread_count); |
128 | atomic_dec(&thread_count); |
| 129 | return; |
129 | return; |
| 130 | } |
130 | } |
| 131 | 131 | ||
| 132 | if (!sh_quiet) |
132 | if (!sh_quiet) |
| 133 | printf("cpu%d, tid %d r=\n", CPU->id, THREAD->tid); |
133 | printf("cpu%d, tid %llu r=\n", CPU->id, THREAD->tid); |
| 134 | 134 | ||
| 135 | thread_usleep(30000); |
135 | thread_usleep(30000); |
| 136 | rwlock_read_unlock(&rwlock); |
136 | rwlock_read_unlock(&rwlock); |
| 137 | 137 | ||
| 138 | if (!sh_quiet) |
138 | if (!sh_quiet) |
| 139 | printf("cpu%d, tid %d r-\n", CPU->id, THREAD->tid); |
139 | printf("cpu%d, tid %llu r-\n", CPU->id, THREAD->tid); |
| 140 | atomic_dec(&thread_count); |
140 | atomic_dec(&thread_count); |
| 141 | } |
141 | } |
| 142 | 142 | ||
| 143 | char * test_rwlock4(bool quiet) |
143 | char * test_rwlock4(bool quiet) |
| 144 | { |
144 | { |