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

Changeset 5ba201d in mainline


Ignore:
Timestamp:
2010-04-17T09:25:40Z (12 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master
Children:
88dea9d
Parents:
b658c5d
Message:

cstyle changes (no change in functionality)

File:
1 edited

Legend:

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

    rb658c5d r5ba201d  
    3333/**
    3434 * @file
    35  * @brief       Task management.
     35 * @brief Task management.
    3636 */
    3737
     
    6666 * The task is guaranteed to exist after it was found in the tasks_tree as
    6767 * long as:
     68 *
    6869 * @li the tasks_lock is held,
    6970 * @li the task's lock is held when task's lock is acquired before releasing
     
    99100        task_t *t = avltree_get_instance(node, task_t, tasks_tree_node);
    100101        unsigned *cnt = (unsigned *) arg;
    101 
     102       
    102103        if (t != TASK) {
    103104                (*cnt)++;
     
    107108                task_kill_internal(t);
    108109        }
    109 
    110         return true;    /* continue the walk */
     110       
     111        /* Continue the walk */
     112        return true;
    111113}
    112114
     
    115117{
    116118        unsigned tasks_left;
    117 
     119       
    118120        do { /* Repeat until there are any tasks except TASK */
    119121                /* Messing with task structures, avoid deadlock */
     
    138140        task_t *ta = obj;
    139141        int i;
    140 
     142       
    141143        atomic_set(&ta->refcount, 0);
    142144        atomic_set(&ta->lifecount, 0);
    143145        atomic_set(&ta->active_calls, 0);
    144 
     146       
    145147        spinlock_initialize(&ta->lock, "task_ta_lock");
    146148        mutex_initialize(&ta->futexes_lock, MUTEX_PASSIVE);
    147 
     149       
    148150        list_initialize(&ta->th_head);
    149151        list_initialize(&ta->sync_box_head);
    150 
     152       
    151153        ipc_answerbox_init(&ta->answerbox, ta);
    152154        for (i = 0; i < IPC_MAX_PHONES; i++)
    153155                ipc_phone_init(&ta->phones[i]);
    154 
     156       
    155157#ifdef CONFIG_UDEBUG
    156158        /* Init kbox stuff */
     
    159161        mutex_initialize(&ta->kb.cleanup_lock, MUTEX_PASSIVE);
    160162#endif
    161 
     163       
    162164        return 0;
    163165}
     
    165167/** Create new task with no threads.
    166168 *
    167  * @param as            Task's address space.
    168  * @param name          Symbolic name (a copy is made).
    169  *
    170  * @return              New task's structure.
     169 * @param as   Task's address space.
     170 * @param name Symbolic name (a copy is made).
     171 *
     172 * @return New task's structure.
    171173 *
    172174 */
     
    181183        memcpy(ta->name, name, TASK_NAME_BUFLEN);
    182184        ta->name[TASK_NAME_BUFLEN - 1] = 0;
    183 
     185       
    184186        ta->context = CONTEXT;
    185187        ta->capabilities = 0;
    186188        ta->cycles = 0;
    187 
     189       
    188190#ifdef CONFIG_UDEBUG
    189191        /* Init debugging stuff */
    190192        udebug_task_init(&ta->udebug);
    191 
     193       
    192194        /* Init kbox stuff */
    193195        ta->kb.finished = false;
    194196#endif
    195 
     197       
    196198        if ((ipc_phone_0) &&
    197199            (context_check(ipc_phone_0->task->context, ta->context)))
    198200                ipc_phone_connect(&ta->phones[0], ipc_phone_0);
    199 
     201       
    200202        btree_create(&ta->futexes);
    201203       
     
    215217/** Destroy task.
    216218 *
    217  * @param t             Task to be destroyed.
     219 * @param t Task to be destroyed.
     220 *
    218221 */
    219222void task_destroy(task_t *t)
     
    225228        avltree_delete(&tasks_tree, &t->tasks_tree_node);
    226229        spinlock_unlock(&tasks_lock);
    227 
     230       
    228231        /*
    229232         * Perform architecture specific task destruction.
    230233         */
    231234        task_destroy_arch(t);
    232 
     235       
    233236        /*
    234237         * Free up dynamically allocated state.
    235238         */
    236239        btree_destroy(&t->futexes);
    237 
     240       
    238241        /*
    239242         * Drop our reference to the address space.
     
    248251/** Syscall for reading task ID from userspace.
    249252 *
    250  * @param               uspace_task_id userspace address of 8-byte buffer
    251  *                      where to store current task ID.
    252  *
    253  * @return              Zero on success or an error code from @ref errno.h.
     253 * @param uspace_task_id Userspace address of 8-byte buffer
     254 *                       where to store current task ID.
     255 *
     256 * @return Zero on success or an error code from @ref errno.h.
     257 *
    254258 */
    255259unative_t sys_task_get_id(task_id_t *uspace_task_id)
     
    267271 * The name simplifies identifying the task in the task list.
    268272 *
    269  * @param name  The new name for the task. (typically the same
    270  *              as the command used to execute it).
     273 * @param name The new name for the task. (typically the same
     274 *             as the command used to execute it).
    271275 *
    272276 * @return 0 on success or an error code from @ref errno.h.
     277 *
    273278 */
    274279unative_t sys_task_set_name(const char *uspace_name, size_t name_len)
     
    276281        int rc;
    277282        char namebuf[TASK_NAME_BUFLEN];
    278 
     283       
    279284        /* Cap length of name and copy it from userspace. */
    280 
     285       
    281286        if (name_len > TASK_NAME_BUFLEN - 1)
    282287                name_len = TASK_NAME_BUFLEN - 1;
    283 
     288       
    284289        rc = copy_from_uspace(namebuf, uspace_name, name_len);
    285290        if (rc != 0)
    286291                return (unative_t) rc;
    287 
     292       
    288293        namebuf[name_len] = '\0';
    289294        str_cpy(TASK->name, TASK_NAME_BUFLEN, namebuf);
    290 
     295       
    291296        return EOK;
    292297}
     
    297302 * interrupts must be disabled.
    298303 *
    299  * @param id            Task ID.
    300  *
    301  * @return              Task structure address or NULL if there is no such task
    302  *                      ID.
    303  */
    304 task_t *task_find_by_id(task_id_t id) { avltree_node_t *node;
    305        
     304 * @param id Task ID.
     305 *
     306 * @return Task structure address or NULL if there is no such task
     307 *         ID.
     308 *
     309 */
     310task_t *task_find_by_id(task_id_t id)
     311{
     312        avltree_node_t *node;
    306313        node = avltree_search(&tasks_tree, (avltree_key_t) id);
    307 
     314       
    308315        if (node)
    309316                return avltree_get_instance(node, task_t, tasks_tree_node);
     317       
    310318        return NULL;
    311319}
     
    316324 * already disabled.
    317325 *
    318  * @param t             Pointer to thread.
    319  *
    320  * @return              Number of cycles used by the task and all its threads
    321  *                      so far.
     326 * @param t Pointer to task.
     327 *
     328 * @return Number of cycles used by the task and all its threads
     329 *         so far.
     330 *
    322331 */
    323332uint64_t task_get_accounting(task_t *t)
     
    349358{
    350359        link_t *cur;
    351 
     360       
    352361        /*
    353362         * Interrupt all threads.
     
    377386 * It signals all the task's threads to bail it out.
    378387 *
    379  * @param id            ID of the task to be killed.
    380  *
    381  * @return              Zero on success or an error code from errno.h.
     388 * @param id ID of the task to be killed.
     389 *
     390 * @return Zero on success or an error code from errno.h.
     391 *
    382392 */
    383393int task_kill(task_id_t id)
     
    406416        task_t *t = avltree_get_instance(node, task_t, tasks_tree_node);
    407417        int j;
    408                
     418       
    409419        spinlock_lock(&t->lock);
    410                        
     420       
    411421        uint64_t cycles;
    412422        char suffix;
    413423        order(task_get_accounting(t), &cycles, &suffix);
    414 
    415 #ifdef __32_BITS__     
     424       
     425#ifdef __32_BITS__
    416426        printf("%-6" PRIu64 " %-12s %-3" PRIu32 " %10p %10p %9" PRIu64
    417427            "%c %7ld %6ld", t->taskid, t->name, t->context, t, t->as, cycles,
    418428            suffix, atomic_get(&t->refcount), atomic_get(&t->active_calls));
    419429#endif
    420 
     430       
    421431#ifdef __64_BITS__
    422432        printf("%-6" PRIu64 " %-12s %-3" PRIu32 " %18p %18p %9" PRIu64
     
    424434            suffix, atomic_get(&t->refcount), atomic_get(&t->active_calls));
    425435#endif
    426 
     436       
    427437        for (j = 0; j < IPC_MAX_PHONES; j++) {
    428438                if (t->phones[j].callee)
     
    430440        }
    431441        printf("\n");
    432                        
     442       
    433443        spinlock_unlock(&t->lock);
    434444        return true;
     
    443453        ipl = interrupts_disable();
    444454        spinlock_lock(&tasks_lock);
    445 
    446 #ifdef __32_BITS__     
     455       
     456#ifdef __32_BITS__
    447457        printf("taskid name         ctx address    as         "
    448458            "cycles     threads calls  callee\n");
     
    450460            "---------- ------- ------ ------>\n");
    451461#endif
    452 
     462       
    453463#ifdef __64_BITS__
    454464        printf("taskid name         ctx address            as                 "
     
    457467            "---------- ------- ------ ------>\n");
    458468#endif
    459 
     469       
    460470        avltree_walk(&tasks_tree, task_print_walker, NULL);
    461 
     471       
    462472        spinlock_unlock(&tasks_lock);
    463473        interrupts_restore(ipl);
Note: See TracChangeset for help on using the changeset viewer.