Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2041 → Rev 2042

/trunk/kernel/generic/src/proc/task.c
220,13 → 220,13
/*
* Create the main thread.
*/
t1 = thread_create(uinit, kernel_uarg, task, THREAD_FLAG_USPACE, "uinit");
t1 = thread_create(uinit, kernel_uarg, task, THREAD_FLAG_USPACE, "uinit", false);
ASSERT(t1);
/*
* Create killer thread for the new task.
*/
t2 = thread_create(ktaskgc, t1, task, 0, "ktaskgc");
t2 = thread_create(ktaskgc, t1, task, 0, "ktaskgc", true);
ASSERT(t2);
thread_ready(t2);
 
285,11 → 285,12
thread_t *thr = list_get_instance(cur, thread_t, th_link);
spinlock_lock(&thr->lock);
if (thr == THREAD) /* Update accounting of current thread */
thread_update_accounting();
ret += thr->cycles;
/* Process only counted threads */
if (!thr->uncounted) {
if (thr == THREAD) /* Update accounting of current thread */
thread_update_accounting();
ret += thr->cycles;
}
spinlock_unlock(&thr->lock);
}
328,7 → 329,7
btree_remove(&tasks_btree, ta->taskid, NULL);
spinlock_unlock(&tasks_lock);
t = thread_create(ktaskclnp, NULL, ta, 0, "ktaskclnp");
t = thread_create(ktaskclnp, NULL, ta, 0, "ktaskclnp", true);
spinlock_lock(&ta->lock);
ta->accept_new_threads = false;
/trunk/kernel/generic/src/proc/thread.c
123,15 → 123,18
ipl_t ipl = interrupts_disable();
spinlock_lock(&THREAD->lock);
thread_update_accounting();
uint64_t cycles = THREAD->cycles;
THREAD->cycles = 0;
spinlock_unlock(&THREAD->lock);
if (!THREAD->uncounted) {
thread_update_accounting();
uint64_t cycles = THREAD->cycles;
THREAD->cycles = 0;
spinlock_unlock(&THREAD->lock);
spinlock_lock(&TASK->lock);
TASK->cycles += cycles;
spinlock_unlock(&TASK->lock);
} else
spinlock_unlock(&THREAD->lock);
spinlock_lock(&TASK->lock);
TASK->cycles += cycles;
spinlock_unlock(&TASK->lock);
interrupts_restore(ipl);
thread_exit();
302,16 → 305,17
*
* Create a new thread.
*
* @param func Thread's implementing function.
* @param arg Thread's implementing function argument.
* @param task Task to which the thread belongs.
* @param flags Thread flags.
* @param name Symbolic name.
* @param func Thread's implementing function.
* @param arg Thread's implementing function argument.
* @param task Task to which the thread belongs.
* @param flags Thread flags.
* @param name Symbolic name.
* @param uncounted Thread's accounting doesn't affect accumulated task accounting.
*
* @return New thread's structure on success, NULL on failure.
*
*/
thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name)
thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name, bool uncounted)
{
thread_t *t;
ipl_t ipl;
344,6 → 348,7
t->thread_arg = arg;
t->ticks = -1;
t->cycles = 0;
t->uncounted = uncounted;
t->priority = -1; /* start in rq[0] */
t->cpu = NULL;
t->flags = flags;
649,7 → 654,7
return (unative_t) rc;
}
 
if ((t = thread_create(uinit, kernel_uarg, TASK, THREAD_FLAG_USPACE, namebuf))) {
if ((t = thread_create(uinit, kernel_uarg, TASK, THREAD_FLAG_USPACE, namebuf, false))) {
tid = t->tid;
thread_ready(t);
return (unative_t) tid;