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

Changeset fbcfc4da in mainline for kernel/generic/src/proc/task.c


Ignore:
Timestamp:
2009-12-03T19:25:17Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
9510be2
Parents:
cb3d641a (diff), 22e6802 (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 mainline changes.

File:
1 edited

Legend:

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

    rcb3d641a rfbcfc4da  
    5454#include <func.h>
    5555#include <string.h>
     56#include <memstr.h>
    5657#include <syscall/copy.h>
    5758#include <macros.h>
     
    7576static task_id_t task_counter = 0;
    7677
     78static slab_cache_t *task_slab;
     79
    7780/* Forward declarations. */
    7881static void task_kill_internal(task_t *);
     82static int tsk_constructor(void *, int);
    7983
    8084/** Initialize kernel tasks support. */
     
    8387        TASK = NULL;
    8488        avltree_create(&tasks_tree);
     89        task_slab = slab_cache_create("task_slab", sizeof(task_t), 0,
     90            tsk_constructor, NULL, 0);
    8591}
    8692
     
    128134}
    129135
     136int tsk_constructor(void *obj, int kmflags)
     137{
     138        task_t *ta = obj;
     139        int i;
     140
     141        atomic_set(&ta->refcount, 0);
     142        atomic_set(&ta->lifecount, 0);
     143        atomic_set(&ta->active_calls, 0);
     144
     145        spinlock_initialize(&ta->lock, "task_ta_lock");
     146        mutex_initialize(&ta->futexes_lock, MUTEX_PASSIVE);
     147
     148        list_initialize(&ta->th_head);
     149        list_initialize(&ta->sync_box_head);
     150
     151        ipc_answerbox_init(&ta->answerbox, ta);
     152        for (i = 0; i < IPC_MAX_PHONES; i++)
     153                ipc_phone_init(&ta->phones[i]);
     154
     155#ifdef CONFIG_UDEBUG
     156        /* Init kbox stuff */
     157        ta->kb.thread = NULL;
     158        ipc_answerbox_init(&ta->kb.box, ta);
     159        mutex_initialize(&ta->kb.cleanup_lock, MUTEX_PASSIVE);
     160#endif
     161
     162        return 0;
     163}
     164
    130165/** Create new task with no threads.
    131166 *
     
    140175        ipl_t ipl;
    141176        task_t *ta;
    142         int i;
    143        
    144         ta = (task_t *) malloc(sizeof(task_t), 0);
    145 
     177       
     178        ta = (task_t *) slab_alloc(task_slab, 0);
    146179        task_create_arch(ta);
    147 
    148         spinlock_initialize(&ta->lock, "task_ta_lock");
    149         list_initialize(&ta->th_head);
    150180        ta->as = as;
    151 
    152181        memcpy(ta->name, name, TASK_NAME_BUFLEN);
    153182        ta->name[TASK_NAME_BUFLEN - 1] = 0;
    154183
    155         atomic_set(&ta->refcount, 0);
    156         atomic_set(&ta->lifecount, 0);
    157184        ta->context = CONTEXT;
    158 
    159185        ta->capabilities = 0;
    160186        ta->cycles = 0;
     
    165191
    166192        /* Init kbox stuff */
    167         ipc_answerbox_init(&ta->kb.box, ta);
    168         ta->kb.thread = NULL;
    169         mutex_initialize(&ta->kb.cleanup_lock, MUTEX_PASSIVE);
    170193        ta->kb.finished = false;
    171194#endif
    172195
    173         ipc_answerbox_init(&ta->answerbox, ta);
    174         for (i = 0; i < IPC_MAX_PHONES; i++)
    175                 ipc_phone_init(&ta->phones[i]);
    176         if ((ipc_phone_0) && (context_check(ipc_phone_0->task->context,
    177             ta->context)))
     196        if ((ipc_phone_0) &&
     197            (context_check(ipc_phone_0->task->context, ta->context)))
    178198                ipc_phone_connect(&ta->phones[0], ipc_phone_0);
    179         atomic_set(&ta->active_calls, 0);
    180 
    181         mutex_initialize(&ta->futexes_lock, MUTEX_PASSIVE);
     199
    182200        btree_create(&ta->futexes);
    183201       
    184202        ipl = interrupts_disable();
    185 
    186         /*
    187          * Increment address space reference count.
    188          */
    189203        atomic_inc(&as->refcount);
    190 
    191204        spinlock_lock(&tasks_lock);
    192205        ta->taskid = ++task_counter;
     
    229242                as_destroy(t->as);
    230243       
    231         free(t);
     244        slab_free(task_slab, t);
    232245        TASK = NULL;
    233246}
Note: See TracChangeset for help on using the changeset viewer.