Rev 2022 | Rev 2029 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2022 | Rev 2028 | ||
---|---|---|---|
Line 35... | Line 35... | ||
35 | #include <mm/frame.h> |
35 | #include <mm/frame.h> |
36 | #include <memstr.h> |
36 | #include <memstr.h> |
37 | #include <synch/condvar.h> |
37 | #include <synch/condvar.h> |
38 | #include <synch/mutex.h> |
38 | #include <synch/mutex.h> |
39 | 39 | ||
40 | #ifdef CONFIG_BENCH |
- | |
41 | #include <arch/cycle.h> |
- | |
42 | #endif |
- | |
43 | - | ||
44 | #define ITEM_SIZE 256 |
40 | #define ITEM_SIZE 256 |
45 | 41 | ||
46 | /** Fill memory with 2 caches, when allocation fails, |
42 | /** Fill memory with 2 caches, when allocation fails, |
47 | * free one of the caches. We should have everything in magazines, |
43 | * free one of the caches. We should have everything in magazines, |
48 | * now allocation should clean magazines and allow for full allocation. |
44 | * now allocation should clean magazines and allow for full allocation. |
Line 170... | Line 166... | ||
170 | *((void **)data) = NULL; |
166 | *((void **)data) = NULL; |
171 | slab_free(thr_cache, data); |
167 | slab_free(thr_cache, data); |
172 | data = new; |
168 | data = new; |
173 | } |
169 | } |
174 | 170 | ||
175 | - | ||
176 | printf("Thread #%d finished\n", THREAD->tid); |
171 | printf("Thread #%d finished\n", THREAD->tid); |
177 | slab_print_list(); |
172 | slab_print_list(); |
178 | semaphore_up(&thr_sem); |
173 | semaphore_up(&thr_sem); |
179 | } |
174 | } |
180 | 175 | ||
181 | - | ||
182 | static void multitest(int size) |
176 | static void multitest(int size) |
183 | { |
177 | { |
184 | /* Start 8 threads that just allocate as much as possible, |
178 | /* Start 8 threads that just allocate as much as possible, |
185 | * then release everything, then again allocate, then release |
179 | * then release everything, then again allocate, then release |
186 | */ |
180 | */ |
Line 195... | Line 189... | ||
195 | NULL, NULL, |
189 | NULL, NULL, |
196 | 0); |
190 | 0); |
197 | semaphore_initialize(&thr_sem,0); |
191 | semaphore_initialize(&thr_sem,0); |
198 | for (i=0; i<THREADS; i++) { |
192 | for (i = 0; i < THREADS; i++) { |
199 | if (!(t = thread_create(slabtest, NULL, TASK, 0, "slabtest"))) |
193 | if (!(t = thread_create(slabtest, NULL, TASK, 0, "slabtest"))) |
200 | panic("could not create thread\n"); |
194 | printf("Could not create thread %d\n", i); |
- | 195 | else |
|
201 | thread_ready(t); |
196 | thread_ready(t); |
202 | } |
197 | } |
203 | thread_sleep(1); |
198 | thread_sleep(1); |
204 | condvar_broadcast(&thread_starter); |
199 | condvar_broadcast(&thread_starter); |
205 | 200 | ||
Line 208... | Line 203... | ||
208 | 203 | ||
209 | slab_cache_destroy(thr_cache); |
204 | slab_cache_destroy(thr_cache); |
210 | printf("Stress test complete.\n"); |
205 | printf("Stress test complete.\n"); |
211 | } |
206 | } |
212 | 207 | ||
213 | void test_slab2(void) |
208 | char * test_slab2(void) |
214 | { |
209 | { |
215 | #ifdef CONFIG_BENCH |
- | |
216 | uint64_t t0 = get_cycle(); |
- | |
217 | #endif |
- | |
218 | - | ||
219 | printf("Running reclaim single-thread test .. pass1\n"); |
210 | printf("Running reclaim single-thread test .. pass 1\n"); |
220 | totalmemtest(); |
211 | totalmemtest(); |
221 | printf("Running reclaim single-thread test .. pass2\n"); |
212 | printf("Running reclaim single-thread test .. pass 2\n"); |
222 | totalmemtest(); |
213 | totalmemtest(); |
223 | printf("Reclaim test OK.\n"); |
214 | printf("Reclaim test OK.\n"); |
Line 225... | Line 216... | ||
225 | multitest(128); |
216 | multitest(128); |
226 | multitest(2048); |
217 | multitest(2048); |
227 | multitest(8192); |
218 | multitest(8192); |
228 | printf("All done.\n"); |
219 | printf("All done.\n"); |
229 | 220 | ||
230 | #ifdef CONFIG_BENCH |
- | |
231 | uint64_t dt = get_cycle() - t0; |
- | |
232 | printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt); |
- | |
233 | #endif |
221 | return NULL; |
234 | } |
222 | } |