Changeset 6f4495f5 in mainline for kernel/generic/src/proc


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 :-)

Location:
kernel/generic/src/proc
Files:
3 edited

Legend:

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

    r51baa8a r6f4495f5  
    361361        context_save(&CPU->saved_context);
    362362        context_set(&CPU->saved_context, FADDR(scheduler_separated_stack),
    363                 (uintptr_t) CPU->stack, CPU_STACK_SIZE);
     363            (uintptr_t) CPU->stack, CPU_STACK_SIZE);
    364364        context_restore(&CPU->saved_context);
    365365        /* not reached */
     
    501501#ifdef SCHEDULER_VERBOSE
    502502        printf("cpu%d: tid %d (priority=%d, ticks=%lld, nrdy=%ld)\n",
    503                 CPU->id, THREAD->tid, THREAD->priority, THREAD->ticks,
    504                 atomic_get(&CPU->nrdy));
     503            CPU->id, THREAD->tid, THREAD->priority, THREAD->ticks,
     504            atomic_get(&CPU->nrdy));
    505505#endif 
    506506
     
    636636#ifdef KCPULB_VERBOSE
    637637                                printf("kcpulb%d: TID %d -> cpu%d, nrdy=%ld, "
    638                                         "avg=%nd\n", CPU->id, t->tid, CPU->id,
    639                                         atomic_get(&CPU->nrdy),
    640                                         atomic_get(&nrdy) / config.cpu_active);
     638                                    "avg=%nd\n", CPU->id, t->tid, CPU->id,
     639                                    atomic_get(&CPU->nrdy),
     640                                    atomic_get(&nrdy) / config.cpu_active);
    641641#endif
    642642                                t->flags |= THREAD_FLAG_STOLEN;
     
    704704                spinlock_lock(&cpus[cpu].lock);
    705705                printf("cpu%d: address=%p, nrdy=%ld, needs_relink=%ld\n",
    706                         cpus[cpu].id, &cpus[cpu], atomic_get(&cpus[cpu].nrdy),
    707                         cpus[cpu].needs_relink);
     706                    cpus[cpu].id, &cpus[cpu], atomic_get(&cpus[cpu].nrdy),
     707                    cpus[cpu].needs_relink);
    708708               
    709709                for (i = 0; i < RQ_COUNT; i++) {
     
    719719                                t = list_get_instance(cur, thread_t, rq_link);
    720720                                printf("%d(%s) ", t->tid,
    721                                         thread_states[t->state]);
     721                                    thread_states[t->state]);
    722722                        }
    723723                        printf("\n");
  • 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);
  • kernel/generic/src/proc/thread.c

    r51baa8a r6f4495f5  
    205205        atomic_set(&nrdy,0);
    206206        thread_slab = slab_cache_create("thread_slab", sizeof(thread_t), 0,
    207                 thr_constructor, thr_destructor, 0);
     207            thr_constructor, thr_destructor, 0);
    208208
    209209#ifdef ARCH_HAS_FPU
    210210        fpu_context_slab = slab_cache_create("fpu_slab", sizeof(fpu_context_t),
    211                 FPU_CONTEXT_ALIGN, NULL, NULL, 0);
     211            FPU_CONTEXT_ALIGN, NULL, NULL, 0);
    212212#endif
    213213
     
    329329        /* Not needed, but good for debugging */
    330330        memsetb((uintptr_t) t->kstack, THREAD_STACK_SIZE * 1 << STACK_FRAMES,
    331                 0);
     331            0);
    332332       
    333333        ipl = interrupts_disable();
     
    339339        context_save(&t->saved_context);
    340340        context_set(&t->saved_context, FADDR(cushion), (uintptr_t) t->kstack,
    341                 THREAD_STACK_SIZE);
     341            THREAD_STACK_SIZE);
    342342       
    343343        the_initialize((the_t *) t->kstack);
     
    405405        spinlock_lock(&threads_lock);
    406406        btree_insert(&threads_btree, (btree_key_t) ((uintptr_t) t), (void *) t,
    407                 NULL);
     407            NULL);
    408408        spinlock_unlock(&threads_lock);
    409409       
     
    561561        spinlock_lock(&threads_lock);
    562562       
    563         printf("tid    name       address    state    task       ctx code       stack      cycles     cpu  kstack     waitqueue\n");
    564         printf("------ ---------- ---------- -------- ---------- --- ---------- ---------- ---------- ---- ---------- ----------\n");
    565 
    566         for (cur = threads_btree.leaf_head.next; cur != &threads_btree.leaf_head; cur = cur->next) {
     563        printf("tid    name       address    state    task       ctx code    "
     564            "   stack      cycles     cpu  kstack     waitqueue\n");
     565        printf("------ ---------- ---------- -------- ---------- --- --------"
     566            "-- ---------- ---------- ---- ---------- ----------\n");
     567
     568        for (cur = threads_btree.leaf_head.next;
     569            cur != &threads_btree.leaf_head; cur = cur->next) {
    567570                btree_node_t *node;
    568571                int i;
     
    578581                        order(t->cycles, &cycles, &suffix);
    579582                       
    580                         printf("%-6zd %-10s %#10zx %-8s %#10zx %-3ld %#10zx %#10zx %9llu%c ", t->tid, t->name, t, thread_states[t->state], t->task, t->task->context, t->thread_code, t->kstack, cycles, suffix);
     583                        printf("%-6zd %-10s %#10zx %-8s %#10zx %-3ld %#10zx "
     584                            "%#10zx %9llu%c ", t->tid, t->name, t,
     585                            thread_states[t->state], t->task, t->task->context,
     586                            t->thread_code, t->kstack, cycles, suffix);
    581587                       
    582588                        if (t->cpu)
     
    586592                       
    587593                        if (t->state == Sleeping)
    588                                 printf(" %#10zx %#10zx", t->kstack, t->sleep_queue);
     594                                printf(" %#10zx %#10zx", t->kstack,
     595                                    t->sleep_queue);
    589596                       
    590597                        printf("\n");
     
    609616        btree_node_t *leaf;
    610617       
    611         return btree_search(&threads_btree, (btree_key_t) ((uintptr_t) t), &leaf) != NULL;
     618        return btree_search(&threads_btree, (btree_key_t) ((uintptr_t) t),
     619            &leaf) != NULL;
    612620}
    613621
     
    648656        }
    649657
    650         if ((t = thread_create(uinit, kernel_uarg, TASK, THREAD_FLAG_USPACE, namebuf, false))) {
     658        t = thread_create(uinit, kernel_uarg, TASK, THREAD_FLAG_USPACE, namebuf,
     659            false);
     660        if (t) {
    651661                tid = t->tid;
    652662                thread_ready(t);
     
    671681/** @}
    672682 */
     683
Note: See TracChangeset for help on using the changeset viewer.