Ah, I wondered if the banter my heat up a little during work time!
So, yep agree with GS. Would never touch dynamic memory allocation, just asking for trouble and doesn’t really bring anything to the party.
Programming strictly in C here, and with MQX for those OS geeks out there.
Although all the info is interesting, and given me a whole wealth of internet browsing to do, I’m not sure I’m any further forward. So how about a little example…
Looking at switch debounce. High priority task task_debounce, runs every 25mS, looks at the inputs lines and sets up rising edge stores in an OS provided event construct. Simple so far. Now, low priority task task_user_interface, occasionally looks for a rising edge. When it sees one, it updates some display things, and then wants to reset the rising edge event, sit back and wait for the next one.
So the question is, what would best practice be to reset the rising edge event?
1.Being a hardcore firmware engineer, my first thought is to disable interrupts, read/clear/write the event store, enable ints. Obviously not the way to go with an OS.
2.Maybe grab a semaphore, to gain exclusive access to the rising edge store. Then I have to worry about task_debounce not having access.
3.Send a message to task_debounce? What then happens if another task reads the stores in the mean time.
4.expect there are an infinite number of other methods…