Ignore:
File:
1 edited

Legend:

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

    r31e15be r0f4f1b2  
    3535#include <atomic.h>
    3636#include <proc/thread.h>
    37 #include <mem.h>
     37#include <memw.h>
    3838#include <arch.h>
    3939
     
    4343#define THREADS      8
    4444
    45 static atomic_size_t thread_cnt;
    4645static atomic_size_t thread_fail;
    4746
     
    5655                    "Unable to allocate frames\n", THREAD->tid, CPU->id);
    5756                atomic_inc(&thread_fail);
    58                 atomic_dec(&thread_cnt);
    5957                return;
    6058        }
    61 
    62         thread_detach(THREAD);
    6359
    6460        for (unsigned int run = 0; run < THREAD_RUNS; run++) {
     
    110106        TPRINTF("Thread #%" PRIu64 " (cpu%u): Exiting\n",
    111107            THREAD->tid, CPU->id);
    112         atomic_dec(&thread_cnt);
    113108}
    114109
    115110const char *test_falloc2(void)
    116111{
    117         atomic_store(&thread_cnt, THREADS);
    118112        atomic_store(&thread_fail, 0);
     113
     114        thread_t *threads[THREADS] = { };
    119115
    120116        for (unsigned int i = 0; i < THREADS; i++) {
     
    125121                        break;
    126122                }
    127                 thread_ready(thrd);
     123                thread_start(thrd);
     124                threads[i] = thrd;
    128125        }
    129126
    130         while (atomic_load(&thread_cnt) > 0) {
    131                 TPRINTF("Threads left: %zu\n",
    132                     atomic_load(&thread_cnt));
    133                 thread_sleep(1);
     127        for (unsigned int i = 0; i < THREADS; i++) {
     128                if (threads[i] != NULL)
     129                        thread_join(threads[i]);
     130
     131                TPRINTF("Threads left: %u\n", THREADS - i - 1);
    134132        }
    135133
Note: See TracChangeset for help on using the changeset viewer.