Changeset 7e13972 in mainline for kernel/test/synch/rwlock4.c
- Timestamp:
- 2006-12-12T18:51:06Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cce6acf
- Parents:
- 96348adc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/synch/rwlock4.c
r96348adc r7e13972 35 35 #include <arch/context.h> 36 36 #include <context.h> 37 #include <panic.h>38 37 39 38 #include <synch/waitq.h> … … 46 45 47 46 static rwlock_t rwlock; 47 static atomic_t threads_fault; 48 48 49 49 SPINLOCK_INITIALIZE(rw_lock); … … 79 79 printf("cpu%d, tid %d w=\n", CPU->id, THREAD->tid); 80 80 81 if (rwlock.readers_in) panic("Oops."); 81 if (rwlock.readers_in) { 82 printf("Oops."); 83 atomic_inc(&threads_fault); 84 return; 85 } 82 86 thread_usleep(random(1000000)); 83 if (rwlock.readers_in) panic("Oops."); 87 if (rwlock.readers_in) { 88 printf("Oops."); 89 atomic_inc(&threads_fault); 90 return; 91 } 84 92 85 93 rwlock_write_unlock(&rwlock); … … 113 121 waitq_initialize(&can_start); 114 122 rwlock_initialize(&rwlock); 123 atomic_set(&threads_fault, 0); 115 124 116 125 thread_t *thrd; … … 131 140 k = random(5) + 1; 132 141 printf("Creating %d writers\n", k); 133 for (i =0; i<k; i++) {142 for (i = 0; i < k; i++) { 134 143 thrd = thread_create(writer, NULL, TASK, 0, "writer"); 135 144 if (thrd) … … 142 151 waitq_wakeup(&can_start, WAKEUP_ALL); 143 152 144 return NULL; 153 if (atomic_get(&threads_fault) == 0) 154 return NULL; 155 156 return "Test failed"; 145 157 }
Note:
See TracChangeset
for help on using the changeset viewer.