Ignore:
File:
1 edited

Legend:

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

    r0f4f1b2 rbab75df6  
    3232#include <arch.h>
    3333#include <mm/frame.h>
    34 #include <memw.h>
     34#include <mem.h>
    3535#include <synch/condvar.h>
    3636#include <synch/mutex.h>
     
    127127
    128128static slab_cache_t *thr_cache;
     129static semaphore_t thr_sem;
    129130static condvar_t thread_starter;
    130131static mutex_t starter_mutex;
     
    135136{
    136137        void *data = NULL, *new;
     138
     139        thread_detach(THREAD);
    137140
    138141        mutex_lock(&starter_mutex);
     
    187190        if (!test_quiet)
    188191                slab_print_list();
     192
     193        semaphore_up(&thr_sem);
    189194}
    190195
     
    195200         * then release everything, then again allocate, then release
    196201         */
     202        thread_t *t;
     203        int i;
    197204
    198205        TPRINTF("Running stress test with size %d\n", size);
     
    202209
    203210        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"))) {
    213214                        TPRINTF("Could not create thread %d\n", i);
    214                 }
    215         }
    216 
     215                } else
     216                        thread_ready(t);
     217        }
    217218        thread_sleep(1);
    218219        condvar_broadcast(&thread_starter);
    219220
    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);
    224223
    225224        slab_cache_destroy(thr_cache);
Note: See TracChangeset for help on using the changeset viewer.