Changes in kernel/test/mm/slab1.c [abf6c01:0f4f1b2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/mm/slab1.c
rabf6c01 r0f4f1b2 31 31 #include <proc/thread.h> 32 32 #include <arch.h> 33 #include <mem .h>33 #include <memw.h> 34 34 35 35 #define VAL_COUNT 1024 … … 121 121 static void *thr_data[THREADS][THR_MEM_COUNT]; 122 122 static slab_cache_t *thr_cache; 123 static semaphore_t thr_sem;124 123 125 124 static void slabtest(void *data) … … 127 126 int offs = (int) (sysarg_t) data; 128 127 int i, j; 129 130 thread_detach(THREAD);131 128 132 129 TPRINTF("Starting thread #%" PRIu64 "...\n", THREAD->tid); … … 144 141 145 142 TPRINTF("Thread #%" PRIu64 " finished\n", THREAD->tid); 146 147 semaphore_up(&thr_sem);148 143 } 149 144 150 145 static void testthreads(void) 151 146 { 152 thread_t *t;153 int i;154 155 147 thr_cache = slab_cache_create("thread_cache", THR_MEM_SIZE, 0, NULL, NULL, 156 148 SLAB_CACHE_NOMAGAZINE); 157 149 158 semaphore_initialize(&thr_sem, 0); 159 for (i = 0; i < THREADS; i++) { 160 if (!(t = thread_create(slabtest, (void *) (sysarg_t) i, TASK, THREAD_FLAG_NONE, "slabtest"))) { 150 thread_t *threads[THREADS] = { }; 151 152 for (int i = 0; i < THREADS; i++) { 153 threads[i] = thread_create(slabtest, (void *) (sysarg_t) i, 154 TASK, THREAD_FLAG_NONE, "slabtest"); 155 if (threads[i]) { 156 thread_start(threads[i]); 157 } else { 161 158 TPRINTF("Could not create thread %d\n", i); 162 } else 163 thread_ready(t); 159 } 164 160 } 165 161 166 for (i = 0; i < THREADS; i++) 167 semaphore_down(&thr_sem); 162 for (int i = 0; i < THREADS; i++) { 163 if (threads[i] != NULL) 164 thread_join(threads[i]); 165 } 168 166 169 167 slab_cache_destroy(thr_cache);
Note:
See TracChangeset
for help on using the changeset viewer.