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