Rev 1658 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1658 | Rev 1780 | ||
---|---|---|---|
Line 47... | Line 47... | ||
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 | printf("Allocating %d items...", count); |
49 | printf("Allocating %d items...", count); |
50 | for (i=0; i < count; i++) { |
50 | for (i=0; i < count; i++) { |
51 | data[i] = slab_alloc(cache, 0); |
51 | data[i] = slab_alloc(cache, 0); |
52 | memsetb((__address)data[i], size, 0); |
52 | memsetb((uintptr_t)data[i], size, 0); |
53 | } |
53 | } |
54 | printf("done.\n"); |
54 | printf("done.\n"); |
55 | printf("Freeing %d items...", count); |
55 | printf("Freeing %d items...", count); |
56 | for (i=0; i < count; i++) { |
56 | for (i=0; i < count; i++) { |
57 | slab_free(cache, data[i]); |
57 | slab_free(cache, data[i]); |
Line 59... | Line 59... | ||
59 | printf("done.\n"); |
59 | printf("done.\n"); |
60 | 60 | ||
61 | printf("Allocating %d items...", count); |
61 | printf("Allocating %d items...", count); |
62 | for (i=0; i < count; i++) { |
62 | for (i=0; i < count; i++) { |
63 | data[i] = slab_alloc(cache, 0); |
63 | data[i] = slab_alloc(cache, 0); |
64 | memsetb((__address)data[i], size, 0); |
64 | memsetb((uintptr_t)data[i], size, 0); |
65 | } |
65 | } |
66 | printf("done.\n"); |
66 | printf("done.\n"); |
67 | 67 | ||
68 | printf("Freeing %d items...", count/2); |
68 | printf("Freeing %d items...", count/2); |
69 | for (i=count-1; i >= count/2; i--) { |
69 | for (i=count-1; i >= count/2; i--) { |
Line 72... | Line 72... | ||
72 | printf("done.\n"); |
72 | printf("done.\n"); |
73 | 73 | ||
74 | printf("Allocating %d items...", count/2); |
74 | printf("Allocating %d items...", count/2); |
75 | for (i=count/2; i < count; i++) { |
75 | for (i=count/2; i < count; i++) { |
76 | data[i] = slab_alloc(cache, 0); |
76 | data[i] = slab_alloc(cache, 0); |
77 | memsetb((__address)data[i], size, 0); |
77 | memsetb((uintptr_t)data[i], size, 0); |
78 | } |
78 | } |
79 | printf("done.\n"); |
79 | printf("done.\n"); |
80 | printf("Freeing %d items...", count); |
80 | printf("Freeing %d items...", count); |
81 | for (i=0; i < count; i++) { |
81 | for (i=0; i < count; i++) { |
82 | slab_free(cache, data[i]); |
82 | slab_free(cache, data[i]); |
Line 108... | Line 108... | ||
108 | slab_cache_t *thr_cache; |
108 | slab_cache_t *thr_cache; |
109 | semaphore_t thr_sem; |
109 | semaphore_t thr_sem; |
110 | 110 | ||
111 | static void slabtest(void *data) |
111 | static void slabtest(void *data) |
112 | { |
112 | { |
113 | int offs = (int)(__native) data; |
113 | int offs = (int)(unative_t) data; |
114 | int i,j; |
114 | int i,j; |
115 | 115 | ||
116 | thread_detach(THREAD); |
116 | thread_detach(THREAD); |
117 | 117 | ||
118 | printf("Starting thread #%d...\n",THREAD->tid); |
118 | printf("Starting thread #%d...\n",THREAD->tid); |
Line 138... | Line 138... | ||
138 | thr_cache = slab_cache_create("thread_cache", THR_MEM_SIZE, 0, |
138 | thr_cache = slab_cache_create("thread_cache", THR_MEM_SIZE, 0, |
139 | NULL, NULL, |
139 | NULL, NULL, |
140 | SLAB_CACHE_NOMAGAZINE); |
140 | SLAB_CACHE_NOMAGAZINE); |
141 | semaphore_initialize(&thr_sem,0); |
141 | semaphore_initialize(&thr_sem,0); |
142 | for (i=0; i<THREADS; i++) { |
142 | for (i=0; i<THREADS; i++) { |
143 | if (!(t = thread_create(slabtest, (void *)(__native)i, TASK, 0, "slabtest"))) |
143 | if (!(t = thread_create(slabtest, (void *)(unative_t)i, TASK, 0, "slabtest"))) |
144 | panic("could not create thread\n"); |
144 | panic("could not create thread\n"); |
145 | thread_ready(t); |
145 | thread_ready(t); |
146 | } |
146 | } |
147 | 147 | ||
148 | for (i=0; i<THREADS; i++) |
148 | for (i=0; i<THREADS; i++) |