Ignore:
File:
1 edited

Legend:

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

    r0f4f1b2 raafed15  
    3535#include <atomic.h>
    3636#include <proc/thread.h>
    37 #include <memw.h>
     37#include <mem.h>
    3838#include <arch.h>
    3939
     
    4343#define THREADS      8
    4444
    45 static atomic_size_t thread_fail;
     45static atomic_t thread_cnt;
     46static atomic_t thread_fail;
    4647
    4748static void falloc(void *arg)
     
    5556                    "Unable to allocate frames\n", THREAD->tid, CPU->id);
    5657                atomic_inc(&thread_fail);
     58                atomic_dec(&thread_cnt);
    5759                return;
    5860        }
     61
     62        thread_detach(THREAD);
    5963
    6064        for (unsigned int run = 0; run < THREAD_RUNS; run++) {
     
    106110        TPRINTF("Thread #%" PRIu64 " (cpu%u): Exiting\n",
    107111            THREAD->tid, CPU->id);
     112        atomic_dec(&thread_cnt);
    108113}
    109114
    110115const char *test_falloc2(void)
    111116{
     117        atomic_store(&thread_cnt, THREADS);
    112118        atomic_store(&thread_fail, 0);
    113 
    114         thread_t *threads[THREADS] = { };
    115119
    116120        for (unsigned int i = 0; i < THREADS; i++) {
     
    121125                        break;
    122126                }
    123                 thread_start(thrd);
    124                 threads[i] = thrd;
     127                thread_ready(thrd);
    125128        }
    126129
    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);
     130        while (atomic_load(&thread_cnt) > 0) {
     131                TPRINTF("Threads left: %zu\n",
     132                    atomic_load(&thread_cnt));
     133                thread_sleep(1);
    132134        }
    133135
Note: See TracChangeset for help on using the changeset viewer.