Changeset 0313ff0 in mainline for kernel/generic/src/proc/task.c


Ignore:
Timestamp:
2006-12-14T12:35:57Z (18 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
def5207
Parents:
cd896e2
Message:

accumulate task accounting, run tests as separate kernel task

File:
1 edited

Legend:

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

    rcd896e2 r0313ff0  
    120120        ta->capabilities = 0;
    121121        ta->accept_new_threads = true;
     122        ta->cycles = 0;
    122123       
    123124        ipc_answerbox_init(&ta->answerbox);
     
    267268}
    268269
     270/** Get accounting data of given task.
     271 *
     272 * Note that task_lock on @t must be already held and
     273 * interrupts must be already disabled.
     274 *
     275 * @param t Pointer to thread.
     276 *
     277 */
     278uint64_t task_get_accounting(task_t *t)
     279{
     280        /* Accumulated value of task */
     281        uint64_t ret = t->cycles;
     282       
     283        /* Current values of threads */
     284        link_t *cur;
     285        for (cur = t->th_head.next; cur != &t->th_head; cur = cur->next) {
     286                thread_t *thr = list_get_instance(cur, thread_t, th_link);
     287               
     288                spinlock_lock(&thr->lock);
     289               
     290                if (thr == THREAD) /* Update accounting of current thread */
     291                        thread_update_accounting();
     292                ret += thr->cycles;
     293               
     294                spinlock_unlock(&thr->lock);
     295        }
     296       
     297        return ret;
     298}
     299
    269300/** Kill task.
    270301 *
     
    345376        spinlock_lock(&tasks_lock);
    346377       
    347         printf("taskid name       ctx address    as         active calls callee\n");
    348         printf("------ ---------- --- ---------- ---------- ------------ ------>\n");
     378        printf("taskid name       ctx address    as         cycles     threads calls callee\n");
     379        printf("------ ---------- --- ---------- ---------- ---------- ------- ------ ------>\n");
    349380
    350381        for (cur = tasks_btree.leaf_head.next; cur != &tasks_btree.leaf_head; cur = cur->next) {
     
    360391               
    361392                        spinlock_lock(&t->lock);
    362                         printf("%-6lld %-10s %-3ld %#10zx %#10zx %12zd", t->taskid, t->name, t->context, t, t->as, atomic_get(&t->active_calls));
     393                       
     394                        uint64_t cycles = task_get_accounting(t);
     395                        char suffix;
     396                       
     397                        if (cycles > 1000000000000000000LL) {
     398                                cycles = cycles / 1000000000000000000LL;
     399                                suffix = 'E';
     400                        } else if (cycles > 1000000000000LL) {
     401                                cycles = cycles / 1000000000000LL;
     402                                suffix = 'T';
     403                        } else if (cycles > 1000000LL) {
     404                                cycles = cycles / 1000000LL;
     405                                suffix = 'M';
     406                        } else
     407                                suffix = ' ';
     408                       
     409                        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));
    363410                        for (j = 0; j < IPC_MAX_PHONES; j++) {
    364411                                if (t->phones[j].callee)
     
    366413                        }
    367414                        printf("\n");
     415                       
    368416                        spinlock_unlock(&t->lock);
    369417                }
Note: See TracChangeset for help on using the changeset viewer.