void ATask(void) { printString("Task A started!\n"); printString("Creating low priority task B...\n"); YKNewTask(BTask, (void *)&BStk[BSTACKSIZE], 7); printString("Creating task C...\n"); YKNewTask(CTask, (void *)&CStk[CSTACKSIZE], 2); printString("Task A is still running! Oh no! Task A was supposed to stop.\n"); exit(0); }
void main(void) { YKInitialize(); newPieceSEM = YKSemCreate(0); receivedSEM = YKSemCreate(1); YKNewTask(STask, (void *) &STaskStk[TASK_STACK_SIZE], 0); YKNewTask(handleNewPieceTask, (void *) &NewPieceHandlerTaskStk[TASK_STACK_SIZE], 1); YKNewTask(handleSendMovementTask, (void *) &SendMovementHandlerTaskStk[TASK_STACK_SIZE], 2); MsgQPtr = YKQCreate(MsgQ, MSGQSIZE); YKRun(); }
void YKInitialize(void){ YKEnterMutex(); //Create Idle task and add it to the ready queue //printString("YKInitialize\n"); YKNewTask(&YKIdleTask, (void *)&idleStk[IDLE_STACK_SIZE], 100); //new task adds to queue for us }
//Initalizing code ----------------------------------------------------------------------------- void YKInitialize() { //Initializes all required kernel data structures int i; YKEnterMutex(); //Initalize the YKAvailTCBList queue YKAvailTCBList = &(YKTCBArray[0]); for (i = 0; i < MAXTASKS; i++) { if(i != 0) { YKTCBArray[i].prev = &(YKTCBArray[i-1]); } YKTCBArray[i].next = &(YKTCBArray[i+1]); } YKTCBArray[0].prev = NULL; YKTCBArray[MAXTASKS].next = NULL; if(MAXTASKS > 0) { YKTCBArray[MAXTASKS].prev = &(YKTCBArray[MAXTASKS - 1]); } YKReadyList = NULL; YKSuspList = NULL; nestedInterruptLevel = 0; curTask = NULL; YKNewTask(YKIdleTask, (void *)&IdleStk[IDLESTACKSIZE], 100); }
void YKInitialize(void) { // Init Tasks void (*idle_task_p)(void); void *idle_task_stack_p; int lowest_priority = 100; YKCtxSwCount = 0; YKTickNum = 0; YKIdleCount = 0; YKISRDepth = 0; YKRunFlag = 0; YKBlockList = 0; YKRdyList = NULL; YKCurrTask = NULL; idle_task_p = YKIdleTask; idle_task_stack_p = YKIdleTaskStack + IDLE_STACK_SIZE - 1; lowest_priority = 100; YKErrorFlag = 0; // Init Semaphores YKAvailSEMList = YKSEMArray; // Init Queues YKQAvailQList = YKQArray; // Init Events YKAvailEventList = YKEventArray; // Finish YKAvailTCBList = YKTCBArray; YKNewTask(idle_task_p, idle_task_stack_p, lowest_priority); }
void YKInitialize(){ int i; YKEnterMutex(); YKIMRInit(0x00); running = 0; YKIdleCount = 0; YKCtxSwCount = 0; YKCurTask = NULL; YKRdyList = NULL; YKSuspList = NULL; nestingLevel = 0; YKTickNum = 0; YKAvaiSems = MAXSEMS; // Initialize locations for TCB YKAvailTCBList = &(YKTCBArray[0]); for (i = 0; i < MAXTASKS; i++){ YKTCBArray[i].next = &(YKTCBArray[i+1]); YKTCBArray[MAXTASKS].prev = NULL; } YKTCBArray[MAXTASKS].next = NULL; YKTCBArray[MAXTASKS].prev = NULL; YKNewTask(YKIdleTask,(void *) &(idleStk[IDLE_STACK_SIZE]),100); }
void main(void) { YKInitialize(); printString("Creating task A...\n"); YKNewTask(ATask, (void *)&AStk[ASTACKSIZE], 5); printString("Starting kernel...\n"); YKRun(); }
void main(void) { YKInitialize(); printString("Creating task...\n"); YKNewTask(Task, (void *) &TaskStack[STACKSIZE], 0); printString("Starting kernel...\n"); YKRun(); }
void main(void) { YKInitialize(); charEvent = YKEventCreate(0); numEvent = YKEventCreate(0); YKNewTask(STask, (void *) &STaskStk[TASK_STACK_SIZE], 0); YKRun(); }
void TaskStat(void) /* a task to track statistics */ { unsigned max, switchCount, idleCount; int tmp; YKDelayTask(1); printString("Welcome to the YAK kernel\r\n"); printString("Determining CPU capacity\r\n"); YKDelayTask(1); YKIdleCount = 0; YKDelayTask(5); max = YKIdleCount / 25; YKIdleCount = 0; YKNewTask(TaskPrime, (void *) &TaskPRMStk[TASK_STACK_SIZE], 32); YKNewTask(TaskWord, (void *) &TaskWStk[TASK_STACK_SIZE], 10); YKNewTask(TaskSpace, (void *) &TaskSStk[TASK_STACK_SIZE], 11); YKNewTask(TaskPunc, (void *) &TaskPStk[TASK_STACK_SIZE], 12); while (1) { YKDelayTask(20); YKEnterMutex(); switchCount = YKCtxSwCount; idleCount = YKIdleCount; YKExitMutex(); printString ("<<<<< Context switches: "); printInt((int)switchCount); printString(", CPU usage: "); tmp = (int) (idleCount/max); printInt(100-tmp); printString("% >>>>>\r\n"); YKEnterMutex(); YKCtxSwCount = 0; YKIdleCount = 0; YKExitMutex(); } }
void STask(void) /* tracks statistics */ { unsigned max, switchCount, idleCount; int tmp; YKDelayTask(1); printString("Welcome to the YAK kernel\r\n"); printString("Determining CPU capacity\r\n"); YKDelayTask(1); YKIdleCount = 0; YKDelayTask(5); max = YKIdleCount / 25; YKIdleCount = 0; YKNewTask(CharTask, (void *) &CharTaskStk[TASK_STACK_SIZE], 2); YKNewTask(AllNumsTask, (void *) &AllNumsTaskStk[TASK_STACK_SIZE], 1); YKNewTask(AllCharsTask, (void *) &AllCharsTaskStk[TASK_STACK_SIZE], 3); while (1) { YKDelayTask(20); YKEnterMutex(); switchCount = YKCtxSwCount; idleCount = YKIdleCount; YKExitMutex(); printString("<<<<< Context switches: "); printInt((int)switchCount); printString(", CPU usage: "); tmp = (int) (idleCount/max); printInt(100-tmp); printString("% >>>>>\r\n"); YKEnterMutex(); YKCtxSwCount = 0; YKIdleCount = 0; YKExitMutex(); } }
/* * tracks statistics */ void StatTask(void) { unsigned max, switchCount, idleCount; int tmp; YKDelayTask(1); printString("Welcome to the YAK kernel\r\n"); printString("Determining CPU capacity\r\n"); YKDelayTask(1); YKIdleCount = 0; YKDelayTask(5); max = YKIdleCount / 25; YKIdleCount = 0; YKNewTask(ArrivalTask, (void *) &ArrivalTaskStk[TASK_STACK_SIZE], 25); YKNewTask(CommunicationTask, (void *) &CommunicationTaskStk[TASK_STACK_SIZE], 20); while (1) { YKDelayTask(20); YKEnterMutex(); switchCount = YKCtxSwCount; idleCount = YKIdleCount; YKExitMutex(); printString("<CS: "); printInt((int)switchCount); printString(", CPU: "); tmp = (int) (idleCount/max); printInt(100-tmp); printString(">\r\n"); YKEnterMutex(); YKCtxSwCount = 0; YKIdleCount = 0; YKExitMutex(); } }
void main(void) { YKInitialize(); /* create all semaphores, at least one user task, etc. */ PSemPtr = YKSemCreate(1); SSemPtr = YKSemCreate(0); WSemPtr = YKSemCreate(0); NSemPtr = YKSemCreate(0); YKNewTask(TaskStat, (void *) &TaskStatStk[TASK_STACK_SIZE], 30); YKRun(); }
void main(void) { scmdarrIdx = 0; PieceArrayIndex = 0; YKInitialize(); YKNewTask(StatTask, (void *) &StatTaskStk[TASK_STACK_SIZE], 10); commandReceivedSem = YKSemCreate(0); touchdownSem = YKSemCreate(1); CmdQPtr = YKQCreate(CmdQ, CMDQSIZE); NewPieceQPtr = YKQCreate(NewPieceQ, PIECEQSIZE); YKRun(); }
void YKInitialize(void) { // Code to initialize global variables YKCtxSwCount = 0; YKIdleCount = 0; YKTickNum = 0; YKRun = 0; // Code to create doubly linked list YKAvailTCBList = &(YKTCBArray[0]); for (i = 1; i < MAX_TASKS; i++) { YKTCBArray[i].next = &(YKTCBArray[i+1]); YKTCBArray[i].prev = &(YKTCBArray[i-1]); } YKTCBArray[MAX_TASKS].next = NULL; YKTCBArray[0].prev = NULL; YKNewTask(YKIdleTask, (void *)&YKIdleTask[IDLE_TASK_STACK_SIZE], MAX_TASKS); }
void YKInitialize(void) { YKEnterMutex(); //Set up queues initializePriorityQueue(&readyQueue); initializeDelayQueue(); //Set up Task Block taskBlock.nextFreeTCB == 0; // //Set up Idle Task YKNewTask(YKIdleTask, &idleTaskStack[IDLETASKSTACKSIZE], 100); // YKExitMutex(); return; }
void YKInitialize() { /* Initializes all required kernel data structures */ int i; TCBptr tempList; // printString("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); activeTasks = 0; YKCtxSwCount = 0; YKIdleCount = 0; YKTickNum = 0; /* Set up TCB Lists */ YKRdyList = NULL; YKSuspList = NULL; runningTask = NULL; YKAvailTCBList = YKTCBArray; YKTCBArray[0].prev = NULL; for(i = 0; i < MAXTASKS; i++){ /* put the YKTCBArray into the available TCB list */ // this doesn't work YKTCBArray[i].next = &YKTCBArray[i + 1]; YKTCBArray[i + 1].prev = &YKTCBArray[i]; } // Creates idle task YKNewTask(YKIdle, (void*)&IStk[ISTACKSIZE],255); }