Changes in kernel/test/mm/slab2.c [0f4f1b2:bab75df6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/mm/slab2.c
r0f4f1b2 rbab75df6 32 32 #include <arch.h> 33 33 #include <mm/frame.h> 34 #include <mem w.h>34 #include <mem.h> 35 35 #include <synch/condvar.h> 36 36 #include <synch/mutex.h> … … 127 127 128 128 static slab_cache_t *thr_cache; 129 static semaphore_t thr_sem; 129 130 static condvar_t thread_starter; 130 131 static mutex_t starter_mutex; … … 135 136 { 136 137 void *data = NULL, *new; 138 139 thread_detach(THREAD); 137 140 138 141 mutex_lock(&starter_mutex); … … 187 190 if (!test_quiet) 188 191 slab_print_list(); 192 193 semaphore_up(&thr_sem); 189 194 } 190 195 … … 195 200 * then release everything, then again allocate, then release 196 201 */ 202 thread_t *t; 203 int i; 197 204 198 205 TPRINTF("Running stress test with size %d\n", size); … … 202 209 203 210 thr_cache = slab_cache_create("thread_cache", size, 0, NULL, NULL, 0); 204 205 thread_t *threads[THREADS] = { }; 206 207 for (int i = 0; i < THREADS; i++) { 208 threads[i] = thread_create(slabtest, NULL, 209 TASK, THREAD_FLAG_NONE, "slabtest"); 210 if (threads[i]) { 211 thread_start(threads[i]); 212 } else { 211 semaphore_initialize(&thr_sem, 0); 212 for (i = 0; i < THREADS; i++) { 213 if (!(t = thread_create(slabtest, NULL, TASK, THREAD_FLAG_NONE, "slabtest"))) { 213 214 TPRINTF("Could not create thread %d\n", i); 214 } 215 }216 215 } else 216 thread_ready(t); 217 } 217 218 thread_sleep(1); 218 219 condvar_broadcast(&thread_starter); 219 220 220 for (int i = 0; i < THREADS; i++) { 221 if (threads[i] != NULL) 222 thread_join(threads[i]); 223 } 221 for (i = 0; i < THREADS; i++) 222 semaphore_down(&thr_sem); 224 223 225 224 slab_cache_destroy(thr_cache);
Note:
See TracChangeset
for help on using the changeset viewer.