about xTaskIncrementTick context switch?

daiyinger
Posts: 6
Joined: Tue Oct 31, 2017 2:02 pm

about xTaskIncrementTick context switch?

Postby daiyinger » Mon May 07, 2018 8:15 am

anyone understand the comments below ? in function BaseType_t xTaskIncrementTick( void )
/* ToDo: This doesn't really play nice with the logic below: it means when core 1 is
running a low-priority task, it will keep running it until there is a context
switch, even when this routine (running on core 0) unblocks a bunch of high-priority
tasks... this is less than optimal -- JD. */

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: about xTaskIncrementTick context switch?

Postby ESP_igrr » Mon May 07, 2018 12:57 pm

The situation is like this:

1. High priority task T1, pinned to CPU1 is in blocked state (e.g. waiting on a xQueueReceive)
2. Lower priority task T2 is running on CPU1
3. Tick interrupt on CPU0 calls xTaskIncrementTick, which unblocks T1 (by making xQueueReceive timeout expire).

Result (with the current logic in xTaskIncrementTick) is that T1 does not start running immediately, and T2 continues to run. T1 will start running when either of the following happens:

a) Tick interrupt occurs on CPU1 (tick interrupts on the two CPUs are not synchronized, so anywhere between 0 and portTICK_PERIOD_MS can pass until then)
b) T2 blocks or otherwise yields
c) Interrupt happens on CPU1, and interrupt handler calls portYIELD_FROM_ISR()

ESP_Sprite
Posts: 9711
Joined: Thu Nov 26, 2015 4:08 am

Re: about xTaskIncrementTick context switch?

Postby ESP_Sprite » Tue May 08, 2018 3:20 am


daiyinger
Posts: 6
Joined: Tue Oct 31, 2017 2:02 pm

Re: about xTaskIncrementTick context switch?

Postby daiyinger » Tue May 08, 2018 9:20 am

thanks, I get it.

Who is online

Users browsing this forum: Majestic-12 [Bot], sayid_ehd and 71 guests