src/C/softirq.c
void task_softirq(void)
{
    softirq_t  *sfq = NULL;

    while (1) {

        /*
         * User ISRs
         */
        if (!isr_queue.empty) {
            while ((sfq = pop_softirq(&isr_queue))) {
                if (sfq->state == SFQ_WAITING) {
                    if (sfq->caller->state[TASK_MODE_MAINTHREAD] != TASK_STATE_LOCKED &&
                        sfq->caller->state[TASK_MODE_MAINTHREAD] != TASK_STATE_SLEEPING_DEEP)
                    {
                        disable_irq();
                        softirq_handler_user_isr(sfq);
                        sfq->state = SFQ_DONE;
                        full_memory_barrier();
                        enable_irq();
                        // ISR should be executed fastly, softirq let them being
                        // executed now, syscalls are delayed
                        request_schedule();
                    } else {
                        // while task is locked, postponing the ISR
                        uint32_t args[2] = { sfq->status, sfq->data };
                        disable_irq();
                        full_memory_barrier();
                        push_softirq(&isr_queue, sfq->caller->id, sfq->irqnum, sfq->handler, args);
                        sfq->state = SFQ_DONE;
                        enable_irq();
                    }
                }
            }
        }

        full_memory_barrier();

        /*
         * Syscalls
         */
        if (!syscall_queue.empty) {
            while ((sfq = pop_softirq(&syscall_queue))) {
                if (sfq->state == SFQ_WAITING) {
                    softirq_handler_syscall(sfq);
                    sfq->state = SFQ_DONE;
                }
            }
        }

        disable_irq();
        full_memory_barrier();

        if (syscall_queue.empty && isr_queue.empty) {
            /* Softirq is idle when there is no more syscall of ISR to manage */
            task_set_task_state (ID_SOFTIRQ, TASK_MODE_MAINTHREAD, TASK_STATE_IDLE);
            full_memory_barrier();
            request_schedule();
        }

        enable_irq();

    }
    /* end of main loop */
}
/*
** This is the softirq task. Scheduled when a syscall or a userspace interrupt handler
** need to be executed. It is executed out of processor interrupt mode, on voluntary schedule
** only.
*/
This is the softirq task. Scheduled when a syscall or a userspace interrupt handler
need to be executed. It is executed out of processor interrupt mode, on voluntary schedule
only.
This is the softirq task . Scheduled when a syscall or a userspace interrupt handler need to be executed . It is executed out of processor interrupt mode on voluntary schedule only .
void task_softirq(void)
{
    softirq_t  *sfq = NULL;
    while (1) {
        if (!isr_queue.empty) {
            while ((sfq = pop_softirq(&isr_queue))) {
                if (sfq->state == SFQ_WAITING) {
                    if (sfq->caller->state[TASK_MODE_MAINTHREAD] != TASK_STATE_LOCKED &&
                        sfq->caller->state[TASK_MODE_MAINTHREAD] != TASK_STATE_SLEEPING_DEEP)
                    {
                        disable_irq();
                        softirq_handler_user_isr(sfq);
                        sfq->state = SFQ_DONE;
                        full_memory_barrier();
                        enable_irq();
                        request_schedule();
                    } else {
                        uint32_t args[2] = { sfq->status, sfq->data };
                        disable_irq();
                        full_memory_barrier();
                        push_softirq(&isr_queue, sfq->caller->id, sfq->irqnum, sfq->handler, args);
                        sfq->state = SFQ_DONE;
                        enable_irq();
                    }
                }
            }
        }
        full_memory_barrier();
        if (!syscall_queue.empty) {
            while ((sfq = pop_softirq(&syscall_queue))) {
                if (sfq->state == SFQ_WAITING) {
                    softirq_handler_syscall(sfq);
                    sfq->state = SFQ_DONE;
                }
            }
        }
        disable_irq();
        full_memory_barrier();
        if (syscall_queue.empty && isr_queue.empty) {
            task_set_task_state (ID_SOFTIRQ, TASK_MODE_MAINTHREAD, TASK_STATE_IDLE);
            full_memory_barrier();
            request_schedule();
        }
        enable_irq();
    }
}
void task_softirq ( void ) { softirq_t * sfq = NULL ; while ( 1 ) { if ( ! isr_queue . empty ) { while ( ( sfq = pop_softirq ( & isr_queue ) ) ) { if ( sfq -> state == SFQ_WAITING ) { if ( sfq -> caller -> state [ TASK_MODE_MAINTHREAD ] != TASK_STATE_LOCKED && sfq -> caller -> state [ TASK_MODE_MAINTHREAD ] != TASK_STATE_SLEEPING_DEEP ) { disable_irq ( ) ; softirq_handler_user_isr ( sfq ) ; sfq -> state = SFQ_DONE ; full_memory_barrier ( ) ; enable_irq ( ) ; request_schedule ( ) ; } else { uint32_t args [ 2 ] = { sfq -> status , sfq -> data } ; disable_irq ( ) ; full_memory_barrier ( ) ; push_softirq ( & isr_queue , sfq -> caller -> id , sfq -> irqnum , sfq -> handler , args ) ; sfq -> state = SFQ_DONE ; enable_irq ( ) ; } } } } full_memory_barrier ( ) ; if ( ! syscall_queue . empty ) { while ( ( sfq = pop_softirq ( & syscall_queue ) ) ) { if ( sfq -> state == SFQ_WAITING ) { softirq_handler_syscall ( sfq ) ; sfq -> state = SFQ_DONE ; } } } disable_irq ( ) ; full_memory_barrier ( ) ; if ( syscall_queue . empty && isr_queue . empty ) { task_set_task_state ( ID_SOFTIRQ , TASK_MODE_MAINTHREAD , TASK_STATE_IDLE ) ; full_memory_barrier ( ) ; request_schedule ( ) ; } enable_irq ( ) ; } }
This is the softirq task.
This is the softirq task .
/*
         * User ISRs
         */ // ISR should be executed fastly, softirq let them being // executed now, syscalls are delayed // while task is locked, postponing the ISR /*
         * Syscalls
         */ /* Softirq is idle when there is no more syscall of ISR to manage */ /* end of main loop */