Create new task with no threads. * * @param as Task's address space. * @param name Symbolic name (a copy is made). * * @return New task's structure. * */
| 196 | * |
| 197 | */ |
| 198 | task_t *task_create(as_t *as, const char *name) |
| 199 | { |
| 200 | task_t *task = (task_t *) slab_alloc(task_cache, FRAME_ATOMIC); |
| 201 | if (!task) |
| 202 | return NULL; |
| 203 | |
| 204 | task_create_arch(task); |
| 205 | |
| 206 | task->as = as; |
| 207 | str_cpy(task->name, TASK_NAME_BUFLEN, name); |
| 208 | |
| 209 | task->container = CONTAINER; |
| 210 | task->perms = 0; |
| 211 | task->ucycles = 0; |
| 212 | task->kcycles = 0; |
| 213 | |
| 214 | caps_task_init(task); |
| 215 | |
| 216 | task->ipc_info.call_sent = 0; |
| 217 | task->ipc_info.call_received = 0; |
| 218 | task->ipc_info.answer_sent = 0; |
| 219 | task->ipc_info.answer_received = 0; |
| 220 | task->ipc_info.irq_notif_received = 0; |
| 221 | task->ipc_info.forwarded = 0; |
| 222 | |
| 223 | event_task_init(task); |
| 224 | |
| 225 | task->answerbox.active = true; |
| 226 | |
| 227 | #ifdef CONFIG_UDEBUG |
| 228 | /* Init debugging stuff */ |
| 229 | udebug_task_init(&task->udebug); |
| 230 | |
| 231 | /* Init kbox stuff */ |
| 232 | task->kb.box.active = true; |
| 233 | task->kb.finished = false; |
| 234 | #endif |
| 235 | |
| 236 | if ((ipc_box_0) && |
| 237 | (container_check(ipc_box_0->task->container, task->container))) { |
| 238 | cap_phone_handle_t phone_handle; |
| 239 | errno_t rc = phone_alloc(task, true, &phone_handle, NULL); |
| 240 | if (rc != EOK) { |
| 241 | task->as = NULL; |
| 242 | task_destroy_arch(task); |
| 243 | slab_free(task_cache, task); |
| 244 | return NULL; |
| 245 | } |
| 246 | |
| 247 | kobject_t *phone_obj = kobject_get(task, phone_handle, |
| 248 | KOBJECT_TYPE_PHONE); |
| 249 | (void) ipc_phone_connect(phone_obj->phone, ipc_box_0); |
| 250 | } |
| 251 | |
| 252 | irq_spinlock_lock(&tasks_lock, true); |
| 253 | |
| 254 | task->taskid = ++task_counter; |
| 255 | odlink_initialize(&task->ltasks); |
no test coverage detected