Changeset cb01e1e in mainline for kernel/test/synch/rwlock5.c
- Timestamp:
- 2009-04-04T00:26:27Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a85aebd
- Parents:
- 171f9a1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/synch/rwlock5.c
r171f9a1 rcb01e1e 36 36 #include <synch/rwlock.h> 37 37 38 #define READERS 39 #define WRITERS 38 #define READERS 50 39 #define WRITERS 50 40 40 41 41 static rwlock_t rwlock; … … 48 48 { 49 49 thread_detach(THREAD); 50 50 51 51 waitq_sleep(&can_start); 52 52 53 53 rwlock_write_lock(&rwlock); 54 54 atomic_inc(&items_written); … … 59 59 { 60 60 thread_detach(THREAD); 61 61 62 62 waitq_sleep(&can_start); 63 63 … … 67 67 } 68 68 69 char * test_rwlock5(bool quiet)69 char *test_rwlock5(void) 70 70 { 71 71 int i, j, k; … … 77 77 for (i = 1; i <= 3; i++) { 78 78 thread_t *thrd; 79 79 80 80 atomic_set(&items_read, 0); 81 81 atomic_set(&items_written, 0); 82 82 83 83 readers = i * READERS; 84 84 writers = (4 - i) * WRITERS; 85 86 printf("Creating %ld readers and %ld writers...", readers, writers);85 86 TPRINTF("Creating %ld readers and %ld writers...", readers, writers); 87 87 88 88 for (j = 0; j < (READERS + WRITERS) / 2; j++) { … … 92 92 thread_ready(thrd); 93 93 else 94 printf("Could not create reader %d\n", k);94 TPRINTF("Could not create reader %d\n", k); 95 95 } 96 96 for (k = 0; k < (4 - i); k++) { … … 99 99 thread_ready(thrd); 100 100 else 101 printf("Could not create writer %d\n", k);101 TPRINTF("Could not create writer %d\n", k); 102 102 } 103 103 } 104 105 printf("ok\n");106 104 105 TPRINTF("ok\n"); 106 107 107 thread_sleep(1); 108 108 waitq_wakeup(&can_start, WAKEUP_ALL); 109 109 110 110 while ((items_read.count != readers) || (items_written.count != writers)) { 111 printf("%d readers remaining, %d writers remaining, readers_in=%d\n", readers - items_read.count, writers - items_written.count, rwlock.readers_in);111 TPRINTF("%d readers remaining, %d writers remaining, readers_in=%d\n", readers - items_read.count, writers - items_written.count, rwlock.readers_in); 112 112 thread_usleep(100000); 113 113 }
Note:
See TracChangeset
for help on using the changeset viewer.