Subversion Repositories HelenOS

Rev

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

Rev 1585 Rev 1587
Line 138... Line 138...
138
 *
138
 *
139
 * @param t Task to be destroyed.
139
 * @param t Task to be destroyed.
140
 */
140
 */
141
void task_destroy(task_t *t)
141
void task_destroy(task_t *t)
142
{
142
{
-
 
143
    spinlock_lock(&tasks_lock);
-
 
144
    btree_remove(&tasks_btree, t->taskid, NULL);
-
 
145
    spinlock_unlock(&tasks_lock);
-
 
146
 
-
 
147
    task_destroy_arch(t);
-
 
148
    btree_destroy(&t->futexes);
-
 
149
 
-
 
150
    mutex_lock_active(&t->as->lock);
-
 
151
    if (--t->as->refcount == 0) {
-
 
152
        mutex_unlock(&t->as->lock);
-
 
153
        as_destroy(t->as);
-
 
154
        /*
-
 
155
         * t->as is destroyed.
-
 
156
         */
-
 
157
    } else {
-
 
158
        mutex_unlock(&t->as->lock);
-
 
159
    }
-
 
160
   
-
 
161
    free(t);
-
 
162
    TASK = NULL;
143
}
163
}
144
 
164
 
145
/** Create new task with 1 thread and run it
165
/** Create new task with 1 thread and run it
146
 *
166
 *
147
 * @param program_addr Address of program executable image.
167
 * @param program_addr Address of program executable image.
Line 256... Line 276...
256
    }
276
    }
257
   
277
   
258
    spinlock_lock(&ta->lock);
278
    spinlock_lock(&ta->lock);
259
    ta->refcount++;
279
    ta->refcount++;
260
    spinlock_unlock(&ta->lock);
280
    spinlock_unlock(&ta->lock);
-
 
281
 
-
 
282
    spinlock_unlock(&tasks_lock);
261
   
283
   
262
    t = thread_create(ktaskclnp, NULL, ta, 0, "ktaskclnp");
284
    t = thread_create(ktaskclnp, NULL, ta, 0, "ktaskclnp");
263
   
285
   
264
    spinlock_lock(&ta->lock);
286
    spinlock_lock(&ta->lock);
265
    ta->accept_new_threads = false;
287
    ta->accept_new_threads = false;