Changeset 59ee56f in mainline for kernel/generic/src/proc/task.c
- Timestamp:
- 2009-11-28T14:38:17Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 67392fa
- Parents:
- e701eb1
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/proc/task.c
re701eb1 r59ee56f 79 79 /* Forward declarations. */ 80 80 static void task_kill_internal(task_t *); 81 static int tsk_constructor(void *, int); 81 82 82 83 /** Initialize kernel tasks support. */ … … 85 86 TASK = NULL; 86 87 avltree_create(&tasks_tree); 87 task_slab = slab_cache_create("task_slab", sizeof(task_t), 0, NULL,88 NULL, 0);88 task_slab = slab_cache_create("task_slab", sizeof(task_t), 0, 89 tsk_constructor, NULL, 0); 89 90 } 90 91 … … 132 133 } 133 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 134 164 /** Create new task with no threads. 135 165 * … … 144 174 ipl_t ipl; 145 175 task_t *ta; 146 int i;147 176 148 177 ta = (task_t *) slab_alloc(task_slab, 0); 149 150 178 task_create_arch(ta); 151 152 spinlock_initialize(&ta->lock, "task_ta_lock");153 list_initialize(&ta->th_head);154 179 ta->as = as; 155 156 180 memcpy(ta->name, name, TASK_NAME_BUFLEN); 157 181 ta->name[TASK_NAME_BUFLEN - 1] = 0; 158 182 159 atomic_set(&ta->refcount, 0);160 atomic_set(&ta->lifecount, 0);161 183 ta->context = CONTEXT; 162 163 184 ta->capabilities = 0; 164 185 ta->cycles = 0; … … 169 190 170 191 /* Init kbox stuff */ 171 ipc_answerbox_init(&ta->kb.box, ta);172 ta->kb.thread = NULL;173 mutex_initialize(&ta->kb.cleanup_lock, MUTEX_PASSIVE);174 192 ta->kb.finished = false; 175 193 #endif 176 194 177 ipc_answerbox_init(&ta->answerbox, ta); 178 for (i = 0; i < IPC_MAX_PHONES; i++) 179 ipc_phone_init(&ta->phones[i]); 180 if ((ipc_phone_0) && (context_check(ipc_phone_0->task->context, 181 ta->context))) 195 if ((ipc_phone_0) && 196 (context_check(ipc_phone_0->task->context, ta->context))) 182 197 ipc_phone_connect(&ta->phones[0], ipc_phone_0); 183 atomic_set(&ta->active_calls, 0); 184 list_initialize(&ta->sync_box_head); 185 186 mutex_initialize(&ta->futexes_lock, MUTEX_PASSIVE); 198 187 199 btree_create(&ta->futexes); 188 200 189 201 ipl = interrupts_disable(); 190 191 /*192 * Increment address space reference count.193 */194 202 atomic_inc(&as->refcount); 195 196 203 spinlock_lock(&tasks_lock); 197 204 ta->taskid = ++task_counter;
Note:
See TracChangeset
for help on using the changeset viewer.