Changeset fbcfc4da in mainline for kernel/generic/src/proc/task.c
- Timestamp:
- 2009-12-03T19:25:17Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9510be2
- Parents:
- cb3d641a (diff), 22e6802 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/proc/task.c
rcb3d641a rfbcfc4da 54 54 #include <func.h> 55 55 #include <string.h> 56 #include <memstr.h> 56 57 #include <syscall/copy.h> 57 58 #include <macros.h> … … 75 76 static task_id_t task_counter = 0; 76 77 78 static slab_cache_t *task_slab; 79 77 80 /* Forward declarations. */ 78 81 static void task_kill_internal(task_t *); 82 static int tsk_constructor(void *, int); 79 83 80 84 /** Initialize kernel tasks support. */ … … 83 87 TASK = NULL; 84 88 avltree_create(&tasks_tree); 89 task_slab = slab_cache_create("task_slab", sizeof(task_t), 0, 90 tsk_constructor, NULL, 0); 85 91 } 86 92 … … 128 134 } 129 135 136 int tsk_constructor(void *obj, int kmflags) 137 { 138 task_t *ta = obj; 139 int i; 140 141 atomic_set(&ta->refcount, 0); 142 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); 150 151 ipc_answerbox_init(&ta->answerbox, ta); 152 for (i = 0; i < IPC_MAX_PHONES; i++) 153 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 130 165 /** Create new task with no threads. 131 166 * … … 140 175 ipl_t ipl; 141 176 task_t *ta; 142 int i; 143 144 ta = (task_t *) malloc(sizeof(task_t), 0); 145 177 178 ta = (task_t *) slab_alloc(task_slab, 0); 146 179 task_create_arch(ta); 147 148 spinlock_initialize(&ta->lock, "task_ta_lock");149 list_initialize(&ta->th_head);150 180 ta->as = as; 151 152 181 memcpy(ta->name, name, TASK_NAME_BUFLEN); 153 182 ta->name[TASK_NAME_BUFLEN - 1] = 0; 154 183 155 atomic_set(&ta->refcount, 0);156 atomic_set(&ta->lifecount, 0);157 184 ta->context = CONTEXT; 158 159 185 ta->capabilities = 0; 160 186 ta->cycles = 0; … … 165 191 166 192 /* 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 193 ta->kb.finished = false; 171 194 #endif 172 195 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))) 196 if ((ipc_phone_0) && 197 (context_check(ipc_phone_0->task->context, ta->context))) 178 198 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); 199 182 200 btree_create(&ta->futexes); 183 201 184 202 ipl = interrupts_disable(); 185 186 /*187 * Increment address space reference count.188 */189 203 atomic_inc(&as->refcount); 190 191 204 spinlock_lock(&tasks_lock); 192 205 ta->taskid = ++task_counter; … … 229 242 as_destroy(t->as); 230 243 231 free(t);244 slab_free(task_slab, t); 232 245 TASK = NULL; 233 246 }
Note:
See TracChangeset
for help on using the changeset viewer.