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