task not switching

seek25 wrote on Wednesday, March 16, 2016:

Hello,

I have 4 tasks all of the same priority, cortex M4. No task uses freeRTOS functions.

Once task A is executed it never gets pre-empted. It just gets executed over and over starving the other.

FreeRTOS is 7.3.0 and thre is no definition about time slice in the freertosconfig.h file.

How was that supposed to work?

Thanks.

IC

Edit:

From here: http://www.freertos.org/FAQSched.html

How are tasks of equal priority scheduled?
Round robin - Ready state tasks that share a priority “take turns” to run.

edwards3 wrote on Wednesday, March 16, 2016:

Sounds like the tick interrupt might not be running. Put a break point on xTaskIncrementTick in Task.c, is it hit?

seek25 wrote on Wednesday, March 16, 2016:

Just found this, since it is not defined it should switch between them.

configUSE_TIME_SLICING
By default (if configUSE_TIME_SLICING is not defined, or if configUSE_TIME_SLICING is defined as 1) FreeRTOS uses prioritised preemptive scheduling with time slicing. That means the RTOS scheduler will always run the highest priority task that is in the Ready state, and will switch between tasks of equal priority on every RTOS tick interrupt. If configUSE_TIME_SLICING is set to 0 then the RTOS scheduler will still run the highest priority task that is in the Ready state, but will not switch between tasks of equal priority just because a tick interrupt has occurred.

seek25 wrote on Wednesday, March 16, 2016:

There is no xTaskIncrementTick in tasks.c

However this gets called and increments

  • Calculate the time to wake - this may overflow but this is
    not a problem. */
    xTimeToWake = xTickCount + xTicksToDelay;

seek25 wrote on Wednesday, March 16, 2016:

	uxCurrentNumberOfTasks	6	volatile unsigned long(static storage at address 0x20010efc.

)

6 tasks? I have 4 and adding the idle task will make 5, why 6 evaluated at signed portBASE_TYPE xTaskResumeAll( void )

			while( listLIST_IS_EMPTY( ( xList * ) &xPendingReadyList ) == pdFALSE )
			{

uxNumberOfItems = 0

the below
pxTCB = ( tskTCB * ) listGET_OWNER_OF_HEAD_ENTRY( ( ( xList * ) &xPendingReadyList ) );
uxListRemove( &( pxTCB->xEventListItem ) );
never reached

rtel wrote on Thursday, March 17, 2016:

Why are you using such an old version? I think in that version the function will be called vTaskIncrementTick() (v prefix instead of x prefix).

The additional task might be the timer service task - that will be the case if you have configUSE_TIMERS set to 1.