예제 #1
0
void ThreadC (void *arg)
{
	while (1) {
        nOS_SemTake(&semC, NOS_WAIT_INFINITE);
        nOS_SemGive(&semB);
	}
}
예제 #2
0
파일: main.c 프로젝트: Shashank-Rudra/nOS
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);
    }
}
예제 #3
0
void ThreadC (void *arg)
{
    while(true) {
        nOS_Print("%s running\n", nOS_ThreadGetName(NULL));
        nOS_SemTake(&semC, NOS_WAIT_INFINITE);
        nOS_SemGive(&semB);
    }
}
예제 #4
0
파일: main.c 프로젝트: Shashank-Rudra/nOS
void ThreadB (void *arg)
{
    NOS_UNUSED(arg);

    while (1) {
        nOS_SemTake(&semB, NOS_WAIT_INFINITE);
        nOS_SemGive(&semA);
    }
}
예제 #5
0
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);
    }
}
예제 #6
0
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);
    }
}
예제 #7
0
파일: main.c 프로젝트: Shashank-Rudra/nOS
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);
    }
}
예제 #8
0
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);
    }
}
예제 #9
0
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;
}
예제 #10
0
파일: nOSTimer.c 프로젝트: therafman/nOS
void nOS_TimerTick (void)
{
    nOS_SemGive(&_timerSem);
}