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