Changeset 7509ddc in mainline for generic/src/proc/task.c
- Timestamp:
- 2006-06-04T21:54:49Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 34dcd3f
- Parents:
- 2cb5e64
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
generic/src/proc/task.c
r2cb5e64 r7509ddc 48 48 #include <print.h> 49 49 #include <elf.h> 50 #include <errno.h> 50 51 #include <syscall/copy.h> 51 52 … … 57 58 btree_t tasks_btree; 58 59 static task_id_t task_counter = 0; 60 61 static void ktask_cleanup(void *); 59 62 60 63 /** Initialize tasks … … 95 98 ta->name = name; 96 99 100 ta->refcount = 0; 101 97 102 ta->capabilities = 0; 103 ta->accept_new_threads = true; 98 104 99 105 ipc_answerbox_init(&ta->answerbox); … … 128 134 } 129 135 136 /** Destroy task. 137 * 138 * @param t Task to be destroyed. 139 */ 140 void task_destroy(task_t *t) 141 { 142 } 143 130 144 /** Create new task with 1 thread and run it 131 145 * … … 206 220 207 221 return (task_t *) btree_search(&tasks_btree, (btree_key_t) id, &leaf); 222 } 223 224 /** Kill task. 225 * 226 * @param id ID of the task to be killed. 227 * 228 * @return 0 on success or an error code from errno.h 229 */ 230 int task_kill(task_id_t id) 231 { 232 ipl_t ipl; 233 task_t *ta; 234 thread_t *t; 235 link_t *cur; 236 237 ipl = interrupts_disable(); 238 spinlock_lock(&tasks_lock); 239 240 if (!(ta = task_find_by_id(id))) { 241 spinlock_unlock(&tasks_lock); 242 interrupts_restore(ipl); 243 return ENOENT; 244 } 245 246 spinlock_lock(&ta->lock); 247 ta->refcount++; 248 spinlock_unlock(&ta->lock); 249 250 t = thread_create(ktask_cleanup, NULL, ta, 0, "ktask_cleanup"); 251 252 spinlock_lock(&ta->lock); 253 ta->refcount--; 254 255 for (cur = ta->th_head.next; cur != &ta->th_head; cur = cur->next) { 256 thread_t *thr; 257 bool sleeping = false; 258 259 thr = list_get_instance(cur, thread_t, th_link); 260 if (thr == t) 261 continue; 262 263 spinlock_lock(&thr->lock); 264 thr->interrupted = true; 265 if (thr->state == Sleeping) 266 sleeping = true; 267 spinlock_unlock(&thr->lock); 268 269 if (sleeping) 270 waitq_interrupt_sleep(thr); 271 } 272 273 thread_ready(t); 274 275 return 0; 208 276 } 209 277 … … 244 312 interrupts_restore(ipl); 245 313 } 314 315 /** Kernel thread used to cleanup the task. */ 316 void ktask_cleanup(void *arg) 317 { 318 /* 319 * 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). 322 * When this thread exits, the task refcount drops to zero and the task structure is 323 * cleaned. 324 */ 325 }
Note:
See TracChangeset
for help on using the changeset viewer.