Changeset 96348adc in mainline for kernel/test/synch/rwlock4.c
- Timestamp:
- 2006-12-12T17:24:58Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7e13972
- Parents:
- 34db7fa
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/synch/rwlock4.c
r34db7fa r96348adc 53 53 static uint32_t seed = 0xdeadbeef; 54 54 55 static uint32_t random(uint32_t max);56 57 static void writer(void *arg);58 static void reader(void *arg);59 static void failed(void);60 61 55 static uint32_t random(uint32_t max) 62 56 { … … 69 63 return rc; 70 64 } 71 72 65 73 66 static void writer(void *arg) … … 83 76 printf("cpu%d, tid %d w!\n", CPU->id, THREAD->tid); 84 77 return; 85 } ;78 } 86 79 printf("cpu%d, tid %d w=\n", CPU->id, THREAD->tid); 87 80 … … 113 106 } 114 107 115 static void failed(void) 116 { 117 printf("Test failed prematurely.\n"); 118 thread_exit(); 119 } 120 121 void test_rwlock4(void) 108 char * test_rwlock4(void) 122 109 { 123 110 context_t ctx; 124 111 uint32_t i, k; 125 112 126 printf("Read/write locks test #4\n");127 128 113 waitq_initialize(&can_start); 129 114 rwlock_initialize(&rwlock); 130 115 131 for (;;) { 132 thread_t *thrd; 133 134 context_save(&ctx); 135 printf("sp=%#x, readers_in=%d\n", ctx.sp, rwlock.readers_in); 136 137 k = random(7) + 1; 138 printf("Creating %d readers\n", k); 139 for (i=0; i<k; i++) { 140 thrd = thread_create(reader, NULL, TASK, 0, "reader"); 141 if (thrd) 142 thread_ready(thrd); 143 else 144 failed(); 145 } 116 thread_t *thrd; 117 118 context_save(&ctx); 119 printf("sp=%#x, readers_in=%d\n", ctx.sp, rwlock.readers_in); 120 121 k = random(7) + 1; 122 printf("Creating %d readers\n", k); 123 for (i = 0; i < k; i++) { 124 thrd = thread_create(reader, NULL, TASK, 0, "reader"); 125 if (thrd) 126 thread_ready(thrd); 127 else 128 printf("Could not create reader %d\n", i); 129 } 146 130 147 148 149 150 151 152 153 154 failed();155 156 157 158 159 }160 131 k = random(5) + 1; 132 printf("Creating %d writers\n", k); 133 for (i=0; i<k; i++) { 134 thrd = thread_create(writer, NULL, TASK, 0, "writer"); 135 if (thrd) 136 thread_ready(thrd); 137 else 138 printf("Could not create writer %d\n", i); 139 } 140 141 thread_usleep(20000); 142 waitq_wakeup(&can_start, WAKEUP_ALL); 143 144 return NULL; 161 145 }
Note:
See TracChangeset
for help on using the changeset viewer.