Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

Task priority problem on PIC24

Posted by quatoria on March 15, 2015

Dear All,

I am using FreeRTOS version 7.5.2 since about 2 years without any problem on PIC24F, until I decided for some technical reasons to change task priority, if all my task has same priority NO problem, if the task ( or any task) has lowest priority than the others , this task never start, if you can give some way to search or debug in my complex source file, it will be fine.

here my a part of my main source code :

xTaskCreate( vTaskCOM1Process,( signed char * )"C1P", configMINIMALSTACKSIZE*2,NULL, 3,NULL); xTaskCreate( vTaskCOM2Process,( signed char * )"C2P", configMINIMALSTACKSIZE,NULL, 3,NULL); xTaskCreate( vTaskStartP24,( signed char * )"CCP", configMINIMALSTACKSIZE,NULL, 5,NULL);

xTaskCreate( vTaskPOOLAnalog,( signed char * )"CANA", configMINIMALSTACKSIZE*2,NULL,2,NULL);

vTaskSerial1Start();

vTaskSerial2Start();

vTaskStartScheduler();

The vTaskPOOLAnalog with priority 2 never start !

Regards David


Task priority problem on PIC24

Posted by edwards3 on March 15, 2015

If a higher priority task never blocks (calls a delay function, or waits for queue data or semaphore etc) then lower priority tasks will be 'starved', meaning they wont ever be scheduled.


Task priority problem on PIC24

Posted by quatoria on March 15, 2015

Dear,

My higher priority task looks like this :

void vTaskCOM2Process( void * pvParameters ) { COMfifonode comget; for (;;) { if( xSemaphoreTake( xCOM2fifo_protect,0) == pdPASS ) { /// undisclosed code

   xSemaphoreGive(xCOM2_fifo_protect);

} else { taskYIELD(); } } }

is there is any problem here ?

Rgds


Task priority problem on PIC24

Posted by edwards3 on March 15, 2015

is there is any problem here ?

Yes. This code is using 0 as the block time so is not waiting for the semaphore. It will just spin round the loop very quickly, not letting lower priority tasks run. The taskYIELD() will let tasks that have the same priority run, but that is all. If you use a block time in your call to xSemaphoreTake() it should fix your problem.

Look at the xTicksToWait parameter http://www.freertos.org/a00122.html


Task priority problem on PIC24

Posted by quatoria on March 15, 2015

And how to determine block time ?, for my understand any value should be fine since as soon as semaphore is free to use the test will succeed.


Task priority problem on PIC24

Posted by edwards3 on March 15, 2015

If the task has nothing to do until it has the semaphore then use portMAX_DELAY, which will leave it in the blocked state as long as possible.


Task priority problem on PIC24

Posted by richard_damon on March 15, 2015

The basic problem is that Yield doesn't block, it only lets other tasks of the same priority run before you.

Since all you are doing on the Semaphore take is yielding, you might as well put in a block time and let the task just block until the semaphore is given.

The block time could be set to the max, or if you want to have some error recovery, make it longer than you every should need to wait, and then you have the option of seeing if you see signs of problems before retrying.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists