Esempio n. 1
0
//${AOs::Table::SM::active::paused} ..........................................
Q_STATE_DEF(Table, paused) {
    QP::QState status_;
    switch (e->sig) {
        //${AOs::Table::SM::active::paused}
        case Q_ENTRY_SIG: {
            BSP_displayPaused(1U);
            status_ = Q_RET_HANDLED;
            break;
        }
        //${AOs::Table::SM::active::paused}
        case Q_EXIT_SIG: {
            BSP_displayPaused(0U);
            status_ = Q_RET_HANDLED;
            break;
        }
        //${AOs::Table::SM::active::paused::PAUSE}
        case PAUSE_SIG: {
            status_ = tran(&serving);
            break;
        }
        //${AOs::Table::SM::active::paused::HUNGRY}
        case HUNGRY_SIG: {
            uint8_t n = Q_EVT_CAST(TableEvt)->philoNum;
            // philo ID must be in range and he must be not hungry
            Q_ASSERT((n < N_PHILO) && (!m_isHungry[n]));
            m_isHungry[n] = true;
            BSP_displayPhilStat(n, HUNGRY);
            status_ = Q_RET_HANDLED;
            break;
        }
        //${AOs::Table::SM::active::paused::DONE}
        case DONE_SIG: {
            uint8_t n = Q_EVT_CAST(TableEvt)->philoNum;
            // phil ID must be in range and he must be not hungry
            Q_ASSERT((n < N_PHILO) && (!m_isHungry[n]));

            BSP_displayPhilStat(n, THINKING);
            uint8_t m = LEFT(n);
            /* both forks of Phil[n] must be used */
            Q_ASSERT((m_fork[n] == USED) && (m_fork[m] == USED));

            m_fork[m] = FREE;
            m_fork[n] = FREE;
            status_ = Q_RET_HANDLED;
            break;
        }
        default: {
            status_ = super(&active);
            break;
        }
    }
    return status_;
}
Esempio n. 2
0
// ${AOs::Table::SM::active::paused}
QP::QState Table::paused_x(Table * const me) {
    BSP_displayPaused(0U);
    (void)me; // avoid compiler warning in case 'me' is not used
    return QM_EXIT(&paused_s);
}