Changeset 6f4495f5 in mainline for kernel/generic/src/proc
- 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
- Location:
- kernel/generic/src/proc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/proc/scheduler.c
r51baa8a r6f4495f5 361 361 context_save(&CPU->saved_context); 362 362 context_set(&CPU->saved_context, FADDR(scheduler_separated_stack), 363 363 (uintptr_t) CPU->stack, CPU_STACK_SIZE); 364 364 context_restore(&CPU->saved_context); 365 365 /* not reached */ … … 501 501 #ifdef SCHEDULER_VERBOSE 502 502 printf("cpu%d: tid %d (priority=%d, ticks=%lld, nrdy=%ld)\n", 503 504 503 CPU->id, THREAD->tid, THREAD->priority, THREAD->ticks, 504 atomic_get(&CPU->nrdy)); 505 505 #endif 506 506 … … 636 636 #ifdef KCPULB_VERBOSE 637 637 printf("kcpulb%d: TID %d -> cpu%d, nrdy=%ld, " 638 639 640 638 "avg=%nd\n", CPU->id, t->tid, CPU->id, 639 atomic_get(&CPU->nrdy), 640 atomic_get(&nrdy) / config.cpu_active); 641 641 #endif 642 642 t->flags |= THREAD_FLAG_STOLEN; … … 704 704 spinlock_lock(&cpus[cpu].lock); 705 705 printf("cpu%d: address=%p, nrdy=%ld, needs_relink=%ld\n", 706 707 706 cpus[cpu].id, &cpus[cpu], atomic_get(&cpus[cpu].nrdy), 707 cpus[cpu].needs_relink); 708 708 709 709 for (i = 0; i < RQ_COUNT; i++) { … … 719 719 t = list_get_instance(cur, thread_t, rq_link); 720 720 printf("%d(%s) ", t->tid, 721 721 thread_states[t->state]); 722 722 } 723 723 printf("\n"); -
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); -
kernel/generic/src/proc/thread.c
r51baa8a r6f4495f5 205 205 atomic_set(&nrdy,0); 206 206 thread_slab = slab_cache_create("thread_slab", sizeof(thread_t), 0, 207 207 thr_constructor, thr_destructor, 0); 208 208 209 209 #ifdef ARCH_HAS_FPU 210 210 fpu_context_slab = slab_cache_create("fpu_slab", sizeof(fpu_context_t), 211 211 FPU_CONTEXT_ALIGN, NULL, NULL, 0); 212 212 #endif 213 213 … … 329 329 /* Not needed, but good for debugging */ 330 330 memsetb((uintptr_t) t->kstack, THREAD_STACK_SIZE * 1 << STACK_FRAMES, 331 331 0); 332 332 333 333 ipl = interrupts_disable(); … … 339 339 context_save(&t->saved_context); 340 340 context_set(&t->saved_context, FADDR(cushion), (uintptr_t) t->kstack, 341 341 THREAD_STACK_SIZE); 342 342 343 343 the_initialize((the_t *) t->kstack); … … 405 405 spinlock_lock(&threads_lock); 406 406 btree_insert(&threads_btree, (btree_key_t) ((uintptr_t) t), (void *) t, 407 407 NULL); 408 408 spinlock_unlock(&threads_lock); 409 409 … … 561 561 spinlock_lock(&threads_lock); 562 562 563 printf("tid name address state task ctx code stack cycles cpu kstack waitqueue\n"); 564 printf("------ ---------- ---------- -------- ---------- --- ---------- ---------- ---------- ---- ---------- ----------\n"); 565 566 for (cur = threads_btree.leaf_head.next; cur != &threads_btree.leaf_head; cur = cur->next) { 563 printf("tid name address state task ctx code " 564 " stack cycles cpu kstack waitqueue\n"); 565 printf("------ ---------- ---------- -------- ---------- --- --------" 566 "-- ---------- ---------- ---- ---------- ----------\n"); 567 568 for (cur = threads_btree.leaf_head.next; 569 cur != &threads_btree.leaf_head; cur = cur->next) { 567 570 btree_node_t *node; 568 571 int i; … … 578 581 order(t->cycles, &cycles, &suffix); 579 582 580 printf("%-6zd %-10s %#10zx %-8s %#10zx %-3ld %#10zx %#10zx %9llu%c ", t->tid, t->name, t, thread_states[t->state], t->task, t->task->context, t->thread_code, t->kstack, cycles, suffix); 583 printf("%-6zd %-10s %#10zx %-8s %#10zx %-3ld %#10zx " 584 "%#10zx %9llu%c ", t->tid, t->name, t, 585 thread_states[t->state], t->task, t->task->context, 586 t->thread_code, t->kstack, cycles, suffix); 581 587 582 588 if (t->cpu) … … 586 592 587 593 if (t->state == Sleeping) 588 printf(" %#10zx %#10zx", t->kstack, t->sleep_queue); 594 printf(" %#10zx %#10zx", t->kstack, 595 t->sleep_queue); 589 596 590 597 printf("\n"); … … 609 616 btree_node_t *leaf; 610 617 611 return btree_search(&threads_btree, (btree_key_t) ((uintptr_t) t), &leaf) != NULL; 618 return btree_search(&threads_btree, (btree_key_t) ((uintptr_t) t), 619 &leaf) != NULL; 612 620 } 613 621 … … 648 656 } 649 657 650 if ((t = thread_create(uinit, kernel_uarg, TASK, THREAD_FLAG_USPACE, namebuf, false))) { 658 t = thread_create(uinit, kernel_uarg, TASK, THREAD_FLAG_USPACE, namebuf, 659 false); 660 if (t) { 651 661 tid = t->tid; 652 662 thread_ready(t); … … 671 681 /** @} 672 682 */ 683
Note:
See TracChangeset
for help on using the changeset viewer.