Subversion Repositories HelenOS

Rev

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

Rev 2039 Rev 2042
Line 121... Line 121...
121
   
121
   
122
    /* Accumulate accounting to the task */
122
    /* Accumulate accounting to the task */
123
    ipl_t ipl = interrupts_disable();
123
    ipl_t ipl = interrupts_disable();
124
   
124
   
125
    spinlock_lock(&THREAD->lock);
125
    spinlock_lock(&THREAD->lock);
-
 
126
    if (!THREAD->uncounted) {
126
    thread_update_accounting();
127
        thread_update_accounting();
127
    uint64_t cycles = THREAD->cycles;
128
        uint64_t cycles = THREAD->cycles;
128
    THREAD->cycles = 0;
129
        THREAD->cycles = 0;
129
    spinlock_unlock(&THREAD->lock);
130
        spinlock_unlock(&THREAD->lock);
130
   
131
       
131
    spinlock_lock(&TASK->lock);
132
        spinlock_lock(&TASK->lock);
132
    TASK->cycles += cycles;
133
        TASK->cycles += cycles;
133
    spinlock_unlock(&TASK->lock);
134
        spinlock_unlock(&TASK->lock);
-
 
135
    } else
-
 
136
        spinlock_unlock(&THREAD->lock);
134
   
137
   
135
    interrupts_restore(ipl);
138
    interrupts_restore(ipl);
136
   
139
   
137
    thread_exit();
140
    thread_exit();
138
    /* not reached */
141
    /* not reached */
Line 300... Line 303...
300
 
303
 
301
/** Create new thread
304
/** Create new thread
302
 *
305
 *
303
 * Create a new thread.
306
 * Create a new thread.
304
 *
307
 *
305
 * @param func  Thread's implementing function.
308
 * @param func      Thread's implementing function.
306
 * @param arg   Thread's implementing function argument.
309
 * @param arg       Thread's implementing function argument.
307
 * @param task  Task to which the thread belongs.
310
 * @param task      Task to which the thread belongs.
308
 * @param flags Thread flags.
311
 * @param flags     Thread flags.
309
 * @param name  Symbolic name.
312
 * @param name      Symbolic name.
-
 
313
 * @param uncounted Thread's accounting doesn't affect accumulated task accounting.
310
 *
314
 *
311
 * @return New thread's structure on success, NULL on failure.
315
 * @return New thread's structure on success, NULL on failure.
312
 *
316
 *
313
 */
317
 */
314
thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name)
318
thread_t *thread_create(void (* func)(void *), void *arg, task_t *task, int flags, char *name, bool uncounted)
315
{
319
{
316
    thread_t *t;
320
    thread_t *t;
317
    ipl_t ipl;
321
    ipl_t ipl;
318
   
322
   
319
    t = (thread_t *) slab_alloc(thread_slab, 0);
323
    t = (thread_t *) slab_alloc(thread_slab, 0);
Line 342... Line 346...
342
   
346
   
343
    t->thread_code = func;
347
    t->thread_code = func;
344
    t->thread_arg = arg;
348
    t->thread_arg = arg;
345
    t->ticks = -1;
349
    t->ticks = -1;
346
    t->cycles = 0;
350
    t->cycles = 0;
-
 
351
    t->uncounted = uncounted;
347
    t->priority = -1;       /* start in rq[0] */
352
    t->priority = -1;       /* start in rq[0] */
348
    t->cpu = NULL;
353
    t->cpu = NULL;
349
    t->flags = flags;
354
    t->flags = flags;
350
    t->state = Entering;
355
    t->state = Entering;
351
    t->call_me = NULL;
356
    t->call_me = NULL;
Line 647... Line 652...
647
    if (rc != 0) {
652
    if (rc != 0) {
648
        free(kernel_uarg);
653
        free(kernel_uarg);
649
        return (unative_t) rc;
654
        return (unative_t) rc;
650
    }
655
    }
651
 
656
 
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))) {
653
        tid = t->tid;
658
        tid = t->tid;
654
        thread_ready(t);
659
        thread_ready(t);
655
        return (unative_t) tid;
660
        return (unative_t) tid;
656
    } else {
661
    } else {
657
        free(kernel_uarg);
662
        free(kernel_uarg);