Ignore:
File:
1 edited

Legend:

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

    rbab75df6 r0f4f1b2  
    3232#include <arch.h>
    3333#include <mm/frame.h>
    34 #include <mem.h>
     34#include <memw.h>
    3535#include <synch/condvar.h>
    3636#include <synch/mutex.h>
     
    127127
    128128static slab_cache_t *thr_cache;
    129 static semaphore_t thr_sem;
    130129static condvar_t thread_starter;
    131130static mutex_t starter_mutex;
     
    136135{
    137136        void *data = NULL, *new;
    138 
    139         thread_detach(THREAD);
    140137
    141138        mutex_lock(&starter_mutex);
     
    190187        if (!test_quiet)
    191188                slab_print_list();
    192 
    193         semaphore_up(&thr_sem);
    194189}
    195190
     
    200195         * then release everything, then again allocate, then release
    201196         */
    202         thread_t *t;
    203         int i;
    204197
    205198        TPRINTF("Running stress test with size %d\n", size);
     
    209202
    210203        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 {
    214213                        TPRINTF("Could not create thread %d\n", i);
    215                 } else
    216                         thread_ready(t);
    217         }
     214                }
     215        }
     216
    218217        thread_sleep(1);
    219218        condvar_broadcast(&thread_starter);
    220219
    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        }
    223224
    224225        slab_cache_destroy(thr_cache);
Note: See TracChangeset for help on using the changeset viewer.