Changes in kernel/test/mm/falloc2.c [6eef3c4:9d58539] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/mm/falloc2.c
r6eef3c4 r9d58539 40 40 #include <arch.h> 41 41 42 #define MAX_FRAMES 256 U42 #define MAX_FRAMES 256 43 43 #define MAX_ORDER 8 44 44 … … 51 51 static void falloc(void *arg) 52 52 { 53 int order, run, allocated, i; 53 54 uint8_t val = THREAD->tid % THREADS; 55 size_t k; 54 56 55 void **frames = (void **) 56 malloc(MAX_FRAMES * sizeof(void *), FRAME_ATOMIC); 57 void **frames = (void **) malloc(MAX_FRAMES * sizeof(void *), FRAME_ATOMIC); 57 58 if (frames == NULL) { 58 TPRINTF("Thread #%" PRIu64 " (cpu%u): " 59 "Unable to allocate frames\n", THREAD->tid, CPU->id); 59 TPRINTF("Thread #%" PRIu64 " (cpu%u): Unable to allocate frames\n", THREAD->tid, CPU->id); 60 60 atomic_inc(&thread_fail); 61 61 atomic_dec(&thread_count); … … 65 65 thread_detach(THREAD); 66 66 67 for (unsigned int run = 0; run < THREAD_RUNS; run++) { 68 for (unsigned int order = 0; order <= MAX_ORDER; order++) { 69 TPRINTF("Thread #%" PRIu64 " (cpu%u): " 70 "Allocating %u frames blocks ... \n", THREAD->tid, 71 CPU->id, 1 << order); 67 for (run = 0; run < THREAD_RUNS; run++) { 68 for (order = 0; order <= MAX_ORDER; order++) { 69 TPRINTF("Thread #%" PRIu64 " (cpu%u): Allocating %d frames blocks ... \n", THREAD->tid, CPU->id, 1 << order); 72 70 73 unsigned int allocated = 0; 74 for (unsigned int i = 0; i < (MAX_FRAMES >> order); i++) { 75 frames[allocated] = 76 frame_alloc(order, FRAME_ATOMIC | FRAME_KA); 71 allocated = 0; 72 for (i = 0; i < (MAX_FRAMES >> order); i++) { 73 frames[allocated] = frame_alloc(order, FRAME_ATOMIC | FRAME_KA); 77 74 if (frames[allocated]) { 78 75 memsetb(frames[allocated], FRAME_SIZE << order, val); … … 82 79 } 83 80 84 TPRINTF("Thread #%" PRIu64 " (cpu%u): " 85 "%u blocks allocated.\n", THREAD->tid, CPU->id, 86 allocated); 87 TPRINTF("Thread #%" PRIu64 " (cpu%u): " 88 "Deallocating ... \n", THREAD->tid, CPU->id); 81 TPRINTF("Thread #%" PRIu64 " (cpu%u): %d blocks allocated.\n", THREAD->tid, CPU->id, allocated); 82 TPRINTF("Thread #%" PRIu64 " (cpu%u): Deallocating ... \n", THREAD->tid, CPU->id); 89 83 90 for (unsigned int i = 0; i < allocated; i++) { 91 for (size_t k = 0; k <= (((size_t) FRAME_SIZE << order) - 1); 92 k++) { 84 for (i = 0; i < allocated; i++) { 85 for (k = 0; k <= (((size_t) FRAME_SIZE << order) - 1); k++) { 93 86 if (((uint8_t *) frames[i])[k] != val) { 94 TPRINTF("Thread #%" PRIu64 " (cpu%u): " 95 "Unexpected data (%c) in block %p offset %zu\n", 96 THREAD->tid, CPU->id, ((char *) frames[i])[k], 97 frames[i], k); 87 TPRINTF("Thread #%" PRIu64 " (cpu%u): Unexpected data (%c) in block %p offset %zu\n", 88 THREAD->tid, CPU->id, ((char *) frames[i])[k], frames[i], k); 98 89 atomic_inc(&thread_fail); 99 90 goto cleanup; … … 103 94 } 104 95 105 TPRINTF("Thread #%" PRIu64 " (cpu%u): " 106 "Finished run.\n", THREAD->tid, CPU->id); 96 TPRINTF("Thread #%" PRIu64 " (cpu%u): Finished run.\n", THREAD->tid, CPU->id); 107 97 } 108 98 } … … 111 101 free(frames); 112 102 113 TPRINTF("Thread #%" PRIu64 " (cpu%u): Exiting\n", 114 THREAD->tid, CPU->id); 103 TPRINTF("Thread #%" PRIu64 " (cpu%u): Exiting\n", THREAD->tid, CPU->id); 115 104 atomic_dec(&thread_count); 116 105 } … … 118 107 const char *test_falloc2(void) 119 108 { 109 unsigned int i; 110 120 111 atomic_set(&thread_count, THREADS); 121 112 atomic_set(&thread_fail, 0); 122 113 123 for (unsigned int i = 0; i < THREADS; i++) { 124 thread_t *thrd = thread_create(falloc, NULL, TASK, 125 THREAD_FLAG_NONE, "falloc2"); 114 for (i = 0; i < THREADS; i++) { 115 thread_t * thrd = thread_create(falloc, NULL, TASK, 0, "falloc", false); 126 116 if (!thrd) { 127 117 TPRINTF("Could not create thread %u\n", i); … … 132 122 133 123 while (atomic_get(&thread_count) > 0) { 134 TPRINTF("Threads left: %" PRIua "\n", 135 atomic_get(&thread_count)); 124 TPRINTF("Threads left: %" PRIua "\n", atomic_get(&thread_count)); 136 125 thread_sleep(1); 137 126 }
Note:
See TracChangeset
for help on using the changeset viewer.