Changes in kernel/generic/src/proc/task.c [feeac0d:c46bfbc] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/proc/task.c
rfeeac0d rc46bfbc 36 36 */ 37 37 38 #include <assert.h> 38 39 #include <proc/thread.h> 39 40 #include <proc/task.h> … … 41 42 #include <mm/slab.h> 42 43 #include <atomic.h> 44 #include <synch/futex.h> 43 45 #include <synch/spinlock.h> 44 46 #include <synch/waitq.h> … … 48 50 #include <adt/btree.h> 49 51 #include <adt/list.h> 52 #include <cap/cap.h> 50 53 #include <ipc/ipc.h> 51 54 #include <ipc/ipcrsc.h> … … 55 58 #include <func.h> 56 59 #include <str.h> 57 #include <memstr.h>58 60 #include <syscall/copy.h> 59 61 #include <macros.h> … … 82 84 static void task_kill_internal(task_t *); 83 85 static int tsk_constructor(void *, unsigned int); 86 static size_t tsk_destructor(void *obj); 84 87 85 88 /** Initialize kernel tasks support. … … 91 94 avltree_create(&tasks_tree); 92 95 task_slab = slab_cache_create("task_t", sizeof(task_t), 0, 93 tsk_constructor, NULL, 0);96 tsk_constructor, tsk_destructor, 0); 94 97 } 95 98 … … 158 161 { 159 162 task_t *task = (task_t *) obj; 163 164 int rc = caps_task_alloc(task); 165 if (rc != EOK) 166 return rc; 160 167 161 168 atomic_set(&task->refcount, 0); … … 163 170 164 171 irq_spinlock_initialize(&task->lock, "task_t_lock"); 165 mutex_initialize(&task->futexes_lock, MUTEX_PASSIVE);166 172 167 173 list_initialize(&task->threads); … … 169 175 ipc_answerbox_init(&task->answerbox, task); 170 176 171 size_t i;172 for (i = 0; i < IPC_MAX_PHONES; i++)173 ipc_phone_init(&task->phones[i], task);174 175 177 spinlock_initialize(&task->active_calls_lock, "active_calls_lock"); 176 178 list_initialize(&task->active_calls); 177 179 178 180 #ifdef CONFIG_UDEBUG 179 181 /* Init kbox stuff */ … … 186 188 } 187 189 190 size_t tsk_destructor(void *obj) 191 { 192 task_t *task = (task_t *) obj; 193 194 caps_task_free(task); 195 return 0; 196 } 197 188 198 /** Create new task with no threads. 189 199 * … … 203 213 204 214 task->container = CONTAINER; 205 task-> capabilities = 0;215 task->perms = 0; 206 216 task->ucycles = 0; 207 217 task->kcycles = 0; 218 219 caps_task_init(task); 208 220 209 221 task->ipc_info.call_sent = 0; … … 228 240 229 241 if ((ipc_phone_0) && 230 (container_check(ipc_phone_0->task->container, task->container))) 231 (void) ipc_phone_connect(&task->phones[0], ipc_phone_0); 232 233 btree_create(&task->futexes); 242 (container_check(ipc_phone_0->task->container, task->container))) { 243 cap_handle_t phone_handle = phone_alloc(task); 244 kobject_t *phone_obj = kobject_get(task, phone_handle, 245 KOBJECT_TYPE_PHONE); 246 (void) ipc_phone_connect(phone_obj->phone, ipc_phone_0); 247 } 248 249 futex_task_init(task); 234 250 235 251 /* … … 272 288 * Free up dynamically allocated state. 273 289 */ 274 btree_destroy(&task->futexes);290 futex_task_deinit(task); 275 291 276 292 /* … … 420 436 task_t *task_find_by_id(task_id_t id) 421 437 { 422 ASSERT(interrupts_disabled());423 ASSERT(irq_spinlock_locked(&tasks_lock));438 assert(interrupts_disabled()); 439 assert(irq_spinlock_locked(&tasks_lock)); 424 440 425 441 avltree_node_t *node = … … 444 460 void task_get_accounting(task_t *task, uint64_t *ucycles, uint64_t *kcycles) 445 461 { 446 ASSERT(interrupts_disabled());447 ASSERT(irq_spinlock_locked(&task->lock));462 assert(interrupts_disabled()); 463 assert(irq_spinlock_locked(&task->lock)); 448 464 449 465 /* Accumulated values of task */ … … 603 619 if (*additional) 604 620 printf("%-8" PRIu64 " %9" PRIu64 "%c %9" PRIu64 "%c " 605 "%9" PRIua , task->taskid, ucycles, usuffix, kcycles,621 "%9" PRIua "\n", task->taskid, ucycles, usuffix, kcycles, 606 622 ksuffix, atomic_get(&task->refcount)); 607 623 else … … 609 625 task->taskid, task->name, task->container, task, task->as); 610 626 #endif 611 612 if (*additional) {613 size_t i;614 for (i = 0; i < IPC_MAX_PHONES; i++) {615 if (task->phones[i].callee)616 printf(" %zu:%p", i, task->phones[i].callee);617 }618 printf("\n");619 }620 627 621 628 irq_spinlock_unlock(&task->lock, false);
Note:
See TracChangeset
for help on using the changeset viewer.