Rev 4337 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4337 | Rev 4342 | ||
---|---|---|---|
Line 100... | Line 100... | ||
100 | 100 | ||
101 | SPINLOCK_INITIALIZE(tidlock); |
101 | SPINLOCK_INITIALIZE(tidlock); |
102 | thread_id_t last_tid = 0; |
102 | thread_id_t last_tid = 0; |
103 | 103 | ||
104 | static slab_cache_t *thread_slab; |
104 | static slab_cache_t *thread_slab; |
105 | #ifdef ARCH_HAS_FPU |
105 | #ifdef CONFIG_FPU |
106 | slab_cache_t *fpu_context_slab; |
106 | slab_cache_t *fpu_context_slab; |
107 | #endif |
107 | #endif |
108 | 108 | ||
109 | /** Thread wrapper. |
109 | /** Thread wrapper. |
110 | * |
110 | * |
Line 159... | Line 159... | ||
159 | link_initialize(&t->th_link); |
159 | link_initialize(&t->th_link); |
160 | 160 | ||
161 | /* call the architecture-specific part of the constructor */ |
161 | /* call the architecture-specific part of the constructor */ |
162 | thr_constructor_arch(t); |
162 | thr_constructor_arch(t); |
163 | 163 | ||
164 | #ifdef ARCH_HAS_FPU |
164 | #ifdef CONFIG_FPU |
165 | #ifdef CONFIG_FPU_LAZY |
165 | #ifdef CONFIG_FPU_LAZY |
166 | t->saved_fpu_context = NULL; |
166 | t->saved_fpu_context = NULL; |
167 | #else |
167 | #else |
168 | t->saved_fpu_context = slab_alloc(fpu_context_slab, kmflags); |
168 | t->saved_fpu_context = slab_alloc(fpu_context_slab, kmflags); |
169 | if (!t->saved_fpu_context) |
169 | if (!t->saved_fpu_context) |
170 | return -1; |
170 | return -1; |
171 | #endif |
171 | #endif |
172 | #endif |
172 | #endif |
173 | 173 | ||
174 | t->kstack = (uint8_t *) frame_alloc(STACK_FRAMES, FRAME_KA | kmflags); |
174 | t->kstack = (uint8_t *) frame_alloc(STACK_FRAMES, FRAME_KA | kmflags); |
175 | if (!t->kstack) { |
175 | if (!t->kstack) { |
176 | #ifdef ARCH_HAS_FPU |
176 | #ifdef CONFIG_FPU |
177 | if (t->saved_fpu_context) |
177 | if (t->saved_fpu_context) |
178 | slab_free(fpu_context_slab, t->saved_fpu_context); |
178 | slab_free(fpu_context_slab, t->saved_fpu_context); |
179 | #endif |
179 | #endif |
180 | return -1; |
180 | return -1; |
181 | } |
181 | } |
Line 194... | Line 194... | ||
194 | 194 | ||
195 | /* call the architecture-specific part of the destructor */ |
195 | /* call the architecture-specific part of the destructor */ |
196 | thr_destructor_arch(t); |
196 | thr_destructor_arch(t); |
197 | 197 | ||
198 | frame_free(KA2PA(t->kstack)); |
198 | frame_free(KA2PA(t->kstack)); |
199 | #ifdef ARCH_HAS_FPU |
199 | #ifdef CONFIG_FPU |
200 | if (t->saved_fpu_context) |
200 | if (t->saved_fpu_context) |
201 | slab_free(fpu_context_slab, t->saved_fpu_context); |
201 | slab_free(fpu_context_slab, t->saved_fpu_context); |
202 | #endif |
202 | #endif |
203 | return 1; /* One page freed */ |
203 | return 1; /* One page freed */ |
204 | } |
204 | } |
Line 213... | Line 213... | ||
213 | THREAD = NULL; |
213 | THREAD = NULL; |
214 | atomic_set(&nrdy, 0); |
214 | atomic_set(&nrdy, 0); |
215 | thread_slab = slab_cache_create("thread_slab", sizeof(thread_t), 0, |
215 | thread_slab = slab_cache_create("thread_slab", sizeof(thread_t), 0, |
216 | thr_constructor, thr_destructor, 0); |
216 | thr_constructor, thr_destructor, 0); |
217 | 217 | ||
218 | #ifdef ARCH_HAS_FPU |
218 | #ifdef CONFIG_FPU |
219 | fpu_context_slab = slab_cache_create("fpu_slab", sizeof(fpu_context_t), |
219 | fpu_context_slab = slab_cache_create("fpu_slab", sizeof(fpu_context_t), |
220 | FPU_CONTEXT_ALIGN, NULL, NULL, 0); |
220 | FPU_CONTEXT_ALIGN, NULL, NULL, 0); |
221 | #endif |
221 | #endif |
222 | 222 | ||
223 | avltree_create(&threads_tree); |
223 | avltree_create(&threads_tree); |