Quantcast
Channel: Active questions tagged operating-system+scheduling - Stack Overflow
Viewing all articles
Browse latest Browse all 211

freeRTOS Process switching

$
0
0

I tried to do a task which was to create 2 tasks. 1 task is to run cyclically every 95 ms and take 30 ms of processor time, and the second task is to run cyclically up to 33 ms and takes 15 ms of processor time. I have a problem to adjust a function so that it takes the right time given as a function parameter. Should a software timer be used or is there a function timing tool in eclipse?

main.c :

xTaskHandle task1, task2;int main(int argc, char * argv[]) {//  SystemClock_Config();HAL_Init();MX_GPIO_Init();xTaskCreate(zadanie1, "Zadanie1", 128, "to jest nazwa zadania ", 1, & task1);xTaskCreate(zadanie2, "Zadanie2", 256, "to jest nazwa zadania ", 1, & task2);vTaskStartScheduler();return 0;}

lab1.c :

int iCPU_work(int czas_obliczen_ms) {int a, b, wynik = 0;for (int i = 0; i < czas_obliczen_ms; i++) {  a++;   b++;wynik = a + b;}return wynik;}void zadanie1(void * parametry) {char nazwa_zadania[16];portTickType OstatnieWywolanie = 0;strncpy(nazwa_zadania, (char * ) parametry, 15);for (;;) {  iCPU_work(30);  LED1_TOGGLE();  vTaskDelayUntil( & OstatnieWywolanie, 95);  printf(nazwa_zadania); } vTaskDelete(NULL); // usuwa zadanie } void zadanie2(void * parametry) { portTickType OstatnieWywolanie = 0; char nazwa_zadania[16]; strncpy(nazwa_zadania, (char * ) parametry, 15); for (;;) {  iCPU_work(15);  LED2_TOGGLE();  vTaskDelayUntil( & OstatnieWywolanie, 33);  printf(nazwa_zadania);  }  vTaskDelete(NULL);  }  void vApplicationIdleHook(void) {  LED3_TOGGLE();  }  void vApplicationTickHook(void) {  LED4_TOGGLE();  }

Viewing all articles
Browse latest Browse all 211

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>