Changes in kernel/test/mm/slab1.c [0f4f1b2:abf6c01] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/test/mm/slab1.c

    r0f4f1b2 rabf6c01  
    3131#include <proc/thread.h>
    3232#include <arch.h>
    33 #include <memw.h>
     33#include <mem.h>
    3434
    3535#define VAL_COUNT  1024
     
    121121static void *thr_data[THREADS][THR_MEM_COUNT];
    122122static slab_cache_t *thr_cache;
     123static semaphore_t thr_sem;
    123124
    124125static void slabtest(void *data)
     
    126127        int offs = (int) (sysarg_t) data;
    127128        int i, j;
     129
     130        thread_detach(THREAD);
    128131
    129132        TPRINTF("Starting thread #%" PRIu64 "...\n", THREAD->tid);
     
    141144
    142145        TPRINTF("Thread #%" PRIu64 " finished\n", THREAD->tid);
     146
     147        semaphore_up(&thr_sem);
    143148}
    144149
    145150static void testthreads(void)
    146151{
     152        thread_t *t;
     153        int i;
     154
    147155        thr_cache = slab_cache_create("thread_cache", THR_MEM_SIZE, 0, NULL, NULL,
    148156            SLAB_CACHE_NOMAGAZINE);
    149157
    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 {
     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"))) {
    158161                        TPRINTF("Could not create thread %d\n", i);
    159                 }
     162                } else
     163                        thread_ready(t);
    160164        }
    161165
    162         for (int i = 0; i < THREADS; i++) {
    163                 if (threads[i] != NULL)
    164                         thread_join(threads[i]);
    165         }
     166        for (i = 0; i < THREADS; i++)
     167                semaphore_down(&thr_sem);
    166168
    167169        slab_cache_destroy(thr_cache);
Note: See TracChangeset for help on using the changeset viewer.