Changeset 0313ff0 in mainline for kernel/generic/src/proc


Ignore:
Timestamp:
2006-12-14T12:35:57Z (19 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

Location:
kernel/generic/src/proc
Files:
2 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                }
  • kernel/generic/src/proc/thread.c

    rcd896e2 r0313ff0  
    114114        THREAD->last_cycle = get_cycle();
    115115
    116         /* this is where each thread wakes up after its creation */
     116        /* This is where each thread wakes up after its creation */
    117117        spinlock_unlock(&THREAD->lock);
    118118        interrupts_enable();
    119119
    120120        f(arg);
     121       
     122        /* Accumulate accounting to the task */
     123        ipl_t ipl = interrupts_disable();
     124       
     125        spinlock_lock(&THREAD->lock);
     126        thread_update_accounting();
     127        uint64_t cycles = THREAD->cycles;
     128        THREAD->cycles = 0;
     129        spinlock_unlock(&THREAD->lock);
     130       
     131        spinlock_lock(&TASK->lock);
     132        TASK->cycles += cycles;
     133        spinlock_unlock(&TASK->lock);
     134       
     135        interrupts_restore(ipl);
     136       
    121137        thread_exit();
    122138        /* not reached */
     
    534550        spinlock_lock(&threads_lock);
    535551       
    536         printf("tid    name       address    state    task       ctx code       stack      cycles     cpu  kst        wq\n");
     552        printf("tid    name       address    state    task       ctx code       stack      cycles     cpu  kstack     waitqueue\n");
    537553        printf("------ ---------- ---------- -------- ---------- --- ---------- ---------- ---------- ---- ---------- ----------\n");
    538554
     
    604620 * interrupts must be already disabled.
    605621 *
    606  * @param t Pointer to thread.
    607  *
    608622 */
    609623void thread_update_accounting(void)
Note: See TracChangeset for help on using the changeset viewer.