static void heartbeat(void) { //int count = 0; int trains_tid = whois_poll("trains"); int display_tid = whois_poll("displaysrv"); int command_tid = whois_poll("commandsrv"); for (;;) { delay(10); struct task_info trains_info, display_info, command_info; task_status(trains_tid, &trains_info); task_status(display_tid, &display_info); task_status(command_tid, &command_info); // printf("\e[s\e[1;100H%d" // "\e[1;110Hts %d" // "\e[1;120Hds %d" // "\e[1;130Hcs %d" // "\e[u", count++, trains_info.state, display_info.state, command_info.state); } }
/******************************************************************************* Name : metrics_Stack_Test Description : launch tasks to calculate the stack usage made by the driver for an Init Term cycle and in its typical conditions of use Parameters : None Assumptions : Limitations : Returns : None *******************************************************************************/ #if !defined(ST_OSLINUX) /* due to task status not yet implemented. To be done. */ static BOOL metrics_Stack_Test(STTST_Parse_t *pars_p, char *result_sym_p) { task_t *task_p; task_status_t status; int overhead_stackused; char funcname[4][20]= { "test_overhead", "test_init", "test_typical", "NULL" }; void (*func_table[])(void *) = { test_overhead, test_init, test_typical, NULL }; void (*func)(void *); int i; UNUSED_PARAMETER(pars_p); UNUSED_PARAMETER(result_sym_p); overhead_stackused = 0; printf("*************************************\n"); printf("* Stack usage calculation beginning *\n"); printf("*************************************\n"); for (i = 0; func_table[i] != NULL; i++) { func = func_table[i]; /* Start the task */ task_p = task_create(func, NULL, STACK_SIZE, MAX_USER_PRIORITY, "stack_test", task_flags_no_min_stack_size); /* Wait for task to complete */ task_wait(&task_p, 1, TIMEOUT_INFINITY); /* Dump stack usage */ task_status(task_p, &status, task_status_flags_stack_used); /* Report Error */ if(Err) printf("An error occured during the process !!!\n"); /* store overhead value */ if (i==0) { printf("*-----------------------------------*\n"); overhead_stackused = status.task_stack_used; printf("%s \t func=0x%08lx stack = %d bytes used\n", &funcname[i][0], (long) func, status.task_stack_used); printf("*-----------------------------------*\n"); } else { printf("%s \t func=0x%08lx stack = %d bytes used (%d - %d overhead)\n", &funcname[i][0], (long) func, status.task_stack_used-overhead_stackused,status.task_stack_used,overhead_stackused); } /* Tidy up */ task_delete(task_p); } printf("*************************************\n"); printf("* Stack usage calculation end *\n"); printf("*************************************\n"); return(FALSE); }