Changes in kernel/test/mm/falloc2.c [0f4f1b2:aafed15] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/mm/falloc2.c
r0f4f1b2 raafed15 35 35 #include <atomic.h> 36 36 #include <proc/thread.h> 37 #include <mem w.h>37 #include <mem.h> 38 38 #include <arch.h> 39 39 … … 43 43 #define THREADS 8 44 44 45 static atomic_size_t thread_fail; 45 static atomic_t thread_cnt; 46 static atomic_t thread_fail; 46 47 47 48 static void falloc(void *arg) … … 55 56 "Unable to allocate frames\n", THREAD->tid, CPU->id); 56 57 atomic_inc(&thread_fail); 58 atomic_dec(&thread_cnt); 57 59 return; 58 60 } 61 62 thread_detach(THREAD); 59 63 60 64 for (unsigned int run = 0; run < THREAD_RUNS; run++) { … … 106 110 TPRINTF("Thread #%" PRIu64 " (cpu%u): Exiting\n", 107 111 THREAD->tid, CPU->id); 112 atomic_dec(&thread_cnt); 108 113 } 109 114 110 115 const char *test_falloc2(void) 111 116 { 117 atomic_store(&thread_cnt, THREADS); 112 118 atomic_store(&thread_fail, 0); 113 114 thread_t *threads[THREADS] = { };115 119 116 120 for (unsigned int i = 0; i < THREADS; i++) { … … 121 125 break; 122 126 } 123 thread_start(thrd); 124 threads[i] = thrd; 127 thread_ready(thrd); 125 128 } 126 129 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); 132 134 } 133 135
Note:
See TracChangeset
for help on using the changeset viewer.