Blocking waits in FreeRTOS? (and 2 other Q's)
Posted by Nobody/Anonymous on November 27, 2004
I'm quite interested in the FreeRTOS project (and thank you for your effort!).
However, I was wondering why the timer tick is not a (signed) long so that a -1 can be used for a forever wait (blocking read)?
At the moment if I want to block forever I cannot. I must pass it ULONG_MAX but expect to wake up in about 42 days with a 1KHz tick (or 420 days with 10ms tick).
At any rate, anyone that can live with blocking for many days (if that's what they want) can also live with "many days"/2 (by using signed).
But for folks where "many days" == forver, I now don't have to put code everywhere to check of my call came back due to a timeout and now I have to call it again!
ALSO (2nd Q):
Is the timer tick over flow handled properly in the kernel? Since even a 10ms tick will result in 400+ days before overflow, if not checked explicitely a problem with it may have gone un-noticed.
ALSO (3rd Q :):
Why no timer functionality in FreeRTOS?
RE: Blocking waits in FreeRTOS? (and 2 other Q's)
Posted by Richard
on November 27, 2004
This was a decision I made mainly based on the efficiency of the list implementation (which is fairly fundamental to the kernel). The way the implementation is, a "wait forever" tasks would have to be stored outside of the blocked list - requiring resources for another structure.
All blocking calls return a value that can be used to determine whether the block was successful or not - so I think it is ok to put an if() around the block to see why the call returned with very little overhead.
There cannot be many tasks in real world applications that are going to run less often than "every 400 days". You can always extend the call to have a block forever option if you wish - a benefit of open source.
What is best is obviously a matter of opinion, and what is best of one application will not be for another.
Q2 - This mechanism was tested by initialising the tick to a large value to start with - rather than 0.
Q3 - FreeRTOS is a minimal kernel, but (hopefully) easy to extend should you wish. The building blocks required for the majority of applications are in place. Should you wish to add features then this should be straight forward.
One aim of FreeRTOS is to keep everything as simple as possible. Adding more features increases the code size, necessitating more configuration options and less readability. Having said that it will grow as required over time whatever.
Not all commercial RTOS's have every feature of every other.
All these things are of coarse just "in my opinion".
Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd..
See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.