what is the function that returns an element of a list

Hi, What is the function that returns an element of a list without removing it in FreeRTOS? I need to know the first task that was added in the list pxReadyTasksLists[configMAX_PRIORITIES-1]. Thanks in advance

what is the function that returns an element of a list

The list functions are not part of the published API. I can probably tell you how to do what you want to do, but it is not clear what it is you want to do. Can you elaborate? When you say the “first task added in the list” do you mean the task that is at the front of the list, assuming tasks that were added after it are behind it in the list?

what is the function that returns an element of a list

Yes, it is the task in the front of the list. I want to know which task the scheduler will choose to execute at the next tick interrupt. It’s the task that has the highest priority, so if I’m not wrong, it’s the task in the front of the ready list that contains the highest priority.

what is the function that returns an element of a list

You cant know which task the scheduler will choose to execute at the next tick interrupt until the tick interrupt executes because you cant predict if a task will unblock. Even when the tick interrupt executes you cant predict it because other interrupts might nest with the tick interrupt and unblock other tasks.

what is the function that returns an element of a list

As already said, you can’t tell which task will be selected in advance of it actually being selected, then you need to know which list to look in. Which list to look in depends on the highest priority ready state task, which if you are using a port that supports port optimised task selection is determined by calling portGETHIGHESTPRIORITY() (that will use a count leading zero type instruction). Once you know which list to look in you call listGETOWNEROFNEXTENTRY() to obtain the next TCB. Look at the definition of taskSELECTHIGHESTPRIORITY_TASK() near the top of FreeRTOS/source/tasks.c to see how the macros are used. Regards.

what is the function that returns an element of a list

Thank you for your answer. This is exactly what I wanted.