FreeRTOS kernel code problem

zhudinum1 wrote on Monday, November 18, 2013:

why use variable xPendingReadyList in the source code ? it can insert ready task into readylist directly without causing any safe problems. very appreciate for your answering in time!

rtel wrote on Monday, November 18, 2013:

xPendingReadyList is used to temporarily hold tasks that have been moved into the Ready state by an interrupt while the scheduler was locked. Its use allows interrupts to remain enabled when the scheduler is locked. Scheduler locking is a lighter form of critical section that prevents the kernel from performing context switches. The alternative is to use a full critical section, but that would mean at least a subset of interrupt priorities would be masked.

Regards.

zhudinum1 wrote on Tuesday, November 19, 2013:

Ok thank you! But why we can not insert the tasks that have been moved into the Ready into the pxReadyTasksLists directly while the scheduler was locked? In the security considerations ?

Regards

richard_damon wrote on Tuesday, November 19, 2013:

Locking the scheduler is one way to implement a critical section when internal state is being manipulated. If the task that locked the schedule is doing something to the ready list, the LAST thing you want to do is manipulate it yourself, the like result is a corrupted list.

zhudinum1 wrote on Tuesday, November 19, 2013:

Ok i konw! Thank you very much!