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 32... | Line 32... | ||
32 | #include <proc/thread.h> |
32 | #include <proc/thread.h> |
33 | #include <arch.h> |
33 | #include <arch.h> |
34 | #include <panic.h> |
34 | #include <panic.h> |
35 | #include <memstr.h> |
35 | #include <memstr.h> |
36 | 36 | ||
37 | #ifdef CONFIG_BENCH |
- | |
38 | #include <arch/cycle.h> |
- | |
39 | #endif |
- | |
40 | - | ||
41 | #define VAL_COUNT 1024 |
37 | #define VAL_COUNT 1024 |
42 | 38 | ||
43 | static void * data[VAL_COUNT]; |
39 | static void * data[VAL_COUNT]; |
44 | 40 | ||
45 | static void testit(int size, int count) |
41 | static void testit(int size, int count) |
Line 101... | Line 97... | ||
101 | testit(8192, 128); |
97 | testit(8192, 128); |
102 | testit(16384, 128); |
98 | testit(16384, 128); |
103 | testit(16385, 128); |
99 | testit(16385, 128); |
104 | } |
100 | } |
105 | 101 | ||
106 | - | ||
107 | #define THREADS 6 |
102 | #define THREADS 6 |
108 | #define THR_MEM_COUNT 1024 |
103 | #define THR_MEM_COUNT 1024 |
109 | #define THR_MEM_SIZE 128 |
104 | #define THR_MEM_SIZE 128 |
110 | 105 | ||
111 | void * thr_data[THREADS][THR_MEM_COUNT]; |
106 | static void * thr_data[THREADS][THR_MEM_COUNT]; |
112 | slab_cache_t *thr_cache; |
107 | static slab_cache_t *thr_cache; |
113 | semaphore_t thr_sem; |
108 | static semaphore_t thr_sem; |
114 | 109 | ||
115 | static void slabtest(void *data) |
110 | static void slabtest(void *data) |
116 | { |
111 | { |
117 | int offs = (int)(unative_t) data; |
112 | int offs = (int) (unative_t) data; |
118 | int i,j; |
113 | int i, j; |
Line 143... | Line 138... | ||
143 | NULL, NULL, |
138 | NULL, NULL, |
144 | SLAB_CACHE_NOMAGAZINE); |
139 | SLAB_CACHE_NOMAGAZINE); |
145 | semaphore_initialize(&thr_sem,0); |
140 | semaphore_initialize(&thr_sem, 0); |
146 | for (i=0; i<THREADS; i++) { |
141 | for (i = 0; i < THREADS; i++) { |
147 | if (!(t = thread_create(slabtest, (void *)(unative_t)i, TASK, 0, "slabtest"))) |
142 | if (!(t = thread_create(slabtest, (void *) (unative_t) i, TASK, 0, "slabtest"))) |
148 | panic("could not create thread\n"); |
143 | printf("Could not create thread %d\n", i); |
- | 144 | else |
|
149 | thread_ready(t); |
145 | thread_ready(t); |
150 | } |
146 | } |
151 | 147 | ||
152 | for (i=0; i<THREADS; i++) |
148 | for (i = 0; i < THREADS; i++) |
153 | semaphore_down(&thr_sem); |
149 | semaphore_down(&thr_sem); |
Line 155... | Line 151... | ||
155 | slab_cache_destroy(thr_cache); |
151 | slab_cache_destroy(thr_cache); |
156 | printf("Test complete.\n"); |
152 | printf("Test complete.\n"); |
157 | 153 | ||
158 | } |
154 | } |
159 | 155 | ||
160 | void test_slab1(void) |
156 | char * test_slab1(void) |
161 | { |
157 | { |
162 | #ifdef CONFIG_BENCH |
- | |
163 | uint64_t t0 = get_cycle(); |
- | |
164 | #endif |
- | |
165 | testsimple(); |
158 | testsimple(); |
166 | testthreads(); |
159 | testthreads(); |
167 | #ifdef CONFIG_BENCH |
160 | |
168 | uint64_t dt = get_cycle() - t0; |
- | |
169 | printf("Time: %.*d cycles\n", sizeof(dt) * 2, dt); |
- | |
170 | #endif |
161 | return NULL; |
171 | } |
162 | } |