Ignore:
File:
1 edited

Legend:

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

    rc46bfbc rfeeac0d  
    3636 */
    3737
    38 #include <assert.h>
    3938#include <proc/thread.h>
    4039#include <proc/task.h>
     
    4241#include <mm/slab.h>
    4342#include <atomic.h>
    44 #include <synch/futex.h>
    4543#include <synch/spinlock.h>
    4644#include <synch/waitq.h>
     
    5048#include <adt/btree.h>
    5149#include <adt/list.h>
    52 #include <cap/cap.h>
    5350#include <ipc/ipc.h>
    5451#include <ipc/ipcrsc.h>
     
    5855#include <func.h>
    5956#include <str.h>
     57#include <memstr.h>
    6058#include <syscall/copy.h>
    6159#include <macros.h>
     
    8482static void task_kill_internal(task_t *);
    8583static int tsk_constructor(void *, unsigned int);
    86 static size_t tsk_destructor(void *obj);
    8784
    8885/** Initialize kernel tasks support.
     
    9491        avltree_create(&tasks_tree);
    9592        task_slab = slab_cache_create("task_t", sizeof(task_t), 0,
    96             tsk_constructor, tsk_destructor, 0);
     93            tsk_constructor, NULL, 0);
    9794}
    9895
     
    161158{
    162159        task_t *task = (task_t *) obj;
    163 
    164         int rc = caps_task_alloc(task);
    165         if (rc != EOK)
    166                 return rc;
    167160       
    168161        atomic_set(&task->refcount, 0);
     
    170163       
    171164        irq_spinlock_initialize(&task->lock, "task_t_lock");
     165        mutex_initialize(&task->futexes_lock, MUTEX_PASSIVE);
    172166       
    173167        list_initialize(&task->threads);
     
    175169        ipc_answerbox_init(&task->answerbox, task);
    176170       
     171        size_t i;
     172        for (i = 0; i < IPC_MAX_PHONES; i++)
     173                ipc_phone_init(&task->phones[i], task);
     174
    177175        spinlock_initialize(&task->active_calls_lock, "active_calls_lock");
    178176        list_initialize(&task->active_calls);
    179                
     177       
    180178#ifdef CONFIG_UDEBUG
    181179        /* Init kbox stuff */
     
    188186}
    189187
    190 size_t tsk_destructor(void *obj)
    191 {
    192         task_t *task = (task_t *) obj;
    193        
    194         caps_task_free(task);
    195         return 0;
    196 }
    197 
    198188/** Create new task with no threads.
    199189 *
     
    213203       
    214204        task->container = CONTAINER;
    215         task->perms = 0;
     205        task->capabilities = 0;
    216206        task->ucycles = 0;
    217207        task->kcycles = 0;
    218 
    219         caps_task_init(task);
    220208
    221209        task->ipc_info.call_sent = 0;
     
    240228       
    241229        if ((ipc_phone_0) &&
    242             (container_check(ipc_phone_0->task->container, task->container))) {
    243                 cap_handle_t phone_handle = phone_alloc(task);
    244                 kobject_t *phone_obj = kobject_get(task, phone_handle,
    245                     KOBJECT_TYPE_PHONE);
    246                 (void) ipc_phone_connect(phone_obj->phone, ipc_phone_0);
    247         }
    248        
    249         futex_task_init(task);
     230            (container_check(ipc_phone_0->task->container, task->container)))
     231                (void) ipc_phone_connect(&task->phones[0], ipc_phone_0);
     232       
     233        btree_create(&task->futexes);
    250234       
    251235        /*
     
    288272         * Free up dynamically allocated state.
    289273         */
    290         futex_task_deinit(task);
     274        btree_destroy(&task->futexes);
    291275       
    292276        /*
     
    436420task_t *task_find_by_id(task_id_t id)
    437421{
    438         assert(interrupts_disabled());
    439         assert(irq_spinlock_locked(&tasks_lock));
     422        ASSERT(interrupts_disabled());
     423        ASSERT(irq_spinlock_locked(&tasks_lock));
    440424
    441425        avltree_node_t *node =
     
    460444void task_get_accounting(task_t *task, uint64_t *ucycles, uint64_t *kcycles)
    461445{
    462         assert(interrupts_disabled());
    463         assert(irq_spinlock_locked(&task->lock));
     446        ASSERT(interrupts_disabled());
     447        ASSERT(irq_spinlock_locked(&task->lock));
    464448
    465449        /* Accumulated values of task */
     
    619603        if (*additional)
    620604                printf("%-8" PRIu64 " %9" PRIu64 "%c %9" PRIu64 "%c "
    621                     "%9" PRIua "\n", task->taskid, ucycles, usuffix, kcycles,
     605                    "%9" PRIua, task->taskid, ucycles, usuffix, kcycles,
    622606                    ksuffix, atomic_get(&task->refcount));
    623607        else
     
    625609                    task->taskid, task->name, task->container, task, task->as);
    626610#endif
     611       
     612        if (*additional) {
     613                size_t i;
     614                for (i = 0; i < IPC_MAX_PHONES; i++) {
     615                        if (task->phones[i].callee)
     616                                printf(" %zu:%p", i, task->phones[i].callee);
     617                }
     618                printf("\n");
     619        }
    627620       
    628621        irq_spinlock_unlock(&task->lock, false);
Note: See TracChangeset for help on using the changeset viewer.