Changeset f74bbaf in mainline for kernel/generic/src


Ignore:
Timestamp:
2007-04-09T06:13:24Z (18 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d0b1443
Parents:
261595b
Message:

start shutdown infrastructure

Location:
kernel/generic/src
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/console/cmd.c

    r261595b rf74bbaf  
    4949#include <adt/list.h>
    5050#include <arch.h>
     51#include <config.h>
    5152#include <func.h>
    5253#include <macros.h>
     
    8081static cmd_info_t exit_info = {
    8182        .name = "exit",
    82         .description = "Exit kconsole",
     83        .description = "Exit kconsole.",
     84        .argc = 0
     85};
     86
     87static int cmd_reboot(cmd_arg_t *argv);
     88static cmd_info_t reboot_info = {
     89        .name = "reboot",
     90        .description = "Reboot.",
     91        .func = cmd_reboot,
    8392        .argc = 0
    8493};
     
    430439        &desc_info,
    431440        &exit_info,
     441        &reboot_info,
    432442        &halt_info,
    433443        &help_info,
     
    505515}
    506516
     517
     518/** Reboot the system.
     519 *
     520 * @param argv Argument vector.
     521 *
     522 * @return 0 on failure, 1 on success.
     523 */
     524int cmd_reboot(cmd_arg_t *argv)
     525{
     526        reboot();
     527       
     528        /* Not reached */
     529        return 1;
     530}
     531
    507532/** Describe specified command.
    508533 *
  • kernel/generic/src/proc/task.c

    r261595b rf74bbaf  
    9494}
    9595
     96/** Kill all tasks except the current task.
     97 *
     98 */
     99void task_done(void)
     100{
     101        task_t *t;
     102        do { /* Repeat until there are any tasks except TASK */
     103               
     104                /* Messing with task structures, avoid deadlock */
     105                ipl_t ipl = interrupts_disable();
     106                spinlock_lock(&tasks_lock);
     107               
     108                t = NULL;
     109                link_t *cur;
     110                for (cur = tasks_btree.leaf_head.next; cur != &tasks_btree.leaf_head; cur = cur->next) {
     111                        btree_node_t *node = list_get_instance(cur, btree_node_t, leaf_link);
     112                       
     113                        unsigned int i;
     114                        for (i = 0; i < node->keys; i++) {
     115                                if ((task_t *) node->value[i] != TASK) {
     116                                        t = (task_t *) node->value[i];
     117                                        break;
     118                                }
     119                        }
     120                }
     121               
     122                if (t != NULL) {
     123                        task_id_t id = t->taskid;
     124                       
     125                        spinlock_unlock(&tasks_lock);
     126                        interrupts_restore(ipl);
     127                       
     128#ifdef CONFIG_DEBUG
     129                        printf("Killing task %llu\n", id);
     130#endif                 
     131                        task_kill(id);
     132                } else {
     133                        spinlock_unlock(&tasks_lock);
     134                        interrupts_restore(ipl);
     135                }
     136               
     137        } while (t != NULL);
     138}
    96139
    97140/** Create new task
     
    374417        ipl_t ipl;
    375418       
    376         /* Messing with thread structures, avoid deadlock */
     419        /* Messing with task structures, avoid deadlock */
    377420        ipl = interrupts_disable();
    378421        spinlock_lock(&tasks_lock);
Note: See TracChangeset for help on using the changeset viewer.