source: mainline/kernel/generic/src/proc/task.c@ df64dbc

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since df64dbc was 2f2beb4, checked in by Jakub Jermar <jakub@…>, 12 years ago

Release the first task in task_done() so that the machine can be rebooted.

  • Property mode set to 100644
File size: 15.1 KB
RevLine 
[f761f1eb]1/*
[278b4a30]2 * Copyright (c) 2010 Jakub Jermar
[f761f1eb]3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
[cc73a8a1]29/** @addtogroup genericproc
[b45c443]30 * @{
31 */
32
[9179d0a]33/**
[b45c443]34 * @file
[5ba201d]35 * @brief Task management.
[9179d0a]36 */
37
[f761f1eb]38#include <proc/thread.h>
39#include <proc/task.h>
[20d50a1]40#include <mm/as.h>
[085d973]41#include <mm/slab.h>
[31d8e10]42#include <atomic.h>
[f761f1eb]43#include <synch/spinlock.h>
[5573942]44#include <synch/waitq.h>
[f761f1eb]45#include <arch.h>
[8605b24]46#include <arch/barrier.h>
[b76a2217]47#include <adt/avl.h>
[7f6e755]48#include <adt/btree.h>
[5c9a08b]49#include <adt/list.h>
[6d9c49a]50#include <ipc/ipc.h>
[c98e6ee]51#include <ipc/ipcrsc.h>
[5d0500c]52#include <ipc/event.h>
[37c57f2]53#include <print.h>
[7509ddc]54#include <errno.h>
[95155b0c]55#include <func.h>
[19f857a]56#include <str.h>
[41df2827]57#include <memstr.h>
[e3c762cd]58#include <syscall/copy.h>
[95ad426]59#include <macros.h>
[8e5e78f]60
[b76a2217]61/** Spinlock protecting the tasks_tree AVL tree. */
[da1bafb]62IRQ_SPINLOCK_INITIALIZE(tasks_lock);
[88169d9]63
[b76a2217]64/** AVL tree of active tasks.
[88169d9]65 *
[b76a2217]66 * The task is guaranteed to exist after it was found in the tasks_tree as
[6f4495f5]67 * long as:
[5ba201d]68 *
[88169d9]69 * @li the tasks_lock is held,
[6f4495f5]70 * @li the task's lock is held when task's lock is acquired before releasing
71 * tasks_lock or
[7bb6b06]72 * @li the task's refcount is greater than 0
[88169d9]73 *
74 */
[b76a2217]75avltree_t tasks_tree;
[88169d9]76
[286e03d]77static task_id_t task_counter = 0;
[70527f1]78
[103de761]79static slab_cache_t *task_slab;
80
[121966e]81/* Forward declarations. */
82static void task_kill_internal(task_t *);
[da1bafb]83static int tsk_constructor(void *, unsigned int);
[121966e]84
[da1bafb]85/** Initialize kernel tasks support.
86 *
87 */
[f761f1eb]88void task_init(void)
89{
[43114c5]90 TASK = NULL;
[b76a2217]91 avltree_create(&tasks_tree);
[f97f1e51]92 task_slab = slab_cache_create("task_t", sizeof(task_t), 0,
[59ee56f]93 tsk_constructor, NULL, 0);
[b76a2217]94}
95
[da1bafb]96/** Task finish walker.
97 *
[121966e]98 * The idea behind this walker is to kill and count all tasks different from
[814c4f5]99 * TASK.
[da1bafb]100 *
[b76a2217]101 */
102static bool task_done_walker(avltree_node_t *node, void *arg)
103{
[da1bafb]104 task_t *task = avltree_get_instance(node, task_t, tasks_tree_node);
105 size_t *cnt = (size_t *) arg;
[5ba201d]106
[da1bafb]107 if (task != TASK) {
[121966e]108 (*cnt)++;
[da1bafb]109
[121966e]110#ifdef CONFIG_DEBUG
[da1bafb]111 printf("[%"PRIu64"] ", task->taskid);
[121966e]112#endif
[da1bafb]113
114 task_kill_internal(task);
[b76a2217]115 }
[5ba201d]116
117 /* Continue the walk */
118 return true;
[f761f1eb]119}
120
[da1bafb]121/** Kill all tasks except the current task.
122 *
123 */
[f74bbaf]124void task_done(void)
125{
[da1bafb]126 size_t tasks_left;
[2f2beb4]127
128 if (ipc_phone_0) {
129 task_t *task_0 = ipc_phone_0->task;
130 ipc_phone_0 = NULL;
131 /*
132 * The first task is held by kinit(), we need to release it or
133 * it will never finish cleanup.
134 */
135 task_release(task_0);
136 }
[5ba201d]137
[da1bafb]138 /* Repeat until there are any tasks except TASK */
139 do {
[121966e]140#ifdef CONFIG_DEBUG
141 printf("Killing tasks... ");
142#endif
[da1bafb]143
144 irq_spinlock_lock(&tasks_lock, true);
[121966e]145 tasks_left = 0;
146 avltree_walk(&tasks_tree, task_done_walker, &tasks_left);
[da1bafb]147 irq_spinlock_unlock(&tasks_lock, true);
148
[121966e]149 thread_sleep(1);
[da1bafb]150
[f74bbaf]151#ifdef CONFIG_DEBUG
[121966e]152 printf("\n");
153#endif
[da1bafb]154 } while (tasks_left > 0);
[f74bbaf]155}
[70527f1]156
[da1bafb]157int tsk_constructor(void *obj, unsigned int kmflags)
[59ee56f]158{
[da1bafb]159 task_t *task = (task_t *) obj;
160
161 atomic_set(&task->refcount, 0);
162 atomic_set(&task->lifecount, 0);
[5ba201d]163
[da1bafb]164 irq_spinlock_initialize(&task->lock, "task_t_lock");
165 mutex_initialize(&task->futexes_lock, MUTEX_PASSIVE);
[5ba201d]166
[55b77d9]167 list_initialize(&task->threads);
[5ba201d]168
[da1bafb]169 ipc_answerbox_init(&task->answerbox, task);
[5ba201d]170
[da1bafb]171 size_t i;
[59ee56f]172 for (i = 0; i < IPC_MAX_PHONES; i++)
[03a8a8e]173 ipc_phone_init(&task->phones[i], task);
[86939b1]174
175 spinlock_initialize(&task->active_calls_lock, "active_calls_lock");
176 list_initialize(&task->active_calls);
[5ba201d]177
[59ee56f]178#ifdef CONFIG_UDEBUG
179 /* Init kbox stuff */
[da1bafb]180 task->kb.thread = NULL;
181 ipc_answerbox_init(&task->kb.box, task);
182 mutex_initialize(&task->kb.cleanup_lock, MUTEX_PASSIVE);
[59ee56f]183#endif
[5ba201d]184
[59ee56f]185 return 0;
186}
187
[814c4f5]188/** Create new task with no threads.
[70527f1]189 *
[5ba201d]190 * @param as Task's address space.
191 * @param name Symbolic name (a copy is made).
[70527f1]192 *
[5ba201d]193 * @return New task's structure.
[70527f1]194 *
195 */
[a000878c]196task_t *task_create(as_t *as, const char *name)
[f761f1eb]197{
[da1bafb]198 task_t *task = (task_t *) slab_alloc(task_slab, 0);
199 task_create_arch(task);
200
201 task->as = as;
202 str_cpy(task->name, TASK_NAME_BUFLEN, name);
203
[473d5d2]204 task->container = CONTAINER;
[da1bafb]205 task->capabilities = 0;
206 task->ucycles = 0;
207 task->kcycles = 0;
[7ad17de]208
[da1bafb]209 task->ipc_info.call_sent = 0;
[be06914]210 task->ipc_info.call_received = 0;
[da1bafb]211 task->ipc_info.answer_sent = 0;
[be06914]212 task->ipc_info.answer_received = 0;
213 task->ipc_info.irq_notif_received = 0;
[da1bafb]214 task->ipc_info.forwarded = 0;
[5d0500c]215
216 event_task_init(task);
[da1bafb]217
[c33f39f]218 task->answerbox.active = true;
219
[9a1b20c]220#ifdef CONFIG_UDEBUG
221 /* Init debugging stuff */
[da1bafb]222 udebug_task_init(&task->udebug);
[5ba201d]223
[9a1b20c]224 /* Init kbox stuff */
[c33f39f]225 task->kb.box.active = true;
[da1bafb]226 task->kb.finished = false;
[9a1b20c]227#endif
[5ba201d]228
[59ee56f]229 if ((ipc_phone_0) &&
[473d5d2]230 (container_check(ipc_phone_0->task->container, task->container)))
[c33f39f]231 (void) ipc_phone_connect(&task->phones[0], ipc_phone_0);
[5ba201d]232
[da1bafb]233 btree_create(&task->futexes);
[bb68433]234
[6193351]235 /*
236 * Get a reference to the address space.
237 */
[da1bafb]238 as_hold(task->as);
239
240 irq_spinlock_lock(&tasks_lock, true);
241
242 task->taskid = ++task_counter;
243 avltree_node_initialize(&task->tasks_tree_node);
244 task->tasks_tree_node.key = task->taskid;
245 avltree_insert(&tasks_tree, &task->tasks_tree_node);
246
247 irq_spinlock_unlock(&tasks_lock, true);
248
249 return task;
[f761f1eb]250}
251
[7509ddc]252/** Destroy task.
253 *
[da1bafb]254 * @param task Task to be destroyed.
[5ba201d]255 *
[7509ddc]256 */
[da1bafb]257void task_destroy(task_t *task)
[7509ddc]258{
[ea7890e7]259 /*
260 * Remove the task from the task B+tree.
261 */
[da1bafb]262 irq_spinlock_lock(&tasks_lock, true);
263 avltree_delete(&tasks_tree, &task->tasks_tree_node);
264 irq_spinlock_unlock(&tasks_lock, true);
[5ba201d]265
[ea7890e7]266 /*
267 * Perform architecture specific task destruction.
268 */
[da1bafb]269 task_destroy_arch(task);
[5ba201d]270
[ea7890e7]271 /*
272 * Free up dynamically allocated state.
273 */
[da1bafb]274 btree_destroy(&task->futexes);
[5ba201d]275
[ea7890e7]276 /*
277 * Drop our reference to the address space.
278 */
[da1bafb]279 as_release(task->as);
[31e8ddd]280
[da1bafb]281 slab_free(task_slab, task);
[7509ddc]282}
283
[278b4a30]284/** Hold a reference to a task.
285 *
286 * Holding a reference to a task prevents destruction of that task.
287 *
[da1bafb]288 * @param task Task to be held.
289 *
[278b4a30]290 */
[da1bafb]291void task_hold(task_t *task)
[278b4a30]292{
[da1bafb]293 atomic_inc(&task->refcount);
[278b4a30]294}
295
296/** Release a reference to a task.
297 *
298 * The last one to release a reference to a task destroys the task.
299 *
[da1bafb]300 * @param task Task to be released.
301 *
[278b4a30]302 */
[da1bafb]303void task_release(task_t *task)
[278b4a30]304{
[da1bafb]305 if ((atomic_predec(&task->refcount)) == 0)
306 task_destroy(task);
[278b4a30]307}
308
[dd8d5a7]309#ifdef __32_BITS__
310
311/** Syscall for reading task ID from userspace (32 bits)
[ec55358]312 *
[dd8d5a7]313 * @param uspace_taskid Pointer to user-space buffer
314 * where to store current task ID.
[5ba201d]315 *
316 * @return Zero on success or an error code from @ref errno.h.
[ec55358]317 *
318 */
[dd8d5a7]319sysarg_t sys_task_get_id(sysarg64_t *uspace_taskid)
[ec55358]320{
321 /*
[814c4f5]322 * No need to acquire lock on TASK because taskid remains constant for
323 * the lifespan of the task.
[ec55358]324 */
[dd8d5a7]325 return (sysarg_t) copy_to_uspace(uspace_taskid, &TASK->taskid,
[6f4495f5]326 sizeof(TASK->taskid));
[ec55358]327}
328
[dd8d5a7]329#endif /* __32_BITS__ */
330
331#ifdef __64_BITS__
332
333/** Syscall for reading task ID from userspace (64 bits)
334 *
335 * @return Current task ID.
336 *
337 */
338sysarg_t sys_task_get_id(void)
339{
340 /*
341 * No need to acquire lock on TASK because taskid remains constant for
342 * the lifespan of the task.
343 */
344 return TASK->taskid;
345}
346
347#endif /* __64_BITS__ */
348
[bc18d63]349/** Syscall for setting the task name.
350 *
351 * The name simplifies identifying the task in the task list.
352 *
[5ba201d]353 * @param name The new name for the task. (typically the same
354 * as the command used to execute it).
[bc18d63]355 *
356 * @return 0 on success or an error code from @ref errno.h.
[5ba201d]357 *
[bc18d63]358 */
[96b02eb9]359sysarg_t sys_task_set_name(const char *uspace_name, size_t name_len)
[bc18d63]360{
361 char namebuf[TASK_NAME_BUFLEN];
[5ba201d]362
[bc18d63]363 /* Cap length of name and copy it from userspace. */
364 if (name_len > TASK_NAME_BUFLEN - 1)
365 name_len = TASK_NAME_BUFLEN - 1;
[5ba201d]366
[577f042a]367 int rc = copy_from_uspace(namebuf, uspace_name, name_len);
[bc18d63]368 if (rc != 0)
[96b02eb9]369 return (sysarg_t) rc;
[5ba201d]370
[f4b1535]371 namebuf[name_len] = '\0';
[577f042a]372
373 /*
374 * As the task name is referenced also from the
375 * threads, lock the threads' lock for the course
376 * of the update.
377 */
378
379 irq_spinlock_lock(&tasks_lock, true);
380 irq_spinlock_lock(&TASK->lock, false);
381 irq_spinlock_lock(&threads_lock, false);
382
383 /* Set task name */
[f4b1535]384 str_cpy(TASK->name, TASK_NAME_BUFLEN, namebuf);
[5ba201d]385
[577f042a]386 irq_spinlock_unlock(&threads_lock, false);
387 irq_spinlock_unlock(&TASK->lock, false);
388 irq_spinlock_unlock(&tasks_lock, true);
389
[bc18d63]390 return EOK;
391}
392
[1e9f8ab]393/** Syscall to forcefully terminate a task
394 *
395 * @param uspace_taskid Pointer to task ID in user space.
396 *
397 * @return 0 on success or an error code from @ref errno.h.
398 *
399 */
400sysarg_t sys_task_kill(task_id_t *uspace_taskid)
401{
402 task_id_t taskid;
[5bcf1f9]403 int rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(taskid));
[1e9f8ab]404 if (rc != 0)
405 return (sysarg_t) rc;
[5bcf1f9]406
[1e9f8ab]407 return (sysarg_t) task_kill(taskid);
408}
409
[9a8d91b]410/** Find task structure corresponding to task ID.
411 *
[814c4f5]412 * The tasks_lock must be already held by the caller of this function and
413 * interrupts must be disabled.
[9a8d91b]414 *
[5ba201d]415 * @param id Task ID.
416 *
[e1b6742]417 * @return Task structure address or NULL if there is no such task ID.
[9a8d91b]418 *
419 */
[5ba201d]420task_t *task_find_by_id(task_id_t id)
421{
[1d432f9]422 ASSERT(interrupts_disabled());
423 ASSERT(irq_spinlock_locked(&tasks_lock));
424
[e1b6742]425 avltree_node_t *node =
426 avltree_search(&tasks_tree, (avltree_key_t) id);
[5ba201d]427
[b76a2217]428 if (node)
[da1bafb]429 return avltree_get_instance(node, task_t, tasks_tree_node);
[5ba201d]430
[b76a2217]431 return NULL;
[9a8d91b]432}
433
[0313ff0]434/** Get accounting data of given task.
435 *
[1d432f9]436 * Note that task lock of 'task' must be already held and interrupts must be
[814c4f5]437 * already disabled.
[0313ff0]438 *
[da1bafb]439 * @param task Pointer to the task.
[88dea9d]440 * @param ucycles Out pointer to sum of all user cycles.
441 * @param kcycles Out pointer to sum of all kernel cycles.
[0313ff0]442 *
443 */
[da1bafb]444void task_get_accounting(task_t *task, uint64_t *ucycles, uint64_t *kcycles)
[0313ff0]445{
[1d432f9]446 ASSERT(interrupts_disabled());
447 ASSERT(irq_spinlock_locked(&task->lock));
448
[a2a00e8]449 /* Accumulated values of task */
[da1bafb]450 uint64_t uret = task->ucycles;
451 uint64_t kret = task->kcycles;
[0313ff0]452
453 /* Current values of threads */
[55b77d9]454 list_foreach(task->threads, cur) {
[da1bafb]455 thread_t *thread = list_get_instance(cur, thread_t, th_link);
456
457 irq_spinlock_lock(&thread->lock, false);
[0313ff0]458
[62b6d17]459 /* Process only counted threads */
[da1bafb]460 if (!thread->uncounted) {
461 if (thread == THREAD) {
[6f4495f5]462 /* Update accounting of current thread */
[a2a00e8]463 thread_update_accounting(false);
[da1bafb]464 }
465
466 uret += thread->ucycles;
467 kret += thread->kcycles;
[62b6d17]468 }
[da1bafb]469
470 irq_spinlock_unlock(&thread->lock, false);
[0313ff0]471 }
472
[a2a00e8]473 *ucycles = uret;
474 *kcycles = kret;
[0313ff0]475}
476
[da1bafb]477static void task_kill_internal(task_t *task)
[121966e]478{
[df58e44]479 irq_spinlock_lock(&task->lock, false);
480 irq_spinlock_lock(&threads_lock, false);
[5ba201d]481
[121966e]482 /*
483 * Interrupt all threads.
484 */
[df58e44]485
[55b77d9]486 list_foreach(task->threads, cur) {
[da1bafb]487 thread_t *thread = list_get_instance(cur, thread_t, th_link);
[121966e]488 bool sleeping = false;
489
[da1bafb]490 irq_spinlock_lock(&thread->lock, false);
[121966e]491
[da1bafb]492 thread->interrupted = true;
493 if (thread->state == Sleeping)
[121966e]494 sleeping = true;
[da1bafb]495
496 irq_spinlock_unlock(&thread->lock, false);
[121966e]497
498 if (sleeping)
[da1bafb]499 waitq_interrupt_sleep(thread);
[121966e]500 }
[da1bafb]501
[df58e44]502 irq_spinlock_unlock(&threads_lock, false);
[da1bafb]503 irq_spinlock_unlock(&task->lock, false);
[121966e]504}
505
[7509ddc]506/** Kill task.
[ea7890e7]507 *
508 * This function is idempotent.
509 * It signals all the task's threads to bail it out.
[7509ddc]510 *
[5ba201d]511 * @param id ID of the task to be killed.
512 *
513 * @return Zero on success or an error code from errno.h.
[7509ddc]514 *
515 */
516int task_kill(task_id_t id)
517{
[9b6aae6]518 if (id == 1)
519 return EPERM;
[7509ddc]520
[da1bafb]521 irq_spinlock_lock(&tasks_lock, true);
522
523 task_t *task = task_find_by_id(id);
524 if (!task) {
525 irq_spinlock_unlock(&tasks_lock, true);
[7509ddc]526 return ENOENT;
527 }
[da1bafb]528
529 task_kill_internal(task);
530 irq_spinlock_unlock(&tasks_lock, true);
531
532 return EOK;
[7509ddc]533}
534
[5bcf1f9]535/** Kill the currently running task.
536 *
537 * @param notify Send out fault notifications.
538 *
539 * @return Zero on success or an error code from errno.h.
540 *
541 */
542void task_kill_self(bool notify)
543{
544 /*
545 * User space can subscribe for FAULT events to take action
546 * whenever a task faults (to take a dump, run a debugger, etc.).
547 * The notification is always available, but unless udebug is enabled,
548 * that's all you get.
549 */
550 if (notify) {
[f9061b4]551 /* Notify the subscriber that a fault occurred. */
552 if (event_notify_3(EVENT_FAULT, false, LOWER32(TASK->taskid),
553 UPPER32(TASK->taskid), (sysarg_t) THREAD) == EOK) {
[5bcf1f9]554#ifdef CONFIG_UDEBUG
555 /* Wait for a debugging session. */
556 udebug_thread_fault();
557#endif
558 }
559 }
560
561 irq_spinlock_lock(&tasks_lock, true);
562 task_kill_internal(TASK);
563 irq_spinlock_unlock(&tasks_lock, true);
564
565 thread_exit();
566}
567
568/** Process syscall to terminate the current task.
569 *
570 * @param notify Send out fault notifications.
571 *
572 */
573sysarg_t sys_task_exit(sysarg_t notify)
574{
575 task_kill_self(notify);
576
577 /* Unreachable */
578 return EOK;
579}
580
[b76a2217]581static bool task_print_walker(avltree_node_t *node, void *arg)
582{
[c0f13d2]583 bool *additional = (bool *) arg;
[da1bafb]584 task_t *task = avltree_get_instance(node, task_t, tasks_tree_node);
585 irq_spinlock_lock(&task->lock, false);
[5ba201d]586
[a2a00e8]587 uint64_t ucycles;
588 uint64_t kcycles;
[1ba37fa]589 char usuffix, ksuffix;
[da1bafb]590 task_get_accounting(task, &ucycles, &kcycles);
[e535eeb]591 order_suffix(ucycles, &ucycles, &usuffix);
592 order_suffix(kcycles, &kcycles, &ksuffix);
[88dea9d]593
[da1bafb]594#ifdef __32_BITS__
[c0f13d2]595 if (*additional)
[97d17fe]596 printf("%-8" PRIu64 " %9" PRIua, task->taskid,
597 atomic_get(&task->refcount));
[c0f13d2]598 else
599 printf("%-8" PRIu64 " %-14s %-5" PRIu32 " %10p %10p"
600 " %9" PRIu64 "%c %9" PRIu64 "%c\n", task->taskid,
[473d5d2]601 task->name, task->container, task, task->as,
[c0f13d2]602 ucycles, usuffix, kcycles, ksuffix);
[52755f1]603#endif
[5ba201d]604
[52755f1]605#ifdef __64_BITS__
[c0f13d2]606 if (*additional)
[7e752b2]607 printf("%-8" PRIu64 " %9" PRIu64 "%c %9" PRIu64 "%c "
[97d17fe]608 "%9" PRIua, task->taskid, ucycles, usuffix, kcycles,
609 ksuffix, atomic_get(&task->refcount));
[c0f13d2]610 else
611 printf("%-8" PRIu64 " %-14s %-5" PRIu32 " %18p %18p\n",
[473d5d2]612 task->taskid, task->name, task->container, task, task->as);
[52755f1]613#endif
[5ba201d]614
[c0f13d2]615 if (*additional) {
616 size_t i;
617 for (i = 0; i < IPC_MAX_PHONES; i++) {
618 if (task->phones[i].callee)
[7e752b2]619 printf(" %zu:%p", i, task->phones[i].callee);
[c0f13d2]620 }
621 printf("\n");
[b76a2217]622 }
[5ba201d]623
[da1bafb]624 irq_spinlock_unlock(&task->lock, false);
[b76a2217]625 return true;
626}
627
[c0f13d2]628/** Print task list
629 *
630 * @param additional Print additional information.
631 *
632 */
633void task_print_list(bool additional)
[37c57f2]634{
[f74bbaf]635 /* Messing with task structures, avoid deadlock */
[da1bafb]636 irq_spinlock_lock(&tasks_lock, true);
[5ba201d]637
638#ifdef __32_BITS__
[c0f13d2]639 if (additional)
[48dcc69]640 printf("[id ] [threads] [calls] [callee\n");
[c0f13d2]641 else
[473d5d2]642 printf("[id ] [name ] [ctn] [address ] [as ]"
[c0f13d2]643 " [ucycles ] [kcycles ]\n");
[52755f1]644#endif
[5ba201d]645
[52755f1]646#ifdef __64_BITS__
[c0f13d2]647 if (additional)
[be06914]648 printf("[id ] [ucycles ] [kcycles ] [threads] [calls]"
[c0f13d2]649 " [callee\n");
650 else
[473d5d2]651 printf("[id ] [name ] [ctn] [address ]"
[c0f13d2]652 " [as ]\n");
[52755f1]653#endif
[5ba201d]654
[c0f13d2]655 avltree_walk(&tasks_tree, task_print_walker, &additional);
[5ba201d]656
[da1bafb]657 irq_spinlock_unlock(&tasks_lock, true);
[37c57f2]658}
[7509ddc]659
[cc73a8a1]660/** @}
[b45c443]661 */
Note: See TracBrowser for help on using the repository browser.