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