Suspending a higher priority Task

sanhardik wrote on Monday, March 16, 2015:

Dear All,
We are trying a code on Atmel SAM D21 for FreeRTOS. We have defined 2 tasks, one is a UART task that writes a string on the terminal and other one toggles a LED.
The UART task has a higher priority than the LED task.
When the UART task is suspended using vTaskSuspend(uart_task_handle), the LED task which has a lower priority doesnt execute.

Is this expected ?

Thanks

rtel wrote on Monday, March 16, 2015:

If the two tasks are independent then, no, that is not expected.

Does the LED task run when the UART task is not suspended?

Regards.

embeddedindia wrote on Tuesday, March 17, 2015:

Hi All,
I also found similar issue on SAMD21 Evaluation Board with FreeRtos.

case 1: Uart_Task_priority ==> 1 & LED_Task_Priority ==> 2
Handler is Declared but not assigned to any task.
both the task didn’t execute with suspending the handler

case 2: Uart_Task_priority ==> 2 & LED_Task_Priority ==> 1
Handler is Declared but not assigned to any task.
LED_Task is executed. But, Uart_Task is not executed.
with suspending the handler.

case 3: Uart_Task_priority ==> 2 & LED_Task_Priority ==> 1
Handler is Declared but not assigned to any task.
both the task didn’t execute.
without suspending the handler

case 4: USR_TASK_PRIORITY ===> 3 Uart_Task_priority ==> 2 & LED_Task_Priority ==> 1
handler is assigned to USR_Task
LED_Task & Uart_Task executed.
with suspending the handler.

case 5: USR_TASK_PRIORITY ===> 1 Uart_Task_priority ==> 2 & LED_Task_Priority ==> 3
handler is assigned to USR_Task
Uart_Task is executed. But, LED_Task is not executed.
with suspending the handler.

case 6: USR_TASK_PRIORITY ===> 1 Uart_Task_priority ==> 3 & LED_Task_Priority ==> 2
handler is assigned to USR_Task
LED_Task is executed. But, Uart_Task is not executed.
with suspending the handler.

case 7: USR_TASK_PRIORITY ===> 1 Uart_Task_priority ==> 3 & LED_Task_Priority ==> 2
handler is assigned to USR_Task
LED_Task is executed. But, Uart_Task is not executed.
without suspending the handler.

case 8: USR_TASK_PRIORITY ===> 1 Uart_Task_priority ==> 2 & LED_Task_Priority ==> 3
handler is assigned to USR_Task
Uart_Task is executed. But, LED_Task is not executed.
without suspending the handler.

please helpme out in fixing these issue.

Thank you

edwards3 wrote on Tuesday, March 17, 2015:

What do you mean “Handler is Declared but not assigned to any task” and “handler is assigned to USR_Task”, etc? What handler? Could you have a buggy UART driver? Did you try with a simple polling driver in place of whatever you are using now?

embeddedindia wrote on Thursday, March 19, 2015:

static xTaskHandle terminal_task_handle; // Declaration of task handler

xTaskCreate(task_USR,(const char *) “USR”,configMINIMAL_STACK_SIZE,NULL,USR_TASK_PRIORITY,terminal_task_handle);

xTaskCreate(task_uart,(const char *) “Uart”,configMINIMAL_STACK_SIZE,NULL,UART_TASK_PRIORITY,NULL);

xTaskCreate(led_task,(const char *) “LED”,configMINIMAL_STACK_SIZE,NULL,LED_TASK_PRIORITY,NULL);

Initially, task_uart & led_task was created to which the handler was not assigned. To further understand we created one more task i.e. task_USR to which we assigned handler. so that we can suspend or resume the task. But, presently we are only suspending the task_USR not resuming it back ever.