Changes in kernel/generic/src/proc/task.c [59ee56f:40240b1] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/proc/task.c
r59ee56f r40240b1 75 75 static task_id_t task_counter = 0; 76 76 77 static slab_cache_t *task_slab;78 79 77 /* Forward declarations. */ 80 78 static void task_kill_internal(task_t *); 81 static int tsk_constructor(void *, int);82 79 83 80 /** Initialize kernel tasks support. */ … … 86 83 TASK = NULL; 87 84 avltree_create(&tasks_tree); 88 task_slab = slab_cache_create("task_slab", sizeof(task_t), 0,89 tsk_constructor, NULL, 0);90 85 } 91 86 … … 133 128 } 134 129 135 int tsk_constructor(void *obj, int kmflags) 136 { 137 task_t *ta = obj; 130 /** Create new task with no threads. 131 * 132 * @param as Task's address space. 133 * @param name Symbolic name (a copy is made). 134 * 135 * @return New task's structure. 136 * 137 */ 138 task_t *task_create(as_t *as, char *name) 139 { 140 ipl_t ipl; 141 task_t *ta; 138 142 int i; 143 144 ta = (task_t *) malloc(sizeof(task_t), 0); 145 146 task_create_arch(ta); 147 148 spinlock_initialize(&ta->lock, "task_ta_lock"); 149 list_initialize(&ta->th_head); 150 ta->as = as; 151 152 memcpy(ta->name, name, TASK_NAME_BUFLEN); 153 ta->name[TASK_NAME_BUFLEN - 1] = 0; 139 154 140 155 atomic_set(&ta->refcount, 0); 141 156 atomic_set(&ta->lifecount, 0); 142 atomic_set(&ta->active_calls, 0); 143 144 spinlock_initialize(&ta->lock, "task_ta_lock"); 145 mutex_initialize(&ta->futexes_lock, MUTEX_PASSIVE); 146 147 list_initialize(&ta->th_head); 148 list_initialize(&ta->sync_box_head); 157 ta->context = CONTEXT; 158 159 ta->capabilities = 0; 160 ta->cycles = 0; 161 162 #ifdef CONFIG_UDEBUG 163 /* Init debugging stuff */ 164 udebug_task_init(&ta->udebug); 165 166 /* Init kbox stuff */ 167 ipc_answerbox_init(&ta->kb.box, ta); 168 ta->kb.thread = NULL; 169 mutex_initialize(&ta->kb.cleanup_lock, MUTEX_PASSIVE); 170 ta->kb.finished = false; 171 #endif 149 172 150 173 ipc_answerbox_init(&ta->answerbox, ta); 151 174 for (i = 0; i < IPC_MAX_PHONES; i++) 152 175 ipc_phone_init(&ta->phones[i]); 153 154 #ifdef CONFIG_UDEBUG 155 /* Init kbox stuff */ 156 ta->kb.thread = NULL; 157 ipc_answerbox_init(&ta->kb.box, ta); 158 mutex_initialize(&ta->kb.cleanup_lock, MUTEX_PASSIVE); 159 #endif 160 161 return 0; 162 } 163 164 /** Create new task with no threads. 165 * 166 * @param as Task's address space. 167 * @param name Symbolic name (a copy is made). 168 * 169 * @return New task's structure. 170 * 171 */ 172 task_t *task_create(as_t *as, char *name) 173 { 174 ipl_t ipl; 175 task_t *ta; 176 177 ta = (task_t *) slab_alloc(task_slab, 0); 178 task_create_arch(ta); 179 ta->as = as; 180 memcpy(ta->name, name, TASK_NAME_BUFLEN); 181 ta->name[TASK_NAME_BUFLEN - 1] = 0; 182 183 ta->context = CONTEXT; 184 ta->capabilities = 0; 185 ta->cycles = 0; 186 187 #ifdef CONFIG_UDEBUG 188 /* Init debugging stuff */ 189 udebug_task_init(&ta->udebug); 190 191 /* Init kbox stuff */ 192 ta->kb.finished = false; 193 #endif 194 195 if ((ipc_phone_0) && 196 (context_check(ipc_phone_0->task->context, ta->context))) 176 if ((ipc_phone_0) && (context_check(ipc_phone_0->task->context, 177 ta->context))) 197 178 ipc_phone_connect(&ta->phones[0], ipc_phone_0); 198 179 atomic_set(&ta->active_calls, 0); 180 181 mutex_initialize(&ta->futexes_lock, MUTEX_PASSIVE); 199 182 btree_create(&ta->futexes); 200 183 201 184 ipl = interrupts_disable(); 185 186 /* 187 * Increment address space reference count. 188 */ 202 189 atomic_inc(&as->refcount); 190 203 191 spinlock_lock(&tasks_lock); 204 192 ta->taskid = ++task_counter; … … 241 229 as_destroy(t->as); 242 230 243 slab_free(task_slab,t);231 free(t); 244 232 TASK = NULL; 245 233 }
Note:
See TracChangeset
for help on using the changeset viewer.