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

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

Turn IRQ structures into kernel objects

ipc_irq_subscribe() now returns a capability for the underlying IRQ kernel
object. ipc_irq_unsubscribe() can now be done only with a valid IRQ capability.

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