Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2041 → Rev 2042

/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;