Changeset b79207d in mainline for kernel/generic/src/main/shutdown.c


Ignore:
Timestamp:
2019-07-18T17:19:02Z (6 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.