Subversion Repositories HelenOS

Rev

Rev 2032 | Rev 2042 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2032 Rev 2039
Line 111... Line 111...
111
{
111
{
112
    void (*f)(void *) = THREAD->thread_code;
112
    void (*f)(void *) = THREAD->thread_code;
113
    void *arg = THREAD->thread_arg;
113
    void *arg = THREAD->thread_arg;
114
    THREAD->last_cycle = get_cycle();
114
    THREAD->last_cycle = get_cycle();
115
 
115
 
116
    /* this is where each thread wakes up after its creation */
116
    /* This is where each thread wakes up after its creation */
117
    spinlock_unlock(&THREAD->lock);
117
    spinlock_unlock(&THREAD->lock);
118
    interrupts_enable();
118
    interrupts_enable();
119
 
119
 
120
    f(arg);
120
    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
   
121
    thread_exit();
137
    thread_exit();
122
    /* not reached */
138
    /* not reached */
123
}
139
}
124
 
140
 
125
/** Initialization and allocation for thread_t structure */
141
/** Initialization and allocation for thread_t structure */
Line 531... Line 547...
531
   
547
   
532
    /* Messing with thread structures, avoid deadlock */
548
    /* Messing with thread structures, avoid deadlock */
533
    ipl = interrupts_disable();
549
    ipl = interrupts_disable();
534
    spinlock_lock(&threads_lock);
550
    spinlock_lock(&threads_lock);
535
   
551
   
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");
537
    printf("------ ---------- ---------- -------- ---------- --- ---------- ---------- ---------- ---- ---------- ----------\n");
553
    printf("------ ---------- ---------- -------- ---------- --- ---------- ---------- ---------- ---- ---------- ----------\n");
538
 
554
 
539
    for (cur = threads_btree.leaf_head.next; cur != &threads_btree.leaf_head; cur = cur->next) {
555
    for (cur = threads_btree.leaf_head.next; cur != &threads_btree.leaf_head; cur = cur->next) {
540
        btree_node_t *node;
556
        btree_node_t *node;
541
        int i;
557
        int i;
Line 601... Line 617...
601
/** Update accounting of current thread.
617
/** Update accounting of current thread.
602
 *
618
 *
603
 * Note that thread_lock on THREAD must be already held and
619
 * Note that thread_lock on THREAD must be already held and
604
 * interrupts must be already disabled.
620
 * interrupts must be already disabled.
605
 *
621
 *
606
 * @param t Pointer to thread.
-
 
607
 *
-
 
608
 */
622
 */
609
void thread_update_accounting(void)
623
void thread_update_accounting(void)
610
{
624
{
611
    uint64_t time = get_cycle();
625
    uint64_t time = get_cycle();
612
    THREAD->cycles += time - THREAD->last_cycle;
626
    THREAD->cycles += time - THREAD->last_cycle;