Changeset a35b458 in mainline for kernel/test/mm/slab1.c
- Timestamp:
- 2018-03-02T20:10:49Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/test/mm/slab1.c
r3061bc1 ra35b458 42 42 slab_cache_t *cache; 43 43 int i; 44 44 45 45 TPRINTF("Creating cache, object size: %d.\n", size); 46 46 47 47 cache = slab_cache_create("test_cache", size, 0, NULL, NULL, 48 48 SLAB_CACHE_NOMAGAZINE); 49 49 50 50 TPRINTF("Allocating %d items...", count); 51 51 52 52 for (i = 0; i < count; i++) { 53 53 data[i] = slab_alloc(cache, 0); 54 54 memsetb(data[i], size, 0); 55 55 } 56 56 57 57 TPRINTF("done.\n"); 58 58 59 59 TPRINTF("Freeing %d items...", count); 60 60 61 61 for (i = 0; i < count; i++) 62 62 slab_free(cache, data[i]); 63 63 64 64 TPRINTF("done.\n"); 65 65 66 66 TPRINTF("Allocating %d items...", count); 67 67 68 68 for (i = 0; i < count; i++) { 69 69 data[i] = slab_alloc(cache, 0); 70 70 memsetb(data[i], size, 0); 71 71 } 72 72 73 73 TPRINTF("done.\n"); 74 74 75 75 TPRINTF("Freeing %d items...", count / 2); 76 76 77 77 for (i = count - 1; i >= count / 2; i--) 78 78 slab_free(cache, data[i]); 79 79 80 80 TPRINTF("done.\n"); 81 81 82 82 TPRINTF("Allocating %d items...", count / 2); 83 83 84 84 for (i = count / 2; i < count; i++) { 85 85 data[i] = slab_alloc(cache, 0); 86 86 memsetb(data[i], size, 0); 87 87 } 88 88 89 89 TPRINTF("done.\n"); 90 90 91 91 TPRINTF("Freeing %d items...", count); 92 92 93 93 for (i = 0; i < count; i++) 94 94 slab_free(cache, data[i]); 95 95 96 96 TPRINTF("done.\n"); 97 97 98 98 slab_cache_destroy(cache); 99 99 100 100 TPRINTF("Test complete.\n"); 101 101 } … … 125 125 int offs = (int) (sysarg_t) data; 126 126 int i, j; 127 127 128 128 thread_detach(THREAD); 129 129 130 130 TPRINTF("Starting thread #%" PRIu64 "...\n", THREAD->tid); 131 131 132 132 for (j = 0; j < 10; j++) { 133 133 for (i = 0; i < THR_MEM_COUNT; i++) … … 140 140 slab_free(thr_cache, thr_data[offs][i]); 141 141 } 142 142 143 143 TPRINTF("Thread #%" PRIu64 " finished\n", THREAD->tid); 144 144 145 145 semaphore_up(&thr_sem); 146 146 } … … 150 150 thread_t *t; 151 151 int i; 152 152 153 153 thr_cache = slab_cache_create("thread_cache", THR_MEM_SIZE, 0, NULL, NULL, 154 154 SLAB_CACHE_NOMAGAZINE); 155 155 156 156 semaphore_initialize(&thr_sem, 0); 157 157 for (i = 0; i < THREADS; i++) { … … 164 164 for (i = 0; i < THREADS; i++) 165 165 semaphore_down(&thr_sem); 166 166 167 167 slab_cache_destroy(thr_cache); 168 168 169 169 TPRINTF("Test complete.\n"); 170 170 } … … 174 174 testsimple(); 175 175 testthreads(); 176 176 177 177 return NULL; 178 178 }
Note:
See TracChangeset
for help on using the changeset viewer.