Quetions about the task scheduler

Hi Yueming,

of course I don’t know about the history of the code, but I believe the issue you raise is similar to that one here:

I tend to believe that the reasoning may be similar here: uxTopReadyPriority is only ever written to in the task selector, but read from in several other places. Without having looked at the code explicitly, it seems as if keeping it as a module level static global helps avoiding overuse of the critical section at pxReadyTasksLists access time.

The other issue, of course, is that optimized task selection is about as close to the heart of the OS as one can get, so at least I would assume that whoever tackles that issue should know (or, at the very least, very thoroughly test) what he/she is doing. Programming errors at this level tend to manifest themselves fairly soon (a profiler would probaly testify that the task selection is among the most heavily used code section in FreeRTOS). If there really have been bugs in a vendor’s adaption that you had to pinpoint, it doesn’t shed a bright light on the adaptor’s quality system (my humble opinion).

Whatever, I’m curiously waiting for Richard Barry’s answer to your query as he probably is the one who coded the selection algorithm (and as far as I can tell, he codes very deliberate and meticuluous, so there probably is a good reasons why it is as it is).