Changes in / [875c629:bf75e3cb] in mainline


Ignore:
Location:
kernel/generic
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/debug.h

    r875c629 rbf75e3cb  
    5555        do { \
    5656                if (!(expr)) \
    57                         panic_assert("%s() at %s:%u:\n%s", \
    58                             __func__, __FILE__, __LINE__, #expr); \
     57                        panic_assert("%s", #expr); \
    5958        } while (0)
    6059
     
    7372        do { \
    7473                if (!(expr)) \
    75                         panic_assert("%s() at %s:%u:\n%s, %s", \
    76                             __func__, __FILE__, __LINE__, #expr, msg); \
     74                        panic_assert("%s, %s", #expr, msg); \
    7775        } while (0)
    7876
  • kernel/generic/include/proc/thread.h

    r875c629 rbf75e3cb  
    9191       
    9292        /** Function implementing the thread. */
    93         void (*thread_code)(void *);
     93        void (* thread_code)(void *);
    9494        /** Argument passed to thread_code() function. */
    9595        void *thread_arg;
    9696       
    9797        /**
    98          * From here, the stored context is restored
    99          * when the thread is scheduled.
     98         * From here, the stored context is restored when the thread is
     99         * scheduled.
    100100         */
    101101        context_t saved_context;
    102        
    103         /**
    104          * From here, the stored timeout context
    105          * is restored when sleep times out.
     102        /**
     103         * From here, the stored timeout context is restored when sleep times
     104         * out.
    106105         */
    107106        context_t sleep_timeout_context;
    108        
    109         /**
    110          * From here, the stored interruption context
    111          * is restored when sleep is interrupted.
     107        /**
     108         * From here, the stored interruption context is restored when sleep is
     109         * interrupted.
    112110         */
    113111        context_t sleep_interruption_context;
     
    127125         */
    128126        bool in_copy_from_uspace;
    129        
    130127        /**
    131128         * True if this thread is executing copy_to_uspace().
     
    190187       
    191188#ifdef CONFIG_UDEBUG
    192         /**
    193          * If true, the scheduler will print a stack trace
    194          * to the kernel console upon scheduling this thread.
    195          */
    196         bool btrace;
    197        
    198189        /** Debugging stuff */
    199190        udebug_thread_t udebug;
     
    246237extern bool thread_exists(thread_t *);
    247238
    248 #ifdef CONFIG_UDEBUG
    249 extern void thread_stack_trace(thread_id_t);
    250 #endif
    251 
    252239/** Fpu context slab cache. */
    253240extern slab_cache_t *fpu_context_slab;
  • kernel/generic/src/console/cmd.c

    r875c629 rbf75e3cb  
    7878static cmd_info_t help_info = {
    7979        .name = "help",
    80         .description = "List supported commands.",
     80        .description = "List of supported commands.",
    8181        .func = cmd_help,
    8282        .argc = 0
    8383};
    8484
    85 /* Data and methods for 'reboot' command. */
    8685static int cmd_reboot(cmd_arg_t *argv);
    8786static cmd_info_t reboot_info = {
    8887        .name = "reboot",
    89         .description = "Reboot system.",
     88        .description = "Reboot.",
    9089        .func = cmd_reboot,
    9190        .argc = 0
    9291};
    9392
    94 /* Data and methods for 'uptime' command. */
    9593static int cmd_uptime(cmd_arg_t *argv);
    9694static cmd_info_t uptime_info = {
    9795        .name = "uptime",
    98         .description = "Show system uptime.",
     96        .description = "Print uptime information.",
    9997        .func = cmd_uptime,
    10098        .argc = 0
    10199};
    102100
    103 /* Data and methods for 'continue' command. */
    104101static int cmd_continue(cmd_arg_t *argv);
    105102static cmd_info_t continue_info = {
     
    111108
    112109#ifdef CONFIG_TEST
    113 
    114 /* Data and methods for 'test' command. */
    115110static char test_buf[MAX_CMDLINE + 1];
    116111static int cmd_test(cmd_arg_t *argv);
     
    124119static cmd_info_t test_info = {
    125120        .name = "test",
    126         .description = "<test> List kernel tests or run a test.",
     121        .description = "Print list of kernel tests or run a test.",
    127122        .func = cmd_test,
    128123        .argc = 1,
     
    130125};
    131126
    132 /* Data and methods for 'bench' command. */
    133127static int cmd_bench(cmd_arg_t *argv);
    134128static cmd_arg_t bench_argv[] = {
     
    144138static cmd_info_t bench_info = {
    145139        .name = "bench",
    146         .description = "<test> <count> Run kernel test as benchmark.",
     140        .description = "Run kernel test as benchmark.",
    147141        .func = cmd_bench,
    148142        .argc = 2,
    149143        .argv = bench_argv
    150144};
    151 
    152 #endif /* CONFIG_TEST */
     145#endif
    153146
    154147/* Data and methods for 'description' command. */
    155148static int cmd_desc(cmd_arg_t *argv);
    156149static void desc_help(void);
    157 static char desc_buf[MAX_CMDLINE + 1];
     150static char desc_buf[MAX_CMDLINE+1];
    158151static cmd_arg_t desc_argv = {
    159152        .type = ARG_TYPE_STRING,
     
    163156static cmd_info_t desc_info = {
    164157        .name = "describe",
    165         .description = "<command> Describe specified command.",
     158        .description = "Describe specified command.",
    166159        .help = desc_help,
    167160        .func = cmd_desc,
     
    172165/* Data and methods for 'symaddr' command. */
    173166static int cmd_symaddr(cmd_arg_t *argv);
    174 static char symaddr_buf[MAX_CMDLINE + 1];
     167static char symaddr_buf[MAX_CMDLINE+1];
    175168static cmd_arg_t symaddr_argv = {
    176169        .type = ARG_TYPE_STRING,
     
    180173static cmd_info_t symaddr_info = {
    181174        .name = "symaddr",
    182         .description = "<symbol> Return symbol address.",
     175        .description = "Return symbol address.",
    183176        .func = cmd_symaddr,
    184177        .argc = 1,
     
    186179};
    187180
    188 /* Data and methods for 'set4' command. */
    189 static char set_buf[MAX_CMDLINE + 1];
     181static char set_buf[MAX_CMDLINE+1];
    190182static int cmd_set4(cmd_arg_t *argv);
    191183static cmd_arg_t set4_argv[] = {
     
    201193static cmd_info_t set4_info = {
    202194        .name = "set4",
    203         .description = "<addr> <value> Set 4B memory location to a value.",
     195        .description = "set <dest_addr> <value> - 4byte version",
    204196        .func = cmd_set4,
    205197        .argc = 2,
     
    221213static cmd_info_t call0_info = {
    222214        .name = "call0",
    223         .description = "<function> Call function().",
     215        .description = "call0 <function> -> call function().",
    224216        .func = cmd_call0,
    225217        .argc = 1,
     
    236228static cmd_info_t mcall0_info = {
    237229        .name = "mcall0",
    238         .description = "<function> Call function() on each CPU.",
     230        .description = "mcall0 <function> -> call function() on each CPU.",
    239231        .func = cmd_mcall0,
    240232        .argc = 1,
     
    258250static cmd_info_t call1_info = {
    259251        .name = "call1",
    260         .description = "<function> <arg1> Call function(arg1).",
     252        .description = "call1 <function> <arg1> -> call function(arg1).",
    261253        .func = cmd_call1,
    262254        .argc = 2,
     
    285277static cmd_info_t call2_info = {
    286278        .name = "call2",
    287         .description = "<function> <arg1> <arg2> Call function(arg1, arg2).",
     279        .description = "call2 <function> <arg1> <arg2> -> call function(arg1,arg2).",
    288280        .func = cmd_call2,
    289281        .argc = 3,
     
    318310static cmd_info_t call3_info = {
    319311        .name = "call3",
    320         .description = "<function> <arg1> <arg2> <arg3> Call function(arg1, arg2, arg3).",
     312        .description = "call3 <function> <arg1> <arg2> <arg3> -> call function(arg1,arg2,arg3).",
    321313        .func = cmd_call3,
    322314        .argc = 4,
     
    348340cmd_info_t tlb_info = {
    349341        .name = "tlb",
    350         .description = "Print TLB of the current CPU.",
     342        .description = "Print TLB of current processor.",
    351343        .help = NULL,
    352344        .func = cmd_tlb,
     
    385377};
    386378
    387 #ifdef CONFIG_UDEBUG
    388 
    389 /* Data and methods for 'btrace' command */
    390 static int cmd_btrace(cmd_arg_t *argv);
    391 static cmd_arg_t btrace_argv = {
    392         .type = ARG_TYPE_INT,
    393 };
    394 static cmd_info_t btrace_info = {
    395         .name = "btrace",
    396         .description = "<threadid> Show thread stack trace.",
    397         .func = cmd_btrace,
    398         .argc = 1,
    399         .argv = &btrace_argv
    400 };
    401 
    402 #endif /* CONFIG_UDEBUG */
    403379
    404380static int cmd_sched(cmd_arg_t *argv);
    405381static cmd_info_t sched_info = {
    406382        .name = "scheduler",
    407         .description = "Show scheduler information.",
     383        .description = "List all scheduler information.",
    408384        .func = cmd_sched,
    409385        .argc = 0
     
    430406static cmd_info_t zones_info = {
    431407        .name = "zones",
    432         .description = "List memory zones.",
     408        .description = "List of memory zones.",
    433409        .func = cmd_zones,
    434410        .argc = 0
     411};
     412
     413/* Data and methods for 'ipc' command */
     414static int cmd_ipc(cmd_arg_t *argv);
     415static cmd_arg_t ipc_argv = {
     416        .type = ARG_TYPE_INT,
     417};
     418static cmd_info_t ipc_info = {
     419        .name = "ipc",
     420        .description = "ipc <taskid> Show IPC information of given task.",
     421        .func = cmd_ipc,
     422        .argc = 1,
     423        .argv = &ipc_argv
     424};
     425
     426/* Data and methods for 'kill' command */
     427static int cmd_kill(cmd_arg_t *argv);
     428static cmd_arg_t kill_argv = {
     429        .type = ARG_TYPE_INT,
     430};
     431static cmd_info_t kill_info = {
     432        .name = "kill",
     433        .description = "kill <taskid> Kill a task.",
     434        .func = cmd_kill,
     435        .argc = 1,
     436        .argv = &kill_argv
    435437};
    436438
     
    443445static cmd_info_t zone_info = {
    444446        .name = "zone",
    445         .description = "<zone> Show memory zone structure.",
     447        .description = "Show memory zone structure.",
    446448        .func = cmd_zone,
    447449        .argc = 1,
    448450        .argv = &zone_argv
    449 };
    450 
    451 /* Data and methods for 'ipc' command */
    452 static int cmd_ipc(cmd_arg_t *argv);
    453 static cmd_arg_t ipc_argv = {
    454         .type = ARG_TYPE_INT,
    455 };
    456 static cmd_info_t ipc_info = {
    457         .name = "ipc",
    458         .description = "<taskid> Show IPC information of a task.",
    459         .func = cmd_ipc,
    460         .argc = 1,
    461         .argv = &ipc_argv
    462 };
    463 
    464 /* Data and methods for 'kill' command */
    465 static int cmd_kill(cmd_arg_t *argv);
    466 static cmd_arg_t kill_argv = {
    467         .type = ARG_TYPE_INT,
    468 };
    469 static cmd_info_t kill_info = {
    470         .name = "kill",
    471         .description = "<taskid> Kill a task.",
    472         .func = cmd_kill,
    473         .argc = 1,
    474         .argv = &kill_argv
    475451};
    476452
     
    506482        &cpus_info,
    507483        &desc_info,
     484        &reboot_info,
     485        &uptime_info,
    508486        &halt_info,
    509487        &help_info,
    510488        &ipc_info,
    511489        &kill_info,
    512         &physmem_info,
    513         &reboot_info,
    514         &sched_info,
    515490        &set4_info,
    516491        &slabs_info,
     492        &sysinfo_info,
    517493        &symaddr_info,
    518         &sysinfo_info,
     494        &sched_info,
     495        &threads_info,
    519496        &tasks_info,
    520         &threads_info,
     497        &physmem_info,
    521498        &tlb_info,
    522         &uptime_info,
    523499        &version_info,
    524500        &zones_info,
     
    528504        &bench_info,
    529505#endif
    530 #ifdef CONFIG_UDEBUG
    531         &btrace_info,
    532 #endif
    533506        NULL
    534507};
     
    557530        }
    558531}
     532
    559533
    560534/** List supported commands.
     
    600574}
    601575
     576
    602577/** Reboot the system.
    603578 *
     
    613588        return 1;
    614589}
     590
    615591
    616592/** Print system uptime information.
     
    848824}
    849825
     826
    850827/** Print detailed description of 'describe' command. */
    851828void desc_help(void)
     
    934911 * @return Always 1
    935912 */
    936 int cmd_slabs(cmd_arg_t *argv)
     913int cmd_slabs(cmd_arg_t * argv)
    937914{
    938915        slab_print_list();
     
    946923 * @return Always 1
    947924 */
    948 int cmd_sysinfo(cmd_arg_t *argv)
     925int cmd_sysinfo(cmd_arg_t * argv)
    949926{
    950927        sysinfo_dump(NULL);
     
    952929}
    953930
    954 /** Command for listing thread information
     931
     932/** Command for listings Thread information
    955933 *
    956934 * @param argv Ignored
     
    970948}
    971949
    972 /** Command for listing task information
     950/** Command for listings Task information
    973951 *
    974952 * @param argv Ignored
     
    988966}
    989967
    990 #ifdef CONFIG_UDEBUG
    991 
    992 /** Command for printing thread stack trace
     968/** Command for listings Thread information
     969 *
     970 * @param argv Ignores
     971 *
     972 * @return Always 1
     973 */
     974int cmd_sched(cmd_arg_t * argv)
     975{
     976        sched_print_list();
     977        return 1;
     978}
     979
     980/** Command for listing memory zones
     981 *
     982 * @param argv Ignored
     983 *
     984 * return Always 1
     985 */
     986int cmd_zones(cmd_arg_t * argv)
     987{
     988        zones_print_list();
     989        return 1;
     990}
     991
     992/** Command for memory zone details
    993993 *
    994994 * @param argv Integer argument from cmdline expected
    995995 *
    996996 * return Always 1
    997  *
    998  */
    999 int cmd_btrace(cmd_arg_t *argv)
    1000 {
    1001         thread_stack_trace(argv[0].intval);
    1002         return 1;
    1003 }
    1004 
    1005 #endif /* CONFIG_UDEBUG */
    1006 
    1007 /** Command for printing scheduler information
    1008  *
    1009  * @param argv Ignores
    1010  *
    1011  * @return Always 1
    1012  */
    1013 int cmd_sched(cmd_arg_t *argv)
    1014 {
    1015         sched_print_list();
    1016         return 1;
    1017 }
    1018 
    1019 /** Command for listing memory zones
    1020  *
    1021  * @param argv Ignored
     997 */
     998int cmd_zone(cmd_arg_t * argv)
     999{
     1000        zone_print_one(argv[0].intval);
     1001        return 1;
     1002}
     1003
     1004/** Command for printing task ipc details
     1005 *
     1006 * @param argv Integer argument from cmdline expected
    10221007 *
    10231008 * return Always 1
    10241009 */
    1025 int cmd_zones(cmd_arg_t *argv)
    1026 {
    1027         zones_print_list();
    1028         return 1;
    1029 }
    1030 
    1031 /** Command for memory zone details
     1010int cmd_ipc(cmd_arg_t * argv)
     1011{
     1012        ipc_print_task(argv[0].intval);
     1013        return 1;
     1014}
     1015
     1016/** Command for killing a task
    10321017 *
    10331018 * @param argv Integer argument from cmdline expected
    10341019 *
    1035  * return Always 1
    1036  */
    1037 int cmd_zone(cmd_arg_t *argv)
    1038 {
    1039         zone_print_one(argv[0].intval);
    1040         return 1;
    1041 }
    1042 
    1043 /** Command for printing task IPC details
    1044  *
    1045  * @param argv Integer argument from cmdline expected
    1046  *
    1047  * return Always 1
    1048  */
    1049 int cmd_ipc(cmd_arg_t *argv)
    1050 {
    1051         ipc_print_task(argv[0].intval);
    1052         return 1;
    1053 }
    1054 
    1055 /** Command for killing a task
    1056  *
    1057  * @param argv Integer argument from cmdline expected
    1058  *
    10591020 * return 0 on failure, 1 on success.
    10601021 */
    1061 int cmd_kill(cmd_arg_t *argv)
     1022int cmd_kill(cmd_arg_t * argv)
    10621023{
    10631024        if (task_kill(argv[0].intval) != EOK)
  • kernel/generic/src/proc/scheduler.c

    r875c629 rbf75e3cb  
    6262#include <print.h>
    6363#include <debug.h>
    64 #include <stacktrace.h>
    65 
     64
     65static void before_task_runs(void);
     66static void before_thread_runs(void);
     67static void after_thread_ran(void);
    6668static void scheduler_separated_stack(void);
    6769
     
    6971
    7072/** Carry out actions before new task runs. */
    71 static void before_task_runs(void)
     73void before_task_runs(void)
    7274{
    7375        before_task_runs_arch();
     
    7880 * Perform actions that need to be
    7981 * taken before the newly selected
    80  * thread is passed control.
     82 * tread is passed control.
    8183 *
    8284 * THREAD->lock is locked on entry
    8385 *
    8486 */
    85 static void before_thread_runs(void)
     87void before_thread_runs(void)
    8688{
    8789        before_thread_runs_arch();
    88        
    8990#ifdef CONFIG_FPU_LAZY
    90         if (THREAD == CPU->fpu_owner)
     91        if(THREAD == CPU->fpu_owner)
    9192                fpu_enable();
    9293        else
     
    101102        }
    102103#endif
    103        
    104 #ifdef CONFIG_UDEBUG
    105         if (THREAD->btrace) {
    106                 istate_t *istate = THREAD->udebug.uspace_state;
    107                 if (istate != NULL) {
    108                         printf("Thread %" PRIu64 " stack trace:\n", THREAD->tid);
    109                         stack_trace_istate(istate);
    110                 }
    111                
    112                 THREAD->btrace = false;
    113         }
    114 #endif
    115104}
    116105
     
    124113 *
    125114 */
    126 static void after_thread_ran(void)
     115void after_thread_ran(void)
    127116{
    128117        after_thread_ran_arch();
     
    402391         * possible destruction should thread_destroy() be called on this or any
    403392         * other processor while the scheduler is still using them.
     393         *
    404394         */
    405395        if (old_task)
     
    427417                                 * The thread structure is kept allocated until
    428418                                 * somebody calls thread_detach() on it.
     419                                 *
    429420                                 */
    430421                                if (!irq_spinlock_trylock(&THREAD->join_wq.lock)) {
    431422                                        /*
    432423                                         * Avoid deadlock.
     424                                         *
    433425                                         */
    434426                                        irq_spinlock_unlock(&THREAD->lock, false);
     
    451443                        /*
    452444                         * Prefer the thread after it's woken up.
     445                         *
    453446                         */
    454447                        THREAD->priority = -1;
     
    458451                         * waitq_sleep(). Address of wq->lock is kept in
    459452                         * THREAD->sleep_queue.
     453                         *
    460454                         */
    461455                        irq_spinlock_unlock(&THREAD->sleep_queue->lock, false);
     
    467461                        /*
    468462                         * Entering state is unexpected.
     463                         *
    469464                         */
    470465                        panic("tid%" PRIu64 ": unexpected state %s.",
     
    485480       
    486481        /*
    487          * If both the old and the new task are the same,
    488          * lots of work is avoided.
     482         * If both the old and the new task are the same, lots of work is
     483         * avoided.
     484         *
    489485         */
    490486        if (TASK != THREAD->task) {
     
    492488               
    493489                /*
    494                  * Note that it is possible for two tasks
    495                  * to share one address space.
     490                 * Note that it is possible for two tasks to share one address
     491                 * space.
     492                 (
    496493                 */
    497494                if (old_as != new_as) {
     
    499496                         * Both tasks and address spaces are different.
    500497                         * Replace the old one with the new one.
     498                         *
    501499                         */
    502500                        as_switch(old_as, new_as);
     
    529527         * necessary, is to be mapped in before_thread_runs(). This
    530528         * function must be executed before the switch to the new stack.
     529         *
    531530         */
    532531        before_thread_runs();
     
    535534         * Copy the knowledge of CPU, TASK, THREAD and preemption counter to
    536535         * thread's stack.
     536         *
    537537         */
    538538        the_copy(THE, (the_t *) THREAD->kstack);
     
    658658                                /*
    659659                                 * Ready thread on local CPU
     660                                 *
    660661                                 */
    661662                               
  • kernel/generic/src/proc/task.c

    r875c629 rbf75e3cb  
    449449static void task_kill_internal(task_t *task)
    450450{
     451        link_t *cur;
     452       
     453        /*
     454         * Interrupt all threads.
     455         */
    451456        irq_spinlock_lock(&task->lock, false);
    452         irq_spinlock_lock(&threads_lock, false);
    453        
    454         /*
    455          * Interrupt all threads.
    456          */
    457        
    458         link_t *cur;
    459457        for (cur = task->th_head.next; cur != &task->th_head; cur = cur->next) {
    460458                thread_t *thread = list_get_instance(cur, thread_t, th_link);
     
    473471        }
    474472       
    475         irq_spinlock_unlock(&threads_lock, false);
    476473        irq_spinlock_unlock(&task->lock, false);
    477474}
  • kernel/generic/src/proc/thread.c

    r875c629 rbf75e3cb  
    239239 * Switch thread to the ready state.
    240240 *
    241  * @param thread Thread to make ready.
     241 * @param t Thread to make ready.
    242242 *
    243243 */
     
    246246        irq_spinlock_lock(&thread->lock, true);
    247247       
    248         ASSERT(thread->state != Ready);
     248        ASSERT(!(thread->state == Ready));
    249249       
    250250        int i = (thread->priority < RQ_COUNT - 1)
     
    350350       
    351351#ifdef CONFIG_UDEBUG
    352         /* Initialize debugging stuff */
    353         thread->btrace = false;
     352        /* Init debugging stuff */
    354353        udebug_thread_initialize(&thread->udebug);
    355354#endif
     
    536535/** Detach thread.
    537536 *
    538  * Mark the thread as detached. If the thread is already
    539  * in the Lingering state, deallocate its resources.
     537 * Mark the thread as detached, if the thread is already in the Lingering
     538 * state, deallocate its resources.
    540539 *
    541540 * @param thread Thread to be detached.
     
    741740        ASSERT(interrupts_disabled());
    742741        ASSERT(irq_spinlock_locked(&threads_lock));
    743        
     742
    744743        thread_iterator_t iterator;
    745744       
     
    752751}
    753752
    754 #ifdef CONFIG_UDEBUG
    755 
    756 void thread_stack_trace(thread_id_t thread_id)
    757 {
    758         irq_spinlock_lock(&threads_lock, true);
    759        
    760         thread_t *thread = thread_find_by_id(thread_id);
    761         if (thread == NULL) {
    762                 printf("No such thread.\n");
    763                 irq_spinlock_unlock(&threads_lock, true);
    764                 return;
    765         }
    766        
    767         irq_spinlock_lock(&thread->lock, false);
    768        
    769         /*
    770          * Schedule a stack trace to be printed
    771          * just before the thread is scheduled next.
    772          *
    773          * If the thread is sleeping then try to interrupt
    774          * the sleep. Any request for printing an uspace stack
    775          * trace from within the kernel should be always
    776          * considered a last resort debugging means, therefore
    777          * forcing the thread's sleep to be interrupted
    778          * is probably justifiable.
    779          */
    780        
    781         bool sleeping = false;
    782         istate_t *istate = thread->udebug.uspace_state;
    783         if (istate != NULL) {
    784                 printf("Scheduling thread stack trace.\n");
    785                 thread->btrace = true;
    786                 if (thread->state == Sleeping)
    787                         sleeping = true;
    788         } else
    789                 printf("Thread interrupt state not available.\n");
    790        
    791         irq_spinlock_unlock(&thread->lock, false);
    792        
    793         if (sleeping)
    794                 waitq_interrupt_sleep(thread);
    795        
    796         irq_spinlock_unlock(&threads_lock, true);
    797 }
    798 
    799 #endif /* CONFIG_UDEBUG */
    800753
    801754/** Process syscall to create new thread.
     
    840793                                 * has already been created. We need to undo its
    841794                                 * creation now.
     795                                 *
    842796                                 */
    843797                               
     
    861815                 * THREAD_B events for threads that already existed
    862816                 * and could be detected with THREAD_READ before.
     817                 *
    863818                 */
    864819                udebug_thread_b_event_attach(thread, TASK);
  • kernel/generic/src/synch/waitq.c

    r875c629 rbf75e3cb  
    127127/** Interrupt sleeping thread.
    128128 *
    129  * This routine attempts to interrupt a thread from its sleep in
    130  * a waitqueue. If the thread is not found sleeping, no action
    131  * is taken.
    132  *
    133  * The threads_lock must be already held and interrupts must be
    134  * disabled upon calling this function.
     129 * This routine attempts to interrupt a thread from its sleep in a waitqueue.
     130 * If the thread is not found sleeping, no action is taken.
    135131 *
    136132 * @param thread Thread to be interrupted.
     
    142138        DEADLOCK_PROBE_INIT(p_wqlock);
    143139       
    144         /*
    145          * The thread is quaranteed to exist because
    146          * threads_lock is held.
    147          */
     140        irq_spinlock_lock(&threads_lock, true);
     141        if (!thread_exists(thread))
     142                goto out;
    148143       
    149144grab_locks:
     
    155150                        /*
    156151                         * The sleep cannot be interrupted.
     152                         *
    157153                         */
    158154                        irq_spinlock_unlock(&thread->lock, false);
    159                         return;
     155                        goto out;
    160156                }
    161157               
    162158                if (!irq_spinlock_trylock(&wq->lock)) {
    163                         /* Avoid deadlock */
    164159                        irq_spinlock_unlock(&thread->lock, false);
    165160                        DEADLOCK_PROBE(p_wqlock, DEADLOCK_THRESHOLD);
     161                        /* Avoid deadlock */
    166162                        goto grab_locks;
    167163                }
     
    177173                irq_spinlock_unlock(&wq->lock, false);
    178174        }
    179        
    180175        irq_spinlock_unlock(&thread->lock, false);
    181176       
    182177        if (do_wakeup)
    183178                thread_ready(thread);
     179       
     180out:
     181        irq_spinlock_unlock(&threads_lock, true);
    184182}
    185183
     
    372370                 * If the thread was already interrupted,
    373371                 * don't go to sleep at all.
     372                 *
    374373                 */
    375374                if (THREAD->interrupted) {
     
    382381                 * Set context that will be restored if the sleep
    383382                 * of this thread is ever interrupted.
     383                 *
    384384                 */
    385385                THREAD->sleep_interruptible = true;
Note: See TracChangeset for help on using the changeset viewer.