FreeRTOS Kernel

Hello Community,

Highlight on Usage

  • I am using FreeRTOS Kernel V10.0.1 in my system with NXP S32K14x series SOC.
  • We have almost 15 tasks at the application layer and out of that 1 task is very critical(With delay of 100ms) which is running on highest priority.
  • We are doing some important calculation and to acheive the prefect timing / execution cycle, We are using “vTaskDelayUntil” in that task.

Problem in Detail

  • As per requirement, At some point, We are suspending all the tasks (Task which has vTaskDelayUntil also suspending).
  • Almost after 10 minutes, We are resuming every tasks.
  • On resumption, System is trying to match the execution count, I mean system is saying we lost 10 minutes = 600 seconds = 600,000 ms / 100 ms = 6000 cycle.
  • Mean system will try to run that task for 6000 times on system resume, Which is resulting in other task on hold for long time.

Looking for solution

  • Can’t we have any simple solution like, If task is suspend then execution will be ignored?

Thanks in advance.

Regards,
Kalpesh Ramani

You can manually update the last execution time which is passed into vTaskDelay() to the current time when the task is resumed. That is the parameter that is initially set to the current time before it’s first use.

Thanks Richard for your suggestion. As its system tick, I thought let’ not manipulate the data manually.
Instead of that, I added below logic which help me to execute task on time and not disturb application when its in sleep.

static void app_100msTask( void *pvParameters )
{

	const TickType_t xFrequency = 100;
	uint32_t current_time = 0;
	uint32_t app_100_task_delay = 0;
	
	for(;;)
	{
		// User Application

		current_time = OSIF_GetMilliseconds();
		app_100_task_delay = xFrequency - (current_time % xFrequency);
		OSIF_TimeDelay(app_100_task_delay);
	}
}