Changeset 0313ff0 in mainline for kernel/generic/src/console/cmd.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/console/cmd.c

    rcd896e2 r0313ff0  
    5757#include <mm/tlb.h>
    5858#include <arch/mm/tlb.h>
     59#include <mm/as.h>
    5960#include <mm/frame.h>
    6061#include <main/version.h>
     
    859860}
    860861
    861 static bool run_test(const test_t * test)
    862 {
    863         printf("%s\t\t%s\n", test->name, test->desc);
     862static void test_wrapper(void *arg)
     863{
     864        test_t *test = (test_t *) arg;
    864865       
    865866        /* Update and read thread accounting
    866867           for benchmarking */
    867868        ipl_t ipl = interrupts_disable();
    868         spinlock_lock(&THREAD->lock);
    869         thread_update_accounting();
    870         uint64_t t0 = THREAD->cycles;
    871         spinlock_unlock(&THREAD->lock);
     869        spinlock_lock(&TASK->lock);
     870        uint64_t t0 = task_get_accounting(TASK);
     871        spinlock_unlock(&TASK->lock);
    872872        interrupts_restore(ipl);
    873873       
     
    877877        /* Update and read thread accounting */
    878878        ipl = interrupts_disable();
    879         spinlock_lock(&THREAD->lock);
    880         thread_update_accounting();
    881         uint64_t dt = THREAD->cycles - t0;
    882         spinlock_unlock(&THREAD->lock);
     879        spinlock_lock(&TASK->lock);
     880        uint64_t dt = task_get_accounting(TASK) - t0;
     881        spinlock_unlock(&TASK->lock);
    883882        interrupts_restore(ipl);
    884883       
     
    887886        if (ret == NULL) {
    888887                printf("Test passed\n");
    889                 return true;
     888//              return true;
     889                return;
    890890        }
    891891
    892892        printf("%s\n", ret);
    893         return false;
     893//      return false;
     894}
     895
     896static bool run_test(const test_t *test)
     897{
     898        printf("%s\t\t%s\n", test->name, test->desc);
     899       
     900        /* Create separate task and thread
     901           for the test */
     902        task_t *ta = task_create(AS_KERNEL, "test");
     903        if (ta == NULL) {
     904                printf("Unable to create test task\n");
     905                return false;
     906        }
     907       
     908        thread_t *t = thread_create(test_wrapper, (void *) test, ta, 0, "test_main");
     909        if (t == NULL) {
     910                printf("Unable to create test main thread\n");
     911                task_destroy(ta);
     912                return false;
     913        }
     914       
     915        /* Run the test */
     916        thread_ready(t);
     917        thread_join(t);
     918        thread_detach(t);
     919       
     920        return true;
    894921}
    895922
Note: See TracChangeset for help on using the changeset viewer.