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

Changeset 67392fa in mainline


Ignore:
Timestamp:
2009-11-28T15:20:58Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master
Children:
2e07d27e, db4d6de
Parents:
fb7c52f (diff), 59ee56f (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:

Tasks should be allocated from a dedicated slab allocator cache.
(Merge fix for #139).

Location:
kernel/generic/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/ipc/ipc.c

    rfb7c52f r67392fa  
    583583                for (i = 0; i < IPC_MAX_PHONES; i++) {
    584584                        if (TASK->phones[i].state == IPC_PHONE_HUNGUP &&
    585                             atomic_get(&TASK->phones[i].active_calls) == 0)
     585                            atomic_get(&TASK->phones[i].active_calls) == 0) {
    586586                                TASK->phones[i].state = IPC_PHONE_FREE;
     587                                TASK->phones[i].callee = NULL;
     588                        }
    587589                       
    588590                        /* Just for sure, we might have had some
  • kernel/generic/src/proc/task.c

    rfb7c52f r67392fa  
    7575static task_id_t task_counter = 0;
    7676
     77static slab_cache_t *task_slab;
     78
    7779/* Forward declarations. */
    7880static void task_kill_internal(task_t *);
     81static int tsk_constructor(void *, int);
    7982
    8083/** Initialize kernel tasks support. */
     
    8386        TASK = NULL;
    8487        avltree_create(&tasks_tree);
     88        task_slab = slab_cache_create("task_slab", sizeof(task_t), 0,
     89            tsk_constructor, NULL, 0);
    8590}
    8691
     
    128133}
    129134
     135int tsk_constructor(void *obj, int kmflags)
     136{
     137        task_t *ta = obj;
     138        int i;
     139
     140        atomic_set(&ta->refcount, 0);
     141        atomic_set(&ta->lifecount, 0);
     142        atomic_set(&ta->active_calls, 0);
     143
     144        spinlock_initialize(&ta->lock, "task_ta_lock");
     145        mutex_initialize(&ta->futexes_lock, MUTEX_PASSIVE);
     146
     147        list_initialize(&ta->th_head);
     148        list_initialize(&ta->sync_box_head);
     149
     150        ipc_answerbox_init(&ta->answerbox, ta);
     151        for (i = 0; i < IPC_MAX_PHONES; i++)
     152                ipc_phone_init(&ta->phones[i]);
     153
     154#ifdef CONFIG_UDEBUG
     155        /* Init kbox stuff */
     156        ta->kb.thread = NULL;
     157        ipc_answerbox_init(&ta->kb.box, ta);
     158        mutex_initialize(&ta->kb.cleanup_lock, MUTEX_PASSIVE);
     159#endif
     160
     161        return 0;
     162}
     163
    130164/** Create new task with no threads.
    131165 *
     
    140174        ipl_t ipl;
    141175        task_t *ta;
    142         int i;
    143        
    144         ta = (task_t *) malloc(sizeof(task_t), 0);
    145 
     176       
     177        ta = (task_t *) slab_alloc(task_slab, 0);
    146178        task_create_arch(ta);
    147 
    148         spinlock_initialize(&ta->lock, "task_ta_lock");
    149         list_initialize(&ta->th_head);
    150179        ta->as = as;
    151 
    152180        memcpy(ta->name, name, TASK_NAME_BUFLEN);
    153181        ta->name[TASK_NAME_BUFLEN - 1] = 0;
    154182
    155         atomic_set(&ta->refcount, 0);
    156         atomic_set(&ta->lifecount, 0);
    157183        ta->context = CONTEXT;
    158 
    159184        ta->capabilities = 0;
    160185        ta->cycles = 0;
     
    165190
    166191        /* 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);
    170192        ta->kb.finished = false;
    171193#endif
    172194
    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)))
     195        if ((ipc_phone_0) &&
     196            (context_check(ipc_phone_0->task->context, ta->context)))
    178197                ipc_phone_connect(&ta->phones[0], ipc_phone_0);
    179         atomic_set(&ta->active_calls, 0);
    180         list_initialize(&ta->sync_box_head);
    181 
    182         mutex_initialize(&ta->futexes_lock, MUTEX_PASSIVE);
     198
    183199        btree_create(&ta->futexes);
    184200       
    185201        ipl = interrupts_disable();
    186 
    187         /*
    188          * Increment address space reference count.
    189          */
    190202        atomic_inc(&as->refcount);
    191 
    192203        spinlock_lock(&tasks_lock);
    193204        ta->taskid = ++task_counter;
     
    230241                as_destroy(t->as);
    231242       
    232         free(t);
     243        slab_free(task_slab, t);
    233244        TASK = NULL;
    234245}
Note: See TracChangeset for help on using the changeset viewer.