Created
March 28, 2015 09:07
-
-
Save good5dog5/3224d7b23a6779e8dd65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// workspace/visualizer/main.c | |
void trace_task_switch(void *prev_task, unsigned int prev_tick, void *curr_task) | |
{ | |
char buf[128]; | |
int len = snprintf(buf, 128, "switch %d %d %d %d %d %d\n", | |
prev_task, curr_task, | |
xTaskGetTickCount(), get_reload(), | |
prev_tick, get_current()); | |
write(logfile, buf, len); | |
} | |
// workspace/visuallizer/FreeRTOSConfig.h | |
// define an alias of trace_task_switch() | |
#define traceTASK_SWITCHED_IN() \ | |
if (pxPreviousTCB != pxCurrentTCB) { \ | |
trace_task_switch(pxPreviousTCB, \ | |
previous_systick_current, \ | |
pxCurrentTCB); \ | |
} | |
// workspace/freertos-basic/freertos/libraries/FreeRTOS/task.c | |
// vTaskSwitchCountext() | |
/* Find the highest priority queue that contains ready tasks. */ | |
while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopReadyPriority ] ) ) ) | |
{ | |
configASSERT( uxTopReadyPriority ); | |
--uxTopReadyPriority; | |
} | |
/* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the tasks of the | |
same priority get an equal share of the processor time. */ | |
listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) ); | |
traceTASK_SWITCHED_IN(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment