/** * Signal g_TimerSem to wake-up timer_task. * */ static void signal_timer_task(void) { #ifdef CONFIG_NANOKERNEL nano_sem_give(&g_TimerSem); #else T_EXEC_LEVEL execLvl; execLvl = _getExecLevel(); /* call the nanoK service that corresponds to the current execution level */ switch (execLvl) { case E_EXEC_LVL_ISR: isr_sem_give(g_TimerSem); break; case E_EXEC_LVL_FIBER: fiber_sem_give(g_TimerSem); break; case E_EXEC_LVL_TASK: task_sem_give(g_TimerSem); break; default: /* will not do that from unknown context */ panic(E_OS_ERR_NOT_SUPPORTED); break; } #endif }
/** * * @brief The test fiber entry function * * Fiber waits on the semaphore controlled by the test task * It signals the semaphore, the testing task waits for, * then it signals the semaphore for N_TASKS times, testing task * checks this number. * Then fiber signals each of the semaphores in the group. Test * task checks this. * * @return N/A */ static void testFiberEntry(void) { int i; /* release semaphore test task is waiting for */ nano_fiber_sem_take(&fiberSem, TICKS_UNLIMITED); fiber_sem_give(simpleSem); /* release the semaphore for N_TESTS times */ nano_fiber_sem_take(&fiberSem, TICKS_UNLIMITED); for (i = 0; i < N_TESTS; i++) { fiber_sem_give(simpleSem); } /* signal each semaphore in the group */ for (i = 0; semList[i] != ENDLIST; i++) { nano_fiber_sem_take(&fiberSem, TICKS_UNLIMITED); fiber_sem_give(semList[i]); } }