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

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

Turn IPC phones into kobjects

  • 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
[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>
[6d9c49a]52#include <ipc/ipc.h>
[c98e6ee]53#include <ipc/ipcrsc.h>
[5d0500c]54#include <ipc/event.h>
[37c57f2]55#include <print.h>
[7509ddc]56#include <errno.h>
[95155b0c]57#include <func.h>
[19f857a]58#include <str.h>
[e3c762cd]59#include <syscall/copy.h>
[95ad426]60#include <macros.h>
[8e5e78f]61
[b76a2217]62/** Spinlock protecting the tasks_tree AVL tree. */
[da1bafb]63IRQ_SPINLOCK_INITIALIZE(tasks_lock);
[88169d9]64
[b76a2217]65/** AVL tree of active tasks.
[88169d9]66 *
[b76a2217]67 * The task is guaranteed to exist after it was found in the tasks_tree as
[6f4495f5]68 * long as:
[5ba201d]69 *
[88169d9]70 * @li the tasks_lock is held,
[6f4495f5]71 * @li the task's lock is held when task's lock is acquired before releasing
72 * tasks_lock or
[7bb6b06]73 * @li the task's refcount is greater than 0
[88169d9]74 *
75 */
[b76a2217]76avltree_t tasks_tree;
[88169d9]77
[286e03d]78static task_id_t task_counter = 0;
[70527f1]79
[103de761]80static slab_cache_t *task_slab;
81
[121966e]82/* Forward declarations. */
83static void task_kill_internal(task_t *);
[da1bafb]84static int tsk_constructor(void *, unsigned int);
[121966e]85
[da1bafb]86/** Initialize kernel tasks support.
87 *
88 */
[f761f1eb]89void task_init(void)
90{
[43114c5]91 TASK = NULL;
[b76a2217]92 avltree_create(&tasks_tree);
[f97f1e51]93 task_slab = slab_cache_create("task_t", sizeof(task_t), 0,
[59ee56f]94 tsk_constructor, NULL, 0);
[b76a2217]95}
96
[da1bafb]97/** Task finish walker.
98 *
[121966e]99 * The idea behind this walker is to kill and count all tasks different from
[814c4f5]100 * TASK.
[da1bafb]101 *
[b76a2217]102 */
103static bool task_done_walker(avltree_node_t *node, void *arg)
104{
[da1bafb]105 task_t *task = avltree_get_instance(node, task_t, tasks_tree_node);
106 size_t *cnt = (size_t *) arg;
[5ba201d]107
[da1bafb]108 if (task != TASK) {
[121966e]109 (*cnt)++;
[da1bafb]110
[121966e]111#ifdef CONFIG_DEBUG
[da1bafb]112 printf("[%"PRIu64"] ", task->taskid);
[121966e]113#endif
[da1bafb]114
115 task_kill_internal(task);
[b76a2217]116 }
[5ba201d]117
118 /* Continue the walk */
119 return true;
[f761f1eb]120}
121
[da1bafb]122/** Kill all tasks except the current task.
123 *
124 */
[f74bbaf]125void task_done(void)
126{
[da1bafb]127 size_t tasks_left;
[2f2beb4]128
129 if (ipc_phone_0) {
130 task_t *task_0 = ipc_phone_0->task;
131 ipc_phone_0 = NULL;
132 /*
133 * The first task is held by kinit(), we need to release it or
134 * it will never finish cleanup.
135 */
136 task_release(task_0);
137 }
[5ba201d]138
[da1bafb]139 /* Repeat until there are any tasks except TASK */
140 do {
[121966e]141#ifdef CONFIG_DEBUG
142 printf("Killing tasks... ");
143#endif
[da1bafb]144
145 irq_spinlock_lock(&tasks_lock, true);
[121966e]146 tasks_left = 0;
147 avltree_walk(&tasks_tree, task_done_walker, &tasks_left);
[da1bafb]148 irq_spinlock_unlock(&tasks_lock, true);
149
[121966e]150 thread_sleep(1);
[da1bafb]151
[f74bbaf]152#ifdef CONFIG_DEBUG
[121966e]153 printf("\n");
154#endif
[da1bafb]155 } while (tasks_left > 0);
[f74bbaf]156}
[70527f1]157
[da1bafb]158int tsk_constructor(void *obj, unsigned int kmflags)
[59ee56f]159{
[da1bafb]160 task_t *task = (task_t *) obj;
161
162 atomic_set(&task->refcount, 0);
163 atomic_set(&task->lifecount, 0);
[5ba201d]164
[da1bafb]165 irq_spinlock_initialize(&task->lock, "task_t_lock");
[5ba201d]166
[55b77d9]167 list_initialize(&task->threads);
[05ffb41]168
169 int cap;
170 for (cap = 0; cap < MAX_KERNEL_OBJECTS; cap++)
171 kobject_init(&task->kobject[cap]);
[5ba201d]172
[da1bafb]173 ipc_answerbox_init(&task->answerbox, task);
[5ba201d]174
[86939b1]175 spinlock_initialize(&task->active_calls_lock, "active_calls_lock");
176 list_initialize(&task->active_calls);
[3ac5086]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;
[719a208]205 task->perms = 0;
[da1bafb]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) &&
[05ffb41]230 (container_check(ipc_phone_0->task->container, task->container))) {
231 int cap = phone_alloc(task);
232 assert(cap == 0);
233 (void) ipc_phone_connect(phone_get(task, 0), ipc_phone_0);
234 }
[5ba201d]235
[669f3d32]236 futex_task_init(task);
[bb68433]237
[6193351]238 /*
239 * Get a reference to the address space.
240 */
[da1bafb]241 as_hold(task->as);
242
243 irq_spinlock_lock(&tasks_lock, true);
244
245 task->taskid = ++task_counter;
246 avltree_node_initialize(&task->tasks_tree_node);
247 task->tasks_tree_node.key = task->taskid;
248 avltree_insert(&tasks_tree, &task->tasks_tree_node);
249
250 irq_spinlock_unlock(&tasks_lock, true);
251
252 return task;
[f761f1eb]253}
254
[7509ddc]255/** Destroy task.
256 *
[da1bafb]257 * @param task Task to be destroyed.
[5ba201d]258 *
[7509ddc]259 */
[da1bafb]260void task_destroy(task_t *task)
[7509ddc]261{
[ea7890e7]262 /*
263 * Remove the task from the task B+tree.
264 */
[da1bafb]265 irq_spinlock_lock(&tasks_lock, true);
266 avltree_delete(&tasks_tree, &task->tasks_tree_node);
267 irq_spinlock_unlock(&tasks_lock, true);
[5ba201d]268
[ea7890e7]269 /*
270 * Perform architecture specific task destruction.
271 */
[da1bafb]272 task_destroy_arch(task);
[5ba201d]273
[ea7890e7]274 /*
275 * Free up dynamically allocated state.
276 */
[669f3d32]277 futex_task_deinit(task);
[5ba201d]278
[ea7890e7]279 /*
280 * Drop our reference to the address space.
281 */
[da1bafb]282 as_release(task->as);
[31e8ddd]283
[da1bafb]284 slab_free(task_slab, task);
[7509ddc]285}
286
[278b4a30]287/** Hold a reference to a task.
288 *
289 * Holding a reference to a task prevents destruction of that task.
290 *
[da1bafb]291 * @param task Task to be held.
292 *
[278b4a30]293 */
[da1bafb]294void task_hold(task_t *task)
[278b4a30]295{
[da1bafb]296 atomic_inc(&task->refcount);
[278b4a30]297}
298
299/** Release a reference to a task.
300 *
301 * The last one to release a reference to a task destroys the task.
302 *
[da1bafb]303 * @param task Task to be released.
304 *
[278b4a30]305 */
[da1bafb]306void task_release(task_t *task)
[278b4a30]307{
[da1bafb]308 if ((atomic_predec(&task->refcount)) == 0)
309 task_destroy(task);
[278b4a30]310}
311
[dd8d5a7]312#ifdef __32_BITS__
313
314/** Syscall for reading task ID from userspace (32 bits)
[ec55358]315 *
[dd8d5a7]316 * @param uspace_taskid Pointer to user-space buffer
317 * where to store current task ID.
[5ba201d]318 *
319 * @return Zero on success or an error code from @ref errno.h.
[ec55358]320 *
321 */
[dd8d5a7]322sysarg_t sys_task_get_id(sysarg64_t *uspace_taskid)
[ec55358]323{
324 /*
[814c4f5]325 * No need to acquire lock on TASK because taskid remains constant for
326 * the lifespan of the task.
[ec55358]327 */
[dd8d5a7]328 return (sysarg_t) copy_to_uspace(uspace_taskid, &TASK->taskid,
[6f4495f5]329 sizeof(TASK->taskid));
[ec55358]330}
331
[dd8d5a7]332#endif /* __32_BITS__ */
333
334#ifdef __64_BITS__
335
336/** Syscall for reading task ID from userspace (64 bits)
337 *
338 * @return Current task ID.
339 *
340 */
341sysarg_t sys_task_get_id(void)
342{
343 /*
344 * No need to acquire lock on TASK because taskid remains constant for
345 * the lifespan of the task.
346 */
347 return TASK->taskid;
348}
349
350#endif /* __64_BITS__ */
351
[bc18d63]352/** Syscall for setting the task name.
353 *
354 * The name simplifies identifying the task in the task list.
355 *
[5ba201d]356 * @param name The new name for the task. (typically the same
357 * as the command used to execute it).
[bc18d63]358 *
359 * @return 0 on success or an error code from @ref errno.h.
[5ba201d]360 *
[bc18d63]361 */
[96b02eb9]362sysarg_t sys_task_set_name(const char *uspace_name, size_t name_len)
[bc18d63]363{
364 char namebuf[TASK_NAME_BUFLEN];
[5ba201d]365
[bc18d63]366 /* Cap length of name and copy it from userspace. */
367 if (name_len > TASK_NAME_BUFLEN - 1)
368 name_len = TASK_NAME_BUFLEN - 1;
[5ba201d]369
[577f042a]370 int rc = copy_from_uspace(namebuf, uspace_name, name_len);
[bc18d63]371 if (rc != 0)
[96b02eb9]372 return (sysarg_t) rc;
[5ba201d]373
[f4b1535]374 namebuf[name_len] = '\0';
[577f042a]375
376 /*
377 * As the task name is referenced also from the
378 * threads, lock the threads' lock for the course
379 * of the update.
380 */
381
382 irq_spinlock_lock(&tasks_lock, true);
383 irq_spinlock_lock(&TASK->lock, false);
384 irq_spinlock_lock(&threads_lock, false);
385
386 /* Set task name */
[f4b1535]387 str_cpy(TASK->name, TASK_NAME_BUFLEN, namebuf);
[5ba201d]388
[577f042a]389 irq_spinlock_unlock(&threads_lock, false);
390 irq_spinlock_unlock(&TASK->lock, false);
391 irq_spinlock_unlock(&tasks_lock, true);
392
[bc18d63]393 return EOK;
394}
395
[1e9f8ab]396/** Syscall to forcefully terminate a task
397 *
398 * @param uspace_taskid Pointer to task ID in user space.
399 *
400 * @return 0 on success or an error code from @ref errno.h.
401 *
402 */
403sysarg_t sys_task_kill(task_id_t *uspace_taskid)
404{
405 task_id_t taskid;
[5bcf1f9]406 int rc = copy_from_uspace(&taskid, uspace_taskid, sizeof(taskid));
[1e9f8ab]407 if (rc != 0)
408 return (sysarg_t) rc;
[5bcf1f9]409
[1e9f8ab]410 return (sysarg_t) task_kill(taskid);
411}
412
[9a8d91b]413/** Find task structure corresponding to task ID.
414 *
[814c4f5]415 * The tasks_lock must be already held by the caller of this function and
416 * interrupts must be disabled.
[9a8d91b]417 *
[5ba201d]418 * @param id Task ID.
419 *
[e1b6742]420 * @return Task structure address or NULL if there is no such task ID.
[9a8d91b]421 *
422 */
[5ba201d]423task_t *task_find_by_id(task_id_t id)
424{
[63e27ef]425 assert(interrupts_disabled());
426 assert(irq_spinlock_locked(&tasks_lock));
[1d432f9]427
[e1b6742]428 avltree_node_t *node =
429 avltree_search(&tasks_tree, (avltree_key_t) id);
[5ba201d]430
[b76a2217]431 if (node)
[da1bafb]432 return avltree_get_instance(node, task_t, tasks_tree_node);
[5ba201d]433
[b76a2217]434 return NULL;
[9a8d91b]435}
436
[0313ff0]437/** Get accounting data of given task.
438 *
[1d432f9]439 * Note that task lock of 'task' must be already held and interrupts must be
[814c4f5]440 * already disabled.
[0313ff0]441 *
[da1bafb]442 * @param task Pointer to the task.
[88dea9d]443 * @param ucycles Out pointer to sum of all user cycles.
444 * @param kcycles Out pointer to sum of all kernel cycles.
[0313ff0]445 *
446 */
[da1bafb]447void task_get_accounting(task_t *task, uint64_t *ucycles, uint64_t *kcycles)
[0313ff0]448{
[63e27ef]449 assert(interrupts_disabled());
450 assert(irq_spinlock_locked(&task->lock));
[1d432f9]451
[a2a00e8]452 /* Accumulated values of task */
[da1bafb]453 uint64_t uret = task->ucycles;
454 uint64_t kret = task->kcycles;
[0313ff0]455
456 /* Current values of threads */
[feeac0d]457 list_foreach(task->threads, th_link, thread_t, thread) {
[da1bafb]458 irq_spinlock_lock(&thread->lock, false);
[0313ff0]459
[62b6d17]460 /* Process only counted threads */
[da1bafb]461 if (!thread->uncounted) {
462 if (thread == THREAD) {
[6f4495f5]463 /* Update accounting of current thread */
[a2a00e8]464 thread_update_accounting(false);
[da1bafb]465 }
466
467 uret += thread->ucycles;
468 kret += thread->kcycles;
[62b6d17]469 }
[da1bafb]470
471 irq_spinlock_unlock(&thread->lock, false);
[0313ff0]472 }
473
[a2a00e8]474 *ucycles = uret;
475 *kcycles = kret;
[0313ff0]476}
477
[da1bafb]478static void task_kill_internal(task_t *task)
[121966e]479{
[df58e44]480 irq_spinlock_lock(&task->lock, false);
481 irq_spinlock_lock(&threads_lock, false);
[5ba201d]482
[121966e]483 /*
484 * Interrupt all threads.
485 */
[df58e44]486
[feeac0d]487 list_foreach(task->threads, th_link, thread_t, thread) {
[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) {
[05ffb41]616 int i;
617 for (i = 0; i < MAX_KERNEL_OBJECTS; i++) {
618 phone_t *phone = phone_get(task, i);
619 if (phone && phone->callee)
620 printf(" %d:%p", i, phone->callee);
[c0f13d2]621 }
622 printf("\n");
[b76a2217]623 }
[5ba201d]624
[da1bafb]625 irq_spinlock_unlock(&task->lock, false);
[b76a2217]626 return true;
627}
628
[c0f13d2]629/** Print task list
630 *
631 * @param additional Print additional information.
632 *
633 */
634void task_print_list(bool additional)
[37c57f2]635{
[f74bbaf]636 /* Messing with task structures, avoid deadlock */
[da1bafb]637 irq_spinlock_lock(&tasks_lock, true);
[5ba201d]638
639#ifdef __32_BITS__
[c0f13d2]640 if (additional)
[48dcc69]641 printf("[id ] [threads] [calls] [callee\n");
[c0f13d2]642 else
[473d5d2]643 printf("[id ] [name ] [ctn] [address ] [as ]"
[c0f13d2]644 " [ucycles ] [kcycles ]\n");
[52755f1]645#endif
[5ba201d]646
[52755f1]647#ifdef __64_BITS__
[c0f13d2]648 if (additional)
[be06914]649 printf("[id ] [ucycles ] [kcycles ] [threads] [calls]"
[c0f13d2]650 " [callee\n");
651 else
[473d5d2]652 printf("[id ] [name ] [ctn] [address ]"
[c0f13d2]653 " [as ]\n");
[52755f1]654#endif
[5ba201d]655
[c0f13d2]656 avltree_walk(&tasks_tree, task_print_walker, &additional);
[5ba201d]657
[da1bafb]658 irq_spinlock_unlock(&tasks_lock, true);
[37c57f2]659}
[7509ddc]660
[cc73a8a1]661/** @}
[b45c443]662 */
Note: See TracBrowser for help on using the repository browser.