Part Number: TMS320C6748
Please don't say 'never' !!!
Clearly it would be reckless to call pend() from outside a task if it is going to block, but is it OK to call it provided the count is 1 or more so it will not block? Currently, I have a program doing this and it works, but I want to be sure it's safe and I'm not just being lucky.
If you're curious why anyone would do such a bizarre thing, this is how it came about. The program uses SPI1 to access two different devices (flash memory and an ADC) from two different tasks, and needs to guarantee exclusive access to the SPI so it uses a semaphore with an initial count of 1 as a mutex. So far, so good. Then it turns out we need to read something from the flash from main, before the call to BIOS_start(); The function that reads the flash pends on a semaphore, reads flash, then posts the semaphore. So (without realising, initially) that function is called once from main, and then repeatedly later on from a task.
And it works! But should it? Needless to say, I could restructure the program if I have to, but it's a huge upheaval at this stage.
In reply to ToddMullanix:
In reply to Roy Jackson:
Oh cool! Thanks. I didn't know about BIOS_getThreadType()
That is excellent, thanks, I can work with that.
All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.