Rev 768 | Rev 1062 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 768 | Rev 772 | ||
---|---|---|---|
Line 43... | Line 43... | ||
43 | slab_cache_t *cache; |
43 | slab_cache_t *cache; |
44 | int i; |
44 | int i; |
45 | 45 | ||
46 | printf("Creating cache, object size: %d.\n", size); |
46 | printf("Creating cache, object size: %d.\n", size); |
47 | cache = slab_cache_create("test_cache", size, 0, NULL, NULL, |
47 | cache = slab_cache_create("test_cache", size, 0, NULL, NULL, |
48 | SLAB_CACHE_NOMAGAZINE); |
48 | SLAB_CACHE_NOMAGAZINE); |
49 | slab_print_list(); |
- | |
50 | - | ||
51 | printf("Allocating %d items...", count); |
49 | printf("Allocating %d items...", count); |
52 | for (i=0; i < count; i++) { |
50 | for (i=0; i < count; i++) { |
53 | data[i] = slab_alloc(cache, 0); |
51 | data[i] = slab_alloc(cache, 0); |
54 | memsetb((__address)data[i], size, 0); |
52 | memsetb((__address)data[i], size, 0); |
55 | } |
53 | } |
Line 65... | Line 63... | ||
65 | data[i] = slab_alloc(cache, 0); |
63 | data[i] = slab_alloc(cache, 0); |
66 | memsetb((__address)data[i], size, 0); |
64 | memsetb((__address)data[i], size, 0); |
67 | } |
65 | } |
68 | printf("done.\n"); |
66 | printf("done.\n"); |
69 | 67 | ||
70 | slab_print_list(); |
- | |
71 | printf("Freeing %d items...", count/2); |
68 | printf("Freeing %d items...", count/2); |
72 | for (i=count-1; i >= count/2; i--) { |
69 | for (i=count-1; i >= count/2; i--) { |
73 | slab_free(cache, data[i]); |
70 | slab_free(cache, data[i]); |
74 | } |
71 | } |
75 | printf("done.\n"); |
72 | printf("done.\n"); |
Line 126... | Line 123... | ||
126 | thr_data[offs][i] = slab_alloc(thr_cache, 0); |
123 | thr_data[offs][i] = slab_alloc(thr_cache, 0); |
127 | for (i=0; i<THR_MEM_COUNT;i++) |
124 | for (i=0; i<THR_MEM_COUNT;i++) |
128 | slab_free(thr_cache, thr_data[offs][i]); |
125 | slab_free(thr_cache, thr_data[offs][i]); |
129 | } |
126 | } |
130 | printf("Thread #%d finished\n", THREAD->tid); |
127 | printf("Thread #%d finished\n", THREAD->tid); |
131 | slab_print_list(); |
- | |
132 | semaphore_up(&thr_sem); |
128 | semaphore_up(&thr_sem); |
133 | } |
129 | } |
134 | 130 | ||
135 | static void testthreads(void) |
131 | static void testthreads(void) |
136 | { |
132 | { |