Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 436a0a5 in mainline for kernel/generic/src/proc/thread.c


Ignore:
Timestamp:
2018-11-09T22:04:01Z (3 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master
Children:
95d45482
Parents:
88e43bc (diff), abf6c01 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

(merge) Reduce the number of blocking allocations in the kernel

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/proc/thread.c

    r88e43bc r436a0a5  
    165165
    166166#ifdef CONFIG_FPU
    167 #ifdef CONFIG_FPU_LAZY
    168         thread->saved_fpu_context = NULL;
    169 #else /* CONFIG_FPU_LAZY */
    170         thread->saved_fpu_context = slab_alloc(fpu_context_cache, kmflags);
     167        thread->saved_fpu_context = slab_alloc(fpu_context_cache,
     168            FRAME_ATOMIC | kmflags);
    171169        if (!thread->saved_fpu_context)
    172170                return ENOMEM;
    173 #endif /* CONFIG_FPU_LAZY */
    174171#endif /* CONFIG_FPU */
    175172
     
    200197        if (!stack_phys) {
    201198#ifdef CONFIG_FPU
    202                 if (thread->saved_fpu_context)
    203                         slab_free(fpu_context_cache, thread->saved_fpu_context);
     199                assert(thread->saved_fpu_context);
     200                slab_free(fpu_context_cache, thread->saved_fpu_context);
    204201#endif
    205202                return ENOMEM;
     
    226223
    227224#ifdef CONFIG_FPU
    228         if (thread->saved_fpu_context)
    229                 slab_free(fpu_context_cache, thread->saved_fpu_context);
     225        assert(thread->saved_fpu_context);
     226        slab_free(fpu_context_cache, thread->saved_fpu_context);
    230227#endif
    231228
     
    342339    thread_flags_t flags, const char *name)
    343340{
    344         thread_t *thread = (thread_t *) slab_alloc(thread_cache, 0);
     341        thread_t *thread = (thread_t *) slab_alloc(thread_cache, FRAME_ATOMIC);
    345342        if (!thread)
    346343                return NULL;
     344
     345        if (thread_create_arch(thread, flags) != EOK) {
     346                slab_free(thread_cache, thread);
     347                return NULL;
     348        }
    347349
    348350        /* Not needed, but good for debugging */
     
    407409        udebug_thread_initialize(&thread->udebug);
    408410#endif
    409 
    410         /* Might depend on previous initialization */
    411         thread_create_arch(thread);
    412411
    413412        if ((flags & THREAD_FLAG_NOATTACH) != THREAD_FLAG_NOATTACH)
     
    654653
    655654        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.
    656659}
    657660
Note: See TracChangeset for help on using the changeset viewer.