Rev 1104 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1104 | Rev 1196 | ||
---|---|---|---|
Line 89... | Line 89... | ||
89 | atomic_set(&items_written, 0); |
89 | atomic_set(&items_written, 0); |
90 | 90 | ||
91 | readers = i*READERS; |
91 | readers = i*READERS; |
92 | writers = (4-i)*WRITERS; |
92 | writers = (4-i)*WRITERS; |
93 | 93 | ||
94 | printf("Creating %d readers and %d writers...", readers, writers); |
94 | printf("Creating %ld readers and %ld writers...", readers, writers); |
95 | 95 | ||
96 | for (j=0; j<(READERS+WRITERS)/2; j++) { |
96 | for (j=0; j<(READERS+WRITERS)/2; j++) { |
97 | for (k=0; k<i; k++) { |
97 | for (k=0; k<i; k++) { |
98 | thrd = thread_create(reader, NULL, TASK, 0, "reader"); |
98 | thrd = thread_create(reader, NULL, TASK, 0, "reader"); |
99 | if (thrd) |
99 | if (thrd) |
Line 114... | Line 114... | ||
114 | 114 | ||
115 | thread_sleep(1); |
115 | thread_sleep(1); |
116 | waitq_wakeup(&can_start, WAKEUP_ALL); |
116 | waitq_wakeup(&can_start, WAKEUP_ALL); |
117 | 117 | ||
118 | while (items_read.count != readers || items_written.count != writers) { |
118 | while (items_read.count != readers || items_written.count != writers) { |
119 | printf("%d readers remaining, %d writers remaining, readers_in=%d\n", readers - items_read.count, writers - items_written.count, rwlock.readers_in); |
119 | printf("%zd readers remaining, %zd writers remaining, readers_in=%zd\n", readers - items_read.count, writers - items_written.count, rwlock.readers_in); |
120 | thread_usleep(100000); |
120 | thread_usleep(100000); |
121 | } |
121 | } |
122 | } |
122 | } |
123 | printf("Test passed.\n"); |
123 | printf("Test passed.\n"); |
124 | } |
124 | } |