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


Ignore:
Timestamp:
2007-01-27T17:32:13Z (18 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1ba41c5
Parents:
51baa8a
Message:

Indentaion and formatting changes even Martin will like :-)

File:
1 edited

Legend:

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

    r51baa8a r6f4495f5  
    6666/** B+tree of active tasks.
    6767 *
    68  * The task is guaranteed to exist after it was found in the tasks_btree as long as:
     68 * The task is guaranteed to exist after it was found in the tasks_btree as
     69 * long as:
    6970 * @li the tasks_lock is held,
    70  * @li the task's lock is held when task's lock is acquired before releasing tasks_lock or
     71 * @li the task's lock is held when task's lock is acquired before releasing
     72 *     tasks_lock or
    7173 * @li the task's refcount is greater than 0
    7274 *
     
    126128        for (i = 0; i < IPC_MAX_PHONES; i++)
    127129                ipc_phone_init(&ta->phones[i]);
    128         if ((ipc_phone_0) && (context_check(ipc_phone_0->task->context, ta->context)))
     130        if ((ipc_phone_0) && (context_check(ipc_phone_0->task->context,
     131            ta->context)))
    129132                ipc_phone_connect(&ta->phones[0], ipc_phone_0);
    130133        atomic_set(&ta->active_calls, 0);
     
    203206       
    204207        kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0);
    205         kernel_uarg->uspace_entry = (void *) ((elf_header_t *) program_addr)->e_entry;
     208        kernel_uarg->uspace_entry =
     209            (void *) ((elf_header_t *) program_addr)->e_entry;
    206210        kernel_uarg->uspace_stack = (void *) USTACK_ADDRESS;
    207211        kernel_uarg->uspace_thread_function = NULL;
     
    215219         * Create the data as_area.
    216220         */
    217         a = as_area_create(as, AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE, 
    218                 LOADED_PROG_STACK_PAGES_NO*PAGE_SIZE,
    219                 USTACK_ADDRESS, AS_AREA_ATTR_NONE, &anon_backend, NULL);
     221        a = as_area_create(as, AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE,
     222            LOADED_PROG_STACK_PAGES_NO * PAGE_SIZE, USTACK_ADDRESS,
     223            AS_AREA_ATTR_NONE, &anon_backend, NULL);
    220224
    221225        /*
    222226         * Create the main thread.
    223227         */
    224         t1 = thread_create(uinit, kernel_uarg, task, THREAD_FLAG_USPACE, "uinit", false);
     228        t1 = thread_create(uinit, kernel_uarg, task, THREAD_FLAG_USPACE,
     229            "uinit", false);
    225230        ASSERT(t1);
    226231       
     
    239244/** Syscall for reading task ID from userspace.
    240245 *
    241  * @param uspace_task_id Userspace address of 8-byte buffer where to store current task ID.
     246 * @param uspace_task_id Userspace address of 8-byte buffer where to store
     247 * current task ID.
    242248 *
    243249 * @return 0 on success or an error code from @ref errno.h.
     
    249255         * remains constant for the lifespan of the task.
    250256         */
    251         return (unative_t) copy_to_uspace(uspace_task_id, &TASK->taskid, sizeof(TASK->taskid));
     257        return (unative_t) copy_to_uspace(uspace_task_id, &TASK->taskid,
     258            sizeof(TASK->taskid));
    252259}
    253260
     
    289296                /* Process only counted threads */
    290297                if (!thr->uncounted) {
    291                         if (thr == THREAD) /* Update accounting of current thread */
    292                                 thread_update_accounting();
     298                        if (thr == THREAD) {
     299                                /* Update accounting of current thread */
     300                                thread_update_accounting();
     301                        }
    293302                        ret += thr->cycles;
    294303                }
     
    377386        spinlock_lock(&tasks_lock);
    378387       
    379         printf("taskid name       ctx address    as         cycles     threads calls  callee\n");
    380         printf("------ ---------- --- ---------- ---------- ---------- ------- ------ ------>\n");
    381 
    382         for (cur = tasks_btree.leaf_head.next; cur != &tasks_btree.leaf_head; cur = cur->next) {
     388        printf("taskid name       ctx address    as         cycles     threads "
     389            "calls  callee\n");
     390        printf("------ ---------- --- ---------- ---------- ---------- ------- "            "------ ------>\n");
     391
     392        for (cur = tasks_btree.leaf_head.next; cur != &tasks_btree.leaf_head;
     393            cur = cur->next) {
    383394                btree_node_t *node;
    384395                int i;
     
    397408                        order(task_get_accounting(t), &cycles, &suffix);
    398409                       
    399                         printf("%-6lld %-10s %-3ld %#10zx %#10zx %9llu%c %7zd %6zd", t->taskid, t->name, t->context, t, t->as, cycles, suffix, t->refcount, atomic_get(&t->active_calls));
     410                        printf("%-6lld %-10s %-3ld %#10zx %#10zx %9llu%c %7zd "
     411                            "%6zd", t->taskid, t->name, t->context, t, t->as,
     412                            cycles, suffix, t->refcount,
     413                            atomic_get(&t->active_calls));
    400414                        for (j = 0; j < IPC_MAX_PHONES; j++) {
    401415                                if (t->phones[j].callee)
    402                                         printf(" %zd:%#zx", j, t->phones[j].callee);
     416                                        printf(" %zd:%#zx", j,
     417                                            t->phones[j].callee);
    403418                        }
    404419                        printf("\n");
     
    466481       
    467482        if (t != THREAD) {
    468                 ASSERT(t != main_thread);       /* uninit is joined and detached in ktaskgc */
     483                ASSERT(t != main_thread);       /* uninit is joined and detached
     484                                                 * in ktaskgc */
    469485                thread_join(t);
    470486                thread_detach(t);
    471                 goto loop;      /* go for another thread */
     487                goto loop;                      /* go for another thread */
    472488        }
    473489       
     
    498514         * therefore the thread pointer is guaranteed to be valid.
    499515         */
    500         if (thread_join_timeout(t, 1000000, SYNCH_FLAGS_NONE) == ESYNCH_TIMEOUT) {      /* sleep uninterruptibly here! */
     516        if (thread_join_timeout(t, 1000000, SYNCH_FLAGS_NONE) ==
     517            ESYNCH_TIMEOUT) {   /* sleep uninterruptibly here! */
    501518                ipl_t ipl;
    502519                link_t *cur;
     
    504521       
    505522                /*
    506                  * The join timed out. Try to do some garbage collection of Undead threads.
     523                 * The join timed out. Try to do some garbage collection of
     524                 * Undead threads.
    507525                 */
    508526more_gc:               
     
    510528                spinlock_lock(&TASK->lock);
    511529               
    512                 for (cur = TASK->th_head.next; cur != &TASK->th_head; cur = cur->next) {
     530                for (cur = TASK->th_head.next; cur != &TASK->th_head;
     531                    cur = cur->next) {
    513532                        thr = list_get_instance(cur, thread_t, th_link);
    514533                        spinlock_lock(&thr->lock);
    515                         if (thr != t && thr->state == Undead && thr->join_type == None) {
     534                        if (thr != t && thr->state == Undead &&
     535                            thr->join_type == None) {
    516536                                thr->join_type = TaskGC;
    517537                                spinlock_unlock(&thr->lock);
Note: See TracChangeset for help on using the changeset viewer.