Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.02 KB | None | 0 0
  1. void taskSELECT_HIGHEST_PRIORITY_TASK(){
  2.     UBaseType_t EDFPriority = 1;
  3.    
  4.     TCB_t *tempTCB, *minTCB;
  5.    
  6.     int testCounter = 0;
  7.     int length = listCURRENT_LIST_LENGTH(&(pxReadyTasksLists[EDFPriority]));
  8.    
  9.     int minToEnd = -1;
  10.    
  11.     for(int i=0; i<length; i++) {
  12.         listGET_OWNER_OF_NEXT_ENTRY(tempTCB, &(pxReadyTasksLists[EDFPriority]));
  13.        
  14.         int tickPassed = xTickCount - tempTCB->start_time;
  15.        
  16.         if (tickPassed >= 0 && tickPassed % tempTCB->period == 0){
  17.             tempTCB->pxTopOfStack = pxPortInitialiseStack( tempTCB->myStackVar, theFunc, tempTCB->pvParameter);
  18.             tempTCB->run_time = 0;
  19.         }
  20.        
  21.         if (tickPassed >= 0 && tempTCB->run_time < tempTCB->work_time) {
  22.            
  23.             int untilEnd = tempTCB->period - tickPassed % tempTCB->period;
  24.            
  25.             if (minToEnd == -1 || untilEnd < minToEnd) {
  26.                 minToEnd = untilEnd;
  27.                 minTCB = tempTCB;
  28.             }
  29.         }
  30.     }
  31.    
  32.     if (minToEnd == -1) {
  33.         pxCurrentTCB = listGET_OWNER_OF_HEAD_ENTRY(&( pxReadyTasksLists[0]));
  34.     } else {
  35.         minTCB->run_time++;
  36.         pxCurrentTCB = minTCB;
  37.     }
  38.     return;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement