Changeset a2a00e8 in mainline for kernel/generic/src/proc/thread.c


Ignore:
Timestamp:
2010-03-28T23:05:18Z (15 years ago)
Author:
Stanislav Kozina <stanislav.kozina@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
07640dfd
Parents:
34bba0e
Message:

Accounting separated to kernel and user time.

File:
1 edited

Legend:

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

    r34bba0e ra2a00e8  
    132132        spinlock_lock(&THREAD->lock);
    133133        if (!THREAD->uncounted) {
    134                 thread_update_accounting();
     134                thread_update_accounting(true);
    135135                uint64_t cycles = THREAD->cycles;
    136136                THREAD->cycles = 0;
     137                uint64_t ucycles = THREAD->ucycles;
     138                THREAD->ucycles = 0;
     139                uint64_t kcycles = THREAD->kcycles;
     140                THREAD->kcycles = 0;
     141
    137142                spinlock_unlock(&THREAD->lock);
    138143               
    139144                spinlock_lock(&TASK->lock);
    140145                TASK->cycles += cycles;
     146                TASK->ucycles += ucycles;
     147                TASK->kcycles += kcycles;
    141148                spinlock_unlock(&TASK->lock);
    142149        } else
     
    324331        t->ticks = -1;
    325332        t->cycles = 0;
     333        t->ucycles = 0;
     334        t->kcycles = 0;
    326335        t->uncounted = uncounted;
    327336        t->priority = -1;               /* start in rq[0] */
     
    614623        thread_t *t = avltree_get_instance(node, thread_t, threads_tree_node);
    615624       
    616         uint64_t cycles;
    617         char suffix;
     625        uint64_t cycles, ucycles, kcycles;
     626        char suffix, usuffix, ksuffix;
    618627        order(t->cycles, &cycles, &suffix);
     628        order(t->ucycles, &ucycles, &usuffix);
     629        order(t->kcycles, &kcycles, &ksuffix);
    619630
    620631#ifdef __32_BITS__
    621         printf("%-6" PRIu64" %-10s %10p %-8s %10p %-3" PRIu32 " %10p %10p %9" PRIu64 "%c ",
     632        printf("%-6" PRIu64" %-10s %10p %-8s %10p %-3" PRIu32 " %10p %10p %9" PRIu64 "%c %9" PRIu64 "%c %9" PRIu64 "%c ",
    622633            t->tid, t->name, t, thread_states[t->state], t->task,
    623         t->task->context, t->thread_code, t->kstack, cycles, suffix);
     634        t->task->context, t->thread_code, t->kstack, cycles, suffix, ucycles, usuffix, kcycles, ksuffix);
    624635#endif
    625636
    626637#ifdef __64_BITS__
    627         printf("%-6" PRIu64" %-10s %18p %-8s %18p %-3" PRIu32 " %18p %18p %9" PRIu64 "%c ",
     638        printf("%-6" PRIu64" %-10s %18p %-8s %18p %-3" PRIu32 " %18p %18p %9" PRIu64 "%c %9" PRIu64 "%c %9" PRIu64 "%c ",
    628639            t->tid, t->name, t, thread_states[t->state], t->task,
    629         t->task->context, t->thread_code, t->kstack, cycles, suffix);
     640        t->task->context, t->thread_code, t->kstack, cycles, suffix, ucycles, usuffix, kcycles, ksuffix);
    630641#endif
    631642                       
     
    661672#ifdef __32_BITS__     
    662673        printf("tid    name       address    state    task       "
    663                 "ctx code       stack      cycles     cpu  "
     674                "ctx code       stack      cycles     ucycles    kcycles    cpu  "
    664675                "waitqueue\n");
    665676        printf("------ ---------- ---------- -------- ---------- "
    666                 "--- ---------- ---------- ---------- ---- "
     677                "--- ---------- ---------- ---------- ---------- ---------- ---- "
    667678                "----------\n");
    668679#endif
     
    670681#ifdef __64_BITS__
    671682        printf("tid    name       address            state    task               "
    672                 "ctx code               stack              cycles     cpu  "
     683                "ctx code               stack              cycles     ucycles    kcycles    cpu  "
    673684                "waitqueue\n");
    674685        printf("------ ---------- ------------------ -------- ------------------ "
    675                 "--- ------------------ ------------------ ---------- ---- "
     686                "--- ------------------ ------------------ ---------- ---------- ---------- ---- "
    676687                "------------------\n");
    677688#endif
     
    706717 * interrupts must be already disabled.
    707718 *
    708  */
    709 void thread_update_accounting(void)
     719 * @param user  True to update user accounting, false for kernel.
     720 */
     721void thread_update_accounting(bool user)
    710722{
    711723        uint64_t time = get_cycle();
    712724        THREAD->cycles += time - THREAD->last_cycle;
     725        if (user) {
     726                THREAD->ucycles += time - THREAD->last_cycle;
     727        } else {
     728                THREAD->kcycles += time - THREAD->last_cycle;
     729        }
    713730        THREAD->last_cycle = time;
    714731}
Note: See TracChangeset for help on using the changeset viewer.