Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

need explanation for following system tick code of FreeRTOS

Status
Not open for further replies.

saochandan

Junior Member level 1
Joined
Mar 13, 2012
Messages
19
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,409
Can anybody explain the following code of FreeRTOS clearly.

Code:
/* Find the highest-priority queue that contains ready tasks. */
while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopReadyPriority ] ) ) )
{
    configASSERT( uxTopReadyPriority );
    --uxTopReadyPriority;
}

/* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the tasks of the same 
priority get an equal share of the processor time. */
listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) );

thanks
 

As I understood from analyzing this piece of code:

"pxReadyTasksLists[]" is an array of lists... each array position is a priority level, meaning that at each position there is a list of equal priority tasks witch are ready (although I don't understand the meaning of ready here)..

"listLIST_IS_EMPTY()" is a function that checks if a given list Is Empty, meaning that it will return true if the list is empty, and return false if there are tasks on the list

configASSERT() is a function that will give assertion for a given false value, and as a value equal to 0 is false and a value different from 0 is true, it will give assertion for uxTopReadyPriority equal to 0, meaning that will assert when priority level zero is reached...


Code C - [expand]
1
2
3
4
5
6
/* Find the highest-priority queue that contains ready tasks. */
while( listLIST_IS_EMPTY( &( pxReadyTasksLists[ uxTopReadyPriority ] ) ) )
{
    configASSERT( uxTopReadyPriority );  // returns Assertion when top ready priority == 0
    --uxTopReadyPriority;
}



the above while cycle will run while the list of ready tasks of the current cycle's priority level is empty.. level will decrement each cycle, and assertion will happen when priority level reaches zero.. the loop will exit when a not empty list is reached.. at this point, the priority level with ready tasks is found and kept at "uxTopReadyPriority", and the tasks can now be processed..

"listGET_OWNER_OF_NEXT_ENTRY( , )" is a function that returns the next element of a given list, meaning that will return the next task of the priority level defined in the above loop ...


Code C - [expand]
1
2
3
/* listGET_OWNER_OF_NEXT_ENTRY walks through the list, so the tasks of the same 
priority get an equal share of the processor time. */
listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) );




.....
next time that systick run, if there are no higher priority levels then the previous cycle higher priority level found, the listGET_OWNER_OF_NEXT_ENTRY() will process the next task in the list, meaning that equal priority tasks will share equally the processor time..

---------- Post added at 02:42 ---------- Previous post was at 02:21 ----------

I've been googling for some answers to your thread..

The whole link I'm providing to you is delicious but check at least chapter 3.3
https://www.aosabook.org/en/freertos.html

here is the books references
https://www.aosabook.org/en/index.html
 
Thank you so much for answer and link you provided. Its really helpful

(although I don't understand the meaning of ready here).. here ready means "ready tasks" which are in ready state and can be executed by cpu on getting their turn that depends upon their priority.
 

thank you for the clarification,
here ready means "ready tasks" which are in ready state and can be executed by cpu on getting their turn that depends upon their priority

I also assumed that.. what I don't understand is what qualifies a task to be ready.. Is it some kind of sync signal?...
 

I am sorry to say I am new to RTOS and don't have much clear idea over it's concepts.

However, from my point of view
what qualifies a task to be ready.. Is it some kind of sync signal?...

It depends upon the need of task that when it would be executed. For example, if we want to execute a particular task after some delay of time
then that task has to wait for that period. For that period of time that task has to wait for accessing the resources(cpu, memory..). So for that period of time that task will be said as blocked task which is not ready to be executed. As that period passes that task qualifies to become a ready task.

Similarly there are various situations when a particular task has to stay in states other then "ready state" and need to wait for occurring some event or interrupt.

Hope this much explanation can give you some clarification.
I'll look forward to you if you get some more explanation on this.

Thanks
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top