Rev 2035 | Rev 2040 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 2035 | Rev 2039 | ||
|---|---|---|---|
| Line 117... | Line 117... | ||
| 117 | ta->refcount = 0; |
117 | ta->refcount = 0; |
| 118 | ta->context = CONTEXT; |
118 | ta->context = CONTEXT; |
| 119 | 119 | ||
| 120 | ta->capabilities = 0; |
120 | ta->capabilities = 0; |
| 121 | ta->accept_new_threads = true; |
121 | ta->accept_new_threads = true; |
| - | 122 | ta->cycles = 0; |
|
| 122 | 123 | ||
| 123 | ipc_answerbox_init(&ta->answerbox); |
124 | ipc_answerbox_init(&ta->answerbox); |
| 124 | for (i = 0; i < IPC_MAX_PHONES; i++) |
125 | for (i = 0; i < IPC_MAX_PHONES; i++) |
| 125 | ipc_phone_init(&ta->phones[i]); |
126 | ipc_phone_init(&ta->phones[i]); |
| 126 | if ((ipc_phone_0) && (context_check(ipc_phone_0->task->context, ta->context))) |
127 | if ((ipc_phone_0) && (context_check(ipc_phone_0->task->context, ta->context))) |
| Line 264... | Line 265... | ||
| 264 | btree_node_t *leaf; |
265 | btree_node_t *leaf; |
| 265 | 266 | ||
| 266 | return (task_t *) btree_search(&tasks_btree, (btree_key_t) id, &leaf); |
267 | return (task_t *) btree_search(&tasks_btree, (btree_key_t) id, &leaf); |
| 267 | } |
268 | } |
| 268 | 269 | ||
| - | 270 | /** Get accounting data of given task. |
|
| - | 271 | * |
|
| - | 272 | * Note that task_lock on @t must be already held and |
|
| - | 273 | * interrupts must be already disabled. |
|
| - | 274 | * |
|
| - | 275 | * @param t Pointer to thread. |
|
| - | 276 | * |
|
| - | 277 | */ |
|
| - | 278 | uint64_t task_get_accounting(task_t *t) |
|
| - | 279 | { |
|
| - | 280 | /* Accumulated value of task */ |
|
| - | 281 | uint64_t ret = t->cycles; |
|
| - | 282 | ||
| - | 283 | /* Current values of threads */ |
|
| - | 284 | link_t *cur; |
|
| - | 285 | for (cur = t->th_head.next; cur != &t->th_head; cur = cur->next) { |
|
| - | 286 | thread_t *thr = list_get_instance(cur, thread_t, th_link); |
|
| - | 287 | ||
| - | 288 | spinlock_lock(&thr->lock); |
|
| - | 289 | ||
| - | 290 | if (thr == THREAD) /* Update accounting of current thread */ |
|
| - | 291 | thread_update_accounting(); |
|
| - | 292 | ret += thr->cycles; |
|
| - | 293 | ||
| - | 294 | spinlock_unlock(&thr->lock); |
|
| - | 295 | } |
|
| - | 296 | ||
| - | 297 | return ret; |
|
| - | 298 | } |
|
| - | 299 | ||
| 269 | /** Kill task. |
300 | /** Kill task. |
| 270 | * |
301 | * |
| 271 | * @param id ID of the task to be killed. |
302 | * @param id ID of the task to be killed. |
| 272 | * |
303 | * |
| 273 | * @return 0 on success or an error code from errno.h |
304 | * @return 0 on success or an error code from errno.h |
| Line 342... | Line 373... | ||
| 342 | 373 | ||
| 343 | /* Messing with thread structures, avoid deadlock */ |
374 | /* Messing with thread structures, avoid deadlock */ |
| 344 | ipl = interrupts_disable(); |
375 | ipl = interrupts_disable(); |
| 345 | spinlock_lock(&tasks_lock); |
376 | spinlock_lock(&tasks_lock); |
| 346 | 377 | ||
| 347 | printf("taskid name ctx address as active calls callee\n"); |
378 | printf("taskid name ctx address as cycles threads calls callee\n"); |
| 348 | printf("------ ---------- --- ---------- ---------- ------------ ------>\n"); |
379 | printf("------ ---------- --- ---------- ---------- ---------- ------- ------ ------>\n"); |
| 349 | 380 | ||
| 350 | for (cur = tasks_btree.leaf_head.next; cur != &tasks_btree.leaf_head; cur = cur->next) { |
381 | for (cur = tasks_btree.leaf_head.next; cur != &tasks_btree.leaf_head; cur = cur->next) { |
| 351 | btree_node_t *node; |
382 | btree_node_t *node; |
| 352 | int i; |
383 | int i; |
| 353 | 384 | ||
| Line 357... | Line 388... | ||
| 357 | int j; |
388 | int j; |
| 358 | 389 | ||
| 359 | t = (task_t *) node->value[i]; |
390 | t = (task_t *) node->value[i]; |
| 360 | 391 | ||
| 361 | spinlock_lock(&t->lock); |
392 | spinlock_lock(&t->lock); |
| - | 393 | ||
| - | 394 | uint64_t cycles = task_get_accounting(t); |
|
| - | 395 | char suffix; |
|
| - | 396 | ||
| - | 397 | if (cycles > 1000000000000000000LL) { |
|
| - | 398 | cycles = cycles / 1000000000000000000LL; |
|
| - | 399 | suffix = 'E'; |
|
| - | 400 | } else if (cycles > 1000000000000LL) { |
|
| - | 401 | cycles = cycles / 1000000000000LL; |
|
| - | 402 | suffix = 'T'; |
|
| - | 403 | } else if (cycles > 1000000LL) { |
|
| - | 404 | cycles = cycles / 1000000LL; |
|
| - | 405 | suffix = 'M'; |
|
| - | 406 | } else |
|
| - | 407 | suffix = ' '; |
|
| - | 408 | ||
| 362 | printf("%-6lld %-10s %-3ld %#10zx %#10zx %12zd", t->taskid, t->name, t->context, t, t->as, atomic_get(&t->active_calls)); |
409 | 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)); |
| 363 | for (j = 0; j < IPC_MAX_PHONES; j++) { |
410 | for (j = 0; j < IPC_MAX_PHONES; j++) { |
| 364 | if (t->phones[j].callee) |
411 | if (t->phones[j].callee) |
| 365 | printf(" %zd:%#zx", j, t->phones[j].callee); |
412 | printf(" %zd:%#zx", j, t->phones[j].callee); |
| 366 | } |
413 | } |
| 367 | printf("\n"); |
414 | printf("\n"); |
| - | 415 | ||
| 368 | spinlock_unlock(&t->lock); |
416 | spinlock_unlock(&t->lock); |
| 369 | } |
417 | } |
| 370 | } |
418 | } |
| 371 | 419 | ||
| 372 | spinlock_unlock(&tasks_lock); |
420 | spinlock_unlock(&tasks_lock); |