void ThreadC (void *arg) { while (1) { nOS_SemTake(&semC, NOS_WAIT_INFINITE); nOS_SemGive(&semB); } }
int main( void ) { // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; nOS_Init(); nOS_ThreadSetName(NULL, "main"); BTCTL = BTHOLD|BTDIV|BT_fCLK2_DIV128; BTCNT1 = 0; BTCNT2 = 0; IE2_bit.BTIE = 1; BTCTL &=~ BTHOLD; __enable_interrupt(); nOS_SemCreate(&semA, 0, 1); nOS_SemCreate(&semB, 0, 1); nOS_SemCreate(&semC, 0, 1); nOS_ThreadCreate(&threadA, ThreadA, 0, stackA, THREAD_STACK_SIZE, NOS_CONFIG_HIGHEST_THREAD_PRIO, NOS_THREAD_READY, "ThreadA"); nOS_ThreadCreate(&threadB, ThreadB, 0, stackB, THREAD_STACK_SIZE, NOS_CONFIG_HIGHEST_THREAD_PRIO-1, NOS_THREAD_READY, "ThreadB"); nOS_ThreadCreate(&threadC, ThreadC, 0, stackC, THREAD_STACK_SIZE, NOS_CONFIG_HIGHEST_THREAD_PRIO-2, NOS_THREAD_READY, "ThreadC"); while (1) { nOS_SemGive(&semC); } }
void ThreadC (void *arg) { while(true) { nOS_Print("%s running\n", nOS_ThreadGetName(NULL)); nOS_SemTake(&semC, NOS_WAIT_INFINITE); nOS_SemGive(&semB); } }
void ThreadB (void *arg) { NOS_UNUSED(arg); while (1) { nOS_SemTake(&semB, NOS_WAIT_INFINITE); nOS_SemGive(&semA); } }
int main (void) { nOS_Init(); nOS_ThreadSetName(NULL, "main"); nOS_SemCreate(&semA, 0, 1); nOS_SemCreate(&semB, 0, 1); nOS_SemCreate(&semC, 0, 1); nOS_ThreadCreate(&threadA, ThreadA, NULL, stackA, 64, NOS_CONFIG_HIGHEST_THREAD_PRIO, NOS_THREAD_READY, "ThreadA"); nOS_ThreadCreate(&threadB, ThreadB, NULL, stackB, 64, NOS_CONFIG_HIGHEST_THREAD_PRIO-1, NOS_THREAD_READY, "ThreadB"); nOS_ThreadCreate(&threadC, ThreadC, NULL, stackC, 64, NOS_CONFIG_HIGHEST_THREAD_PRIO-2, NOS_THREAD_READY, "ThreadC"); nOS_Start(TimerA0_Init); while (1){ nOS_SemGive(&semC); } }
int main() { nOS_Init(); nOS_ThreadSetName(NULL, "main"); nOS_SemCreate(&semA, 0, 1); nOS_SemCreate(&semB, 0, 1); nOS_SemCreate(&semC, 0, 1); nOS_ThreadCreate(&threadA, ThreadA, 0, stackA, THREAD_STACK_SIZE, NOS_CONFIG_HIGHEST_THREAD_PRIO, NOS_THREAD_READY, "ThreadA"); nOS_ThreadCreate(&threadB, ThreadB, 0, stackB, THREAD_STACK_SIZE, NOS_CONFIG_HIGHEST_THREAD_PRIO-1, NOS_THREAD_READY, "ThreadB"); nOS_ThreadCreate(&threadC, ThreadC, 0, stackC, THREAD_STACK_SIZE, NOS_CONFIG_HIGHEST_THREAD_PRIO-2, NOS_THREAD_READY, "ThreadC"); nOS_Start(SysTick_Init); while (1) { nOS_SemGive(&semC); } }
int main() { nOS_Init(); nOS_ThreadSetName(NULL, "main"); SystemCoreClockUpdate(); SysTick_Config(SystemCoreClock / NOS_CONFIG_TICKS_PER_SECOND); nOS_SemCreate(&semA, 0, 1); nOS_SemCreate(&semB, 0, 1); nOS_SemCreate(&semC, 0, 1); nOS_ThreadCreate(&threadA, ThreadA, 0, stackA, THREAD_STACK_SIZE, NOS_CONFIG_HIGHEST_THREAD_PRIO, NOS_THREAD_READY, "ThreadA"); nOS_ThreadCreate(&threadB, ThreadB, 0, stackB, THREAD_STACK_SIZE, NOS_CONFIG_HIGHEST_THREAD_PRIO-1, NOS_THREAD_READY, "ThreadB"); nOS_ThreadCreate(&threadC, ThreadC, 0, stackC, THREAD_STACK_SIZE, NOS_CONFIG_HIGHEST_THREAD_PRIO-2, NOS_THREAD_READY, "ThreadC"); while (1) { nOS_SemGive(&semC); } }
int main(int argc, char *argv[]) { nOS_Init(); nOS_ThreadSetName(NULL, "main"); nOS_SemCreate(&semA, 0, 1); nOS_SemCreate(&semB, 0, 1); nOS_SemCreate(&semC, 0, 1); nOS_ThreadCreate(&threadA, ThreadA, NULL, &stackA, 0, NOS_CONFIG_HIGHEST_THREAD_PRIO, NOS_THREAD_READY, "ThreadA"); nOS_ThreadCreate(&threadB, ThreadB, NULL, &stackB, 0, NOS_CONFIG_HIGHEST_THREAD_PRIO-1, NOS_THREAD_READY, "ThreadB"); nOS_ThreadCreate(&threadC, ThreadC, NULL, &stackC, 0, NOS_CONFIG_HIGHEST_THREAD_PRIO-2, NOS_THREAD_READY, "ThreadC"); nOS_Start(NULL); while (true) { nOS_Print("%s running\n", nOS_ThreadGetName(NULL)); nOS_SemGive(&semC); } }
nOS_Error nOS_SignalSend (nOS_Signal *signal, void *arg) { nOS_Error err; nOS_StatusReg sr; #if (NOS_CONFIG_SAFE > 0) if (signal == NULL) { err = NOS_E_INV_OBJ; } else #endif { nOS_EnterCritical(sr); #if (NOS_CONFIG_SAFE > 0) if (signal->state == NOS_SIGNAL_DELETED) { err = NOS_E_INV_OBJ; } else #endif { if (signal->state & NOS_SIGNAL_RAISED) { err = NOS_E_OVERFLOW; } else { signal->state = (nOS_SignalState)(signal->state | NOS_SIGNAL_RAISED); signal->arg = arg; nOS_AppendToList(&_signalList, &signal->node); err = nOS_SemGive(&_signalSem); if (err != NOS_OK) { signal->state = (nOS_SignalState)(signal->state &~ NOS_SIGNAL_RAISED); nOS_RemoveFromList(&_signalList, &signal->node); } } } nOS_LeaveCritical(sr); } return err; }
void nOS_TimerTick (void) { nOS_SemGive(&_timerSem); }