Changeset 62b6d17 in mainline for kernel/generic/src/proc


Ignore:
Timestamp:
2006-12-14T16:47:36Z (19 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
aeaebcc
Parents:
55cc9bc
Message:

introduce uncounted threads, whose accounting doesn't affect accumulated task accounting
run tests in kconsole thread again

Location:
kernel/generic/src/proc
Files:
2 edited

Legend:

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

    r55cc9bc r62b6d17  
    221221         * Create the main thread.
    222222         */
    223         t1 = thread_create(uinit, kernel_uarg, task, THREAD_FLAG_USPACE, "uinit");
     223        t1 = thread_create(uinit, kernel_uarg, task, THREAD_FLAG_USPACE, "uinit", false);
    224224        ASSERT(t1);
    225225       
     
    227227         * Create killer thread for the new task.
    228228         */
    229         t2 = thread_create(ktaskgc, t1, task, 0, "ktaskgc");
     229        t2 = thread_create(ktaskgc, t1, task, 0, "ktaskgc", true);
    230230        ASSERT(t2);
    231231        thread_ready(t2);
     
    286286               
    287287                spinlock_lock(&thr->lock);
    288                
    289                 if (thr == THREAD) /* Update accounting of current thread */
    290                         thread_update_accounting();
    291                 ret += thr->cycles;
    292                
     288                /* Process only counted threads */
     289                if (!thr->uncounted) {
     290                        if (thr == THREAD) /* Update accounting of current thread */
     291                                thread_update_accounting();
     292                        ret += thr->cycles;
     293                }
    293294                spinlock_unlock(&thr->lock);
    294295        }
     
    329330        spinlock_unlock(&tasks_lock);
    330331       
    331         t = thread_create(ktaskclnp, NULL, ta, 0, "ktaskclnp");
     332        t = thread_create(ktaskclnp, NULL, ta, 0, "ktaskclnp", true);
    332333       
    333334        spinlock_lock(&ta->lock);
  • kernel/generic/src/proc/thread.c

    r55cc9bc r62b6d17  
    124124       
    125125        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);
     126        if (!THREAD->uncounted) {
     127                thread_update_accounting();
     128                uint64_t cycles = THREAD->cycles;
     129                THREAD->cycles = 0;
     130                spinlock_unlock(&THREAD->lock);
     131               
     132                spinlock_lock(&TASK->lock);
     133                TASK->cycles += cycles;
     134                spinlock_unlock(&TASK->lock);
     135        } else
     136                spinlock_unlock(&THREAD->lock);
    134137       
    135138        interrupts_restore(ipl);
     
    303306 * Create a new thread.
    304307 *
    305  * @param func  Thread's implementing function.
    306  * @param arg   Thread's implementing function argument.
    307  * @param task  Task to which the thread belongs.
    308  * @param flags Thread flags.
    309  * @param name  Symbolic name.
     308 * @param func      Thread's implementing function.
     309 * @param arg       Thread's implementing function argument.
     310 * @param task      Task to which the thread belongs.
     311 * @param flags     Thread flags.
     312 * @param name      Symbolic name.
     313 * @param uncounted Thread's accounting doesn't affect accumulated task accounting.
    310314 *
    311315 * @return New thread's structure on success, NULL on failure.
    312316 *
    313317 */
    314 thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name)
     318thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name, bool uncounted)
    315319{
    316320        thread_t *t;
     
    345349        t->ticks = -1;
    346350        t->cycles = 0;
     351        t->uncounted = uncounted;
    347352        t->priority = -1;               /* start in rq[0] */
    348353        t->cpu = NULL;
     
    650655        }
    651656
    652         if ((t = thread_create(uinit, kernel_uarg, TASK, THREAD_FLAG_USPACE, namebuf))) {
     657        if ((t = thread_create(uinit, kernel_uarg, TASK, THREAD_FLAG_USPACE, namebuf, false))) {
    653658                tid = t->tid;
    654659                thread_ready(t);
Note: See TracChangeset for help on using the changeset viewer.