Subversion Repositories HelenOS

Rev

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

Rev 1787 Rev 1820
Line 121... Line 121...
121
}
121
}
122
 
122
 
123
/** Initialization and allocation for thread_t structure */
123
/** Initialization and allocation for thread_t structure */
124
static int thr_constructor(void *obj, int kmflags)
124
static int thr_constructor(void *obj, int kmflags)
125
{
125
{
126
    thread_t *t = (thread_t *)obj;
126
    thread_t *t = (thread_t *) obj;
127
 
127
 
128
    spinlock_initialize(&t->lock, "thread_t_lock");
128
    spinlock_initialize(&t->lock, "thread_t_lock");
129
    link_initialize(&t->rq_link);
129
    link_initialize(&t->rq_link);
130
    link_initialize(&t->wq_link);
130
    link_initialize(&t->wq_link);
131
    link_initialize(&t->th_link);
131
    link_initialize(&t->th_link);
Line 153... Line 153...
153
}
153
}
154
 
154
 
155
/** Destruction of thread_t object */
155
/** Destruction of thread_t object */
156
static int thr_destructor(void *obj)
156
static int thr_destructor(void *obj)
157
{
157
{
158
    thread_t *t = (thread_t *)obj;
158
    thread_t *t = (thread_t *) obj;
159
 
159
 
160
    frame_free(KA2PA(t->kstack));
160
    frame_free(KA2PA(t->kstack));
161
#ifdef ARCH_HAS_FPU
161
#ifdef ARCH_HAS_FPU
162
    if (t->saved_fpu_context)
162
    if (t->saved_fpu_context)
163
        slab_free(fpu_context_slab,t->saved_fpu_context);
163
        slab_free(fpu_context_slab,t->saved_fpu_context);
Line 297... Line 297...
297
        return NULL;
297
        return NULL;
298
 
298
 
299
    thread_create_arch(t);
299
    thread_create_arch(t);
300
   
300
   
301
    /* Not needed, but good for debugging */
301
    /* Not needed, but good for debugging */
302
    memsetb((uintptr_t)t->kstack, THREAD_STACK_SIZE * 1<<STACK_FRAMES, 0);
302
    memsetb((uintptr_t) t->kstack, THREAD_STACK_SIZE * 1 << STACK_FRAMES, 0);
303
   
303
   
304
    ipl = interrupts_disable();
304
    ipl = interrupts_disable();
305
    spinlock_lock(&tidlock);
305
    spinlock_lock(&tidlock);
306
    t->tid = ++last_tid;
306
    t->tid = ++last_tid;
307
    spinlock_unlock(&tidlock);
307
    spinlock_unlock(&tidlock);
Line 316... Line 316...
316
    t->saved_context.ipl = interrupts_read();
316
    t->saved_context.ipl = interrupts_read();
317
    interrupts_restore(ipl);
317
    interrupts_restore(ipl);
318
   
318
   
319
    memcpy(t->name, name, THREAD_NAME_BUFLEN);
319
    memcpy(t->name, name, THREAD_NAME_BUFLEN);
320
   
320
   
-
 
321
    t->context = THE->context;
321
    t->thread_code = func;
322
    t->thread_code = func;
322
    t->thread_arg = arg;
323
    t->thread_arg = arg;
323
    t->ticks = -1;
324
    t->ticks = -1;
324
    t->priority = -1;       /* start in rq[0] */
325
    t->priority = -1;       /* start in rq[0] */
325
    t->cpu = NULL;
326
    t->cpu = NULL;
Line 531... Line 532...
531
        node = list_get_instance(cur, btree_node_t, leaf_link);
532
        node = list_get_instance(cur, btree_node_t, leaf_link);
532
        for (i = 0; i < node->keys; i++) {
533
        for (i = 0; i < node->keys; i++) {
533
            thread_t *t;
534
            thread_t *t;
534
       
535
       
535
            t = (thread_t *) node->value[i];
536
            t = (thread_t *) node->value[i];
536
            printf("%s: address=%#zx, tid=%zd, state=%s, task=%#zx, code=%#zx, stack=%#zx, cpu=",
537
            printf("%s: address=%#zx, tid=%zd, context=%ld, state=%s, task=%#zx, code=%#zx, stack=%#zx, cpu=",
537
                t->name, t, t->tid, thread_states[t->state], t->task, t->thread_code, t->kstack);
538
                t->name, t, t->tid, t->context, thread_states[t->state], t->task, t->thread_code, t->kstack);
538
            if (t->cpu)
539
            if (t->cpu)
539
                printf("cpu%zd", t->cpu->id);
540
                printf("cpu%zd", t->cpu->id);
540
            else
541
            else
541
                printf("none");
542
                printf("none");
542
            if (t->state == Sleeping) {
543
            if (t->state == Sleeping) {