Changeset 6f4495f5 in mainline for kernel/generic/src/proc/task.c
- Timestamp:
- 2007-01-27T17:32:13Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1ba41c5
- Parents:
- 51baa8a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/proc/task.c
r51baa8a r6f4495f5 66 66 /** B+tree of active tasks. 67 67 * 68 * The task is guaranteed to exist after it was found in the tasks_btree as long as: 68 * The task is guaranteed to exist after it was found in the tasks_btree as 69 * long as: 69 70 * @li the tasks_lock is held, 70 * @li the task's lock is held when task's lock is acquired before releasing tasks_lock or 71 * @li the task's lock is held when task's lock is acquired before releasing 72 * tasks_lock or 71 73 * @li the task's refcount is greater than 0 72 74 * … … 126 128 for (i = 0; i < IPC_MAX_PHONES; i++) 127 129 ipc_phone_init(&ta->phones[i]); 128 if ((ipc_phone_0) && (context_check(ipc_phone_0->task->context, ta->context))) 130 if ((ipc_phone_0) && (context_check(ipc_phone_0->task->context, 131 ta->context))) 129 132 ipc_phone_connect(&ta->phones[0], ipc_phone_0); 130 133 atomic_set(&ta->active_calls, 0); … … 203 206 204 207 kernel_uarg = (uspace_arg_t *) malloc(sizeof(uspace_arg_t), 0); 205 kernel_uarg->uspace_entry = (void *) ((elf_header_t *) program_addr)->e_entry; 208 kernel_uarg->uspace_entry = 209 (void *) ((elf_header_t *) program_addr)->e_entry; 206 210 kernel_uarg->uspace_stack = (void *) USTACK_ADDRESS; 207 211 kernel_uarg->uspace_thread_function = NULL; … … 215 219 * Create the data as_area. 216 220 */ 217 a = as_area_create(as, AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE, 218 LOADED_PROG_STACK_PAGES_NO*PAGE_SIZE,219 USTACK_ADDRESS,AS_AREA_ATTR_NONE, &anon_backend, NULL);221 a = as_area_create(as, AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE, 222 LOADED_PROG_STACK_PAGES_NO * PAGE_SIZE, USTACK_ADDRESS, 223 AS_AREA_ATTR_NONE, &anon_backend, NULL); 220 224 221 225 /* 222 226 * Create the main thread. 223 227 */ 224 t1 = thread_create(uinit, kernel_uarg, task, THREAD_FLAG_USPACE, "uinit", false); 228 t1 = thread_create(uinit, kernel_uarg, task, THREAD_FLAG_USPACE, 229 "uinit", false); 225 230 ASSERT(t1); 226 231 … … 239 244 /** Syscall for reading task ID from userspace. 240 245 * 241 * @param uspace_task_id Userspace address of 8-byte buffer where to store current task ID. 246 * @param uspace_task_id Userspace address of 8-byte buffer where to store 247 * current task ID. 242 248 * 243 249 * @return 0 on success or an error code from @ref errno.h. … … 249 255 * remains constant for the lifespan of the task. 250 256 */ 251 return (unative_t) copy_to_uspace(uspace_task_id, &TASK->taskid, sizeof(TASK->taskid)); 257 return (unative_t) copy_to_uspace(uspace_task_id, &TASK->taskid, 258 sizeof(TASK->taskid)); 252 259 } 253 260 … … 289 296 /* Process only counted threads */ 290 297 if (!thr->uncounted) { 291 if (thr == THREAD) /* Update accounting of current thread */ 292 thread_update_accounting(); 298 if (thr == THREAD) { 299 /* Update accounting of current thread */ 300 thread_update_accounting(); 301 } 293 302 ret += thr->cycles; 294 303 } … … 377 386 spinlock_lock(&tasks_lock); 378 387 379 printf("taskid name ctx address as cycles threads calls callee\n"); 380 printf("------ ---------- --- ---------- ---------- ---------- ------- ------ ------>\n"); 381 382 for (cur = tasks_btree.leaf_head.next; cur != &tasks_btree.leaf_head; cur = cur->next) { 388 printf("taskid name ctx address as cycles threads " 389 "calls callee\n"); 390 printf("------ ---------- --- ---------- ---------- ---------- ------- " "------ ------>\n"); 391 392 for (cur = tasks_btree.leaf_head.next; cur != &tasks_btree.leaf_head; 393 cur = cur->next) { 383 394 btree_node_t *node; 384 395 int i; … … 397 408 order(task_get_accounting(t), &cycles, &suffix); 398 409 399 printf("%-6lld %-10s %-3ld %#10zx %#10zx %9llu%c %7zd %6zd", t->taskid, t->name, t->context, t, t->as, cycles, suffix, t->refcount, atomic_get(&t->active_calls)); 410 printf("%-6lld %-10s %-3ld %#10zx %#10zx %9llu%c %7zd " 411 "%6zd", t->taskid, t->name, t->context, t, t->as, 412 cycles, suffix, t->refcount, 413 atomic_get(&t->active_calls)); 400 414 for (j = 0; j < IPC_MAX_PHONES; j++) { 401 415 if (t->phones[j].callee) 402 printf(" %zd:%#zx", j, t->phones[j].callee); 416 printf(" %zd:%#zx", j, 417 t->phones[j].callee); 403 418 } 404 419 printf("\n"); … … 466 481 467 482 if (t != THREAD) { 468 ASSERT(t != main_thread); /* uninit is joined and detached in ktaskgc */ 483 ASSERT(t != main_thread); /* uninit is joined and detached 484 * in ktaskgc */ 469 485 thread_join(t); 470 486 thread_detach(t); 471 goto loop; /* go for another thread */487 goto loop; /* go for another thread */ 472 488 } 473 489 … … 498 514 * therefore the thread pointer is guaranteed to be valid. 499 515 */ 500 if (thread_join_timeout(t, 1000000, SYNCH_FLAGS_NONE) == ESYNCH_TIMEOUT) { /* sleep uninterruptibly here! */ 516 if (thread_join_timeout(t, 1000000, SYNCH_FLAGS_NONE) == 517 ESYNCH_TIMEOUT) { /* sleep uninterruptibly here! */ 501 518 ipl_t ipl; 502 519 link_t *cur; … … 504 521 505 522 /* 506 * The join timed out. Try to do some garbage collection of Undead threads. 523 * The join timed out. Try to do some garbage collection of 524 * Undead threads. 507 525 */ 508 526 more_gc: … … 510 528 spinlock_lock(&TASK->lock); 511 529 512 for (cur = TASK->th_head.next; cur != &TASK->th_head; cur = cur->next) { 530 for (cur = TASK->th_head.next; cur != &TASK->th_head; 531 cur = cur->next) { 513 532 thr = list_get_instance(cur, thread_t, th_link); 514 533 spinlock_lock(&thr->lock); 515 if (thr != t && thr->state == Undead && thr->join_type == None) { 534 if (thr != t && thr->state == Undead && 535 thr->join_type == None) { 516 536 thr->join_type = TaskGC; 517 537 spinlock_unlock(&thr->lock);
Note:
See TracChangeset
for help on using the changeset viewer.