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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since d04e46e was 669f3d32, checked in by Adam Hraska <adam.hraska+hos@…>, 13 years ago

Adapted the kernel futex subsystem to use CHT.

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