Hello
i have test task where i = 0; i++ and
when i ==5 i need to start new task with "while(1)"
and when i==10 i need to break this "while"
with the help of semaphore, it's hard to get it
help me please use the "event"
I tried to understand, but I could not get
Please check the code and fix the problemm
#include <xdc/std.h> #include <xdc/runtime/System.h> /* BIOS Header files */ #include <ti/sysbios/BIOS.h> #include <ti/sysbios/knl/Clock.h> #include <ti/sysbios/knl/Task.h> #include <ti/sysbios/knl/Semaphore.h> #include <ti/drivers/Power.h> #include <ti/drivers/power/PowerCC26XX.h> #include "Board.h" #define TASKSTACKSIZE 768 //PIN_Handle pinHandle = NULL; Task_Struct task0Struct, task1Struct, task2Struct; Char task0Stack[TASKSTACKSIZE], task1Stack[TASKSTACKSIZE], task2Stack[TASKSTACKSIZE]; Task_Handle uartTask, vmTask, stopTask; Semaphore_Struct sem0Struct, sem1Struct; Semaphore_Handle startVmSem; Semaphore_Handle stopVmSem; Void uartFxn(UArg a0, UArg a1){ uint32_t i = 0; while(1){ i++; System_flush(); System_printf(" %d", i); if(i==5){ Semaphore_post(startVmSem); } if(i==10){ Semaphore_post(stopVmSem); } Task_sleep(1000000 / Clock_tickPeriod); } } void vmFxn(void){ uint32_t i=0; while(1){ Semaphore_pend(startVmSem, BIOS_WAIT_FOREVER); while(1){ if(1){ i++; System_flush(); System_printf(" <i=%d>", i); } else { Semaphore_pend(stopVmSem, BIOS_WAIT_FOREVER); break; } } } } /* * ======== main ======== */ int main(void) { Task_Params taskParams; Semaphore_Params semParams; /* Call board init functions */ Board_initGeneral(); /* Construct BIOS objects */ Task_Params_init(&taskParams); taskParams.stackSize = TASKSTACKSIZE; taskParams.stack = &task0Stack; taskParams.priority = 2; taskParams.instance->name = "vmFxn"; Task_construct(&task0Struct, (Task_FuncPtr)vmFxn, &taskParams, NULL); vmTask = Task_handle(&task0Struct); taskParams.stack = &task1Stack; taskParams.priority = 1; taskParams.instance->name = "uartFxn"; Task_construct(&task1Struct, (Task_FuncPtr)uartFxn, &taskParams, NULL); uartTask = Task_handle(&task1Struct); Semaphore_Params_init(&semParams); semParams.mode = Semaphore_Mode_BINARY; Semaphore_construct(&sem0Struct, 0, &semParams); startVmSem = Semaphore_handle(&sem0Struct); semParams.mode = Semaphore_Mode_BINARY; Semaphore_construct(&sem1Struct, 0, &semParams); stopVmSem = Semaphore_handle(&sem1Struct); BIOS_start(); return (0); }