Changes in kernel/generic/src/proc/thread.c [95d45482:aab5e46] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/proc/thread.c
r95d45482 raab5e46 48 48 #include <synch/spinlock.h> 49 49 #include <synch/waitq.h> 50 #include <synch/workqueue.h> 51 #include <synch/rcu.h> 50 52 #include <cpu.h> 51 53 #include <str.h> … … 67 69 #include <syscall/copy.h> 68 70 #include <errno.h> 69 #include <debug.h>70 71 71 72 /** Thread states */ … … 165 166 166 167 #ifdef CONFIG_FPU 167 thread->saved_fpu_context = slab_alloc(fpu_context_cache, 168 FRAME_ATOMIC | kmflags); 168 #ifdef CONFIG_FPU_LAZY 169 thread->saved_fpu_context = NULL; 170 #else /* CONFIG_FPU_LAZY */ 171 thread->saved_fpu_context = slab_alloc(fpu_context_cache, kmflags); 169 172 if (!thread->saved_fpu_context) 170 173 return ENOMEM; 174 #endif /* CONFIG_FPU_LAZY */ 171 175 #endif /* CONFIG_FPU */ 172 176 … … 190 194 kmflags &= ~FRAME_HIGHMEM; 191 195 192 // NOTE: All kernel stacks must be aligned to STACK_SIZE,193 // 196 // XXX: All kernel stacks must be aligned to STACK_SIZE, 197 // see get_stack_base(). 194 198 195 199 uintptr_t stack_phys = … … 197 201 if (!stack_phys) { 198 202 #ifdef CONFIG_FPU 199 assert(thread->saved_fpu_context);200 slab_free(fpu_context_cache, thread->saved_fpu_context);203 if (thread->saved_fpu_context) 204 slab_free(fpu_context_cache, thread->saved_fpu_context); 201 205 #endif 202 206 return ENOMEM; … … 223 227 224 228 #ifdef CONFIG_FPU 225 assert(thread->saved_fpu_context);226 slab_free(fpu_context_cache, thread->saved_fpu_context);229 if (thread->saved_fpu_context) 230 slab_free(fpu_context_cache, thread->saved_fpu_context); 227 231 #endif 228 232 … … 268 272 { 269 273 assert(irq_spinlock_locked(&thread->lock)); 274 workq_before_thread_is_ready(thread); 270 275 } 271 276 … … 339 344 thread_flags_t flags, const char *name) 340 345 { 341 thread_t *thread = (thread_t *) slab_alloc(thread_cache, FRAME_ATOMIC);346 thread_t *thread = (thread_t *) slab_alloc(thread_cache, 0); 342 347 if (!thread) 343 348 return NULL; 344 345 if (thread_create_arch(thread, flags) != EOK) {346 slab_free(thread_cache, thread);347 return NULL;348 }349 349 350 350 /* Not needed, but good for debugging */ … … 399 399 thread->task = task; 400 400 401 thread->workq = NULL; 402 401 403 thread->fpu_context_exists = false; 402 404 thread->fpu_context_engaged = false; … … 409 411 udebug_thread_initialize(&thread->udebug); 410 412 #endif 413 414 /* Might depend on previous initialization */ 415 thread_create_arch(thread); 416 417 rcu_thread_init(thread); 411 418 412 419 if ((flags & THREAD_FLAG_NOATTACH) != THREAD_FLAG_NOATTACH) … … 653 660 654 661 return waitq_sleep_timeout(&thread->join_wq, usec, flags, NULL); 655 656 // FIXME: join should deallocate the thread.657 // Current code calls detach after join, that's contrary to how658 // join is used in other threading APIs.659 662 } 660 663
Note:
See TracChangeset
for help on using the changeset viewer.