Changeset 34dcd3f in mainline for generic/src/proc/task.c
- Timestamp:
- 2006-06-05T07:47:45Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c778c1a
- Parents:
- 7509ddc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/src/proc/task.c
r7509ddc r34dcd3f 59 59 static task_id_t task_counter = 0; 60 60 61 static void ktask _cleanup(void *);61 static void ktaskclnp(void *); 62 62 63 63 /** Initialize tasks … … 248 248 spinlock_unlock(&ta->lock); 249 249 250 t = thread_create(ktask _cleanup, NULL, ta, 0, "ktask_cleanup");250 t = thread_create(ktaskclnp, NULL, ta, 0, "ktaskclnp"); 251 251 252 252 spinlock_lock(&ta->lock); 253 ta->accept_new_threads = false; 253 254 ta->refcount--; 254 255 … … 271 272 } 272 273 273 thread_ready(t); 274 274 spinlock_unlock(&ta->lock); 275 interrupts_restore(ipl); 276 277 if (t) 278 thread_ready(t); 279 275 280 return 0; 276 281 } … … 314 319 315 320 /** Kernel thread used to cleanup the task. */ 316 void ktask_cleanup(void *arg) 317 { 321 void ktaskclnp(void *arg) 322 { 323 ipl_t ipl; 324 thread_t *t = NULL; 325 link_t *cur; 326 327 thread_detach(THREAD); 328 329 loop: 330 ipl = interrupts_disable(); 331 spinlock_lock(&TASK->lock); 332 333 /* 334 * Find a thread to join. 335 */ 336 for (cur = TASK->th_head.next; cur != &TASK->th_head; cur = cur->next) { 337 t = list_get_instance(cur, thread_t, th_link); 338 if (t == THREAD) 339 continue; 340 else 341 break; 342 } 343 344 spinlock_unlock(&TASK->lock); 345 interrupts_restore(ipl); 346 347 if (t != THREAD) { 348 thread_join(t); 349 thread_detach(t); 350 goto loop; 351 } 352 353 /* 354 * Now there are no other threads in this task 355 * and no new threads can be created. 356 */ 357 318 358 /* 319 359 * TODO: 320 * Wait until it is save to cleanup the task (i.e. all other threads exit) 321 * and do the cleanup (e.g. close IPC communication and release used futexes). 360 * Close IPC communication and release used futexes. 322 361 * When this thread exits, the task refcount drops to zero and the task structure is 323 362 * cleaned.
Note:
See TracChangeset
for help on using the changeset viewer.