Subversion Repositories HelenOS

Rev

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

Rev 2216 Rev 2227
Line 91... Line 91...
91
{
91
{
92
    TASK = NULL;
92
    TASK = NULL;
93
    btree_create(&tasks_btree);
93
    btree_create(&tasks_btree);
94
}
94
}
95
 
95
 
-
 
96
/** Kill all tasks except the current task.
-
 
97
 *
-
 
98
 */
-
 
99
void task_done(void)
-
 
100
{
-
 
101
    task_t *t;
-
 
102
    do { /* Repeat until there are any tasks except TASK */
-
 
103
       
-
 
104
        /* Messing with task structures, avoid deadlock */
-
 
105
        ipl_t ipl = interrupts_disable();
-
 
106
        spinlock_lock(&tasks_lock);
-
 
107
       
-
 
108
        t = NULL;
-
 
109
        link_t *cur;
-
 
110
        for (cur = tasks_btree.leaf_head.next; cur != &tasks_btree.leaf_head; cur = cur->next) {
-
 
111
            btree_node_t *node = list_get_instance(cur, btree_node_t, leaf_link);
-
 
112
           
-
 
113
            unsigned int i;
-
 
114
            for (i = 0; i < node->keys; i++) {
-
 
115
                if ((task_t *) node->value[i] != TASK) {
-
 
116
                    t = (task_t *) node->value[i];
-
 
117
                    break;
-
 
118
                }
-
 
119
            }
-
 
120
        }
-
 
121
       
-
 
122
        if (t != NULL) {
-
 
123
            task_id_t id = t->taskid;
-
 
124
           
-
 
125
            spinlock_unlock(&tasks_lock);
-
 
126
            interrupts_restore(ipl);
-
 
127
           
-
 
128
#ifdef CONFIG_DEBUG
-
 
129
            printf("Killing task %llu\n", id);
-
 
130
#endif          
-
 
131
            task_kill(id);
-
 
132
        } else {
-
 
133
            spinlock_unlock(&tasks_lock);
-
 
134
            interrupts_restore(ipl);
-
 
135
        }
-
 
136
       
-
 
137
    } while (t != NULL);
-
 
138
}
96
 
139
 
97
/** Create new task
140
/** Create new task
98
 *
141
 *
99
 * Create new task with no threads.
142
 * Create new task with no threads.
100
 *
143
 *
Line 371... Line 414...
371
void task_print_list(void)
414
void task_print_list(void)
372
{
415
{
373
    link_t *cur;
416
    link_t *cur;
374
    ipl_t ipl;
417
    ipl_t ipl;
375
   
418
   
376
    /* Messing with thread structures, avoid deadlock */
419
    /* Messing with task structures, avoid deadlock */
377
    ipl = interrupts_disable();
420
    ipl = interrupts_disable();
378
    spinlock_lock(&tasks_lock);
421
    spinlock_lock(&tasks_lock);
379
   
422
   
380
    printf("taskid name       ctx address    as         cycles     threads "
423
    printf("taskid name       ctx address    as         cycles     threads "
381
        "calls  callee\n");
424
        "calls  callee\n");