How does FreeRTOS allocate more service time (CPU cycles) to higher priority level task?
Posted: Sun Aug 27, 2023 2:55 pm
I have been experimenting with the following setup (Fig-1) and the sketch to understand the mechanism of FreeRTOS in allocating more time to Task11 (with higher priority level 2) than Tasks10 with priority level 1. Would appreciate you explain this mechanism.
Sketch:
Sketch:
- TaskHandle_t Task10Handle;
- TaskHandle_t Task11Handle;
- void setup()
- {
- Serial.begin(115200);
- analogReadResolution(12);
- xTaskCreatePinnedToCore(Task10, "Task-10", 2048, NULL, 1, &Task10Handle, 1);
- xTaskCreatePinnedToCore(Task11, "Task-11", 2048, NULL, 2, &Task11Handle, 1);
- }
- void loop() {}
- void Task10(void *pvParameters)
- {
- while (true)
- {
- int analogValue34 = analogRead(34);
- Serial.print("ADC1_6: "); Serial.println(analogValue34);
- vTaskDelay(pdMS_TO_TICKS(1000)); //
- }
- }
- void Task11(void *pvParameter)
- {
- while (true)
- {
- int analogValue35 = analogRead(35);
- Serial.print("ADC1_7: "); Serial.println(analogValue35);
- vTaskDelay(pdMS_TO_TICKS(1000)); //
- }
- }