Changeset b79207d in mainline


Ignore:
Timestamp:
2019-07-18T17:19:02Z (5 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Parents:
bb580548
Message:

Create abort_shutdown function

The piece of code which destroyed the thread used
by shutdown has been refractoried to it's own function.
This method will be called in the kernel console to ensure
that there is no weird threading behaviour

Location:
kernel/generic
Files:
3 edited

Legend:

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

    rbb580548 rb79207d  
    4747extern void reboot(void);
    4848extern void arch_reboot(void);
     49extern void abort_shutdown(void);
    4950extern sys_errno_t sys_shutdown(sysarg_t mode, sysarg_t delay, sysarg_t kconsole);
    5051
  • kernel/generic/src/console/cmd.c

    rbb580548 rb79207d  
    880880int cmd_reboot(cmd_arg_t *argv)
    881881{
     882        abort_shutdown();
    882883        reboot();
    883884
     
    11251126int cmd_halt(cmd_arg_t *argv)
    11261127{
     1128        abort_shutdown();
    11271129        halt();
    11281130        return 1;
  • kernel/generic/src/main/shutdown.c

    rbb580548 rb79207d  
    9898}
    9999
     100void abort_shutdown()
     101{
     102        irq_spinlock_lock(&threads_lock, true);
     103        thread_t *thread = atomic_load(&shutdown_thread);
     104        if (thread != NULL) {
     105                thread_interrupt(thread);
     106                atomic_store(&shutdown_thread, NULL);
     107        }
     108        irq_spinlock_unlock(&threads_lock, true);
     109}
     110
    100111/* argument structure for the shutdown thread */
    101112typedef struct {
     
    135146#endif
    136147
    137         irq_spinlock_lock(&threads_lock, true);
    138         thread_t *thread = atomic_load(&shutdown_thread);
    139         if (thread != NULL) {
    140                 thread_interrupt(thread);
    141                 atomic_store(&shutdown_thread, NULL);
    142         }
    143         irq_spinlock_unlock(&threads_lock, true);
     148        abort_shutdown();
    144149
    145150        /* `cancel` or default has been called */
     
    165170        arg->delay = delay;
    166171
    167         thread = thread_create(sys_shutdown_function, arg, kernel_task, THREAD_FLAG_NONE, "shutdown");
     172        thread_t *thread = thread_create(sys_shutdown_function, arg, kernel_task, THREAD_FLAG_NONE, "shutdown");
    168173
    169174        if (thread == NULL) {
Note: See TracChangeset for help on using the changeset viewer.