I’m reading about the direct task notification, noted the content ulvalue is a 32-bit number. I am wondering, would it be possible to set the value to a pointer to a stack? Hence can pass information of any length.
Consider an example with multiple sender tasks and a receiver task. Each sender knows an index starting from 1. The same index is reserved in the notification array of the receiver, so the receiver can know who send the message.
- The sender may send a notification to the receiver at their index, with a context being a pointer to a struct in their stack.
- The sender then blocks until the receiver sends an ack back in some form. (i.e. sender will not change stack once the notification is sent).
- The sender then resumes, corrupting the original content in the stack.
My question is would this work? Is there any chance the stack of the sender would change/corrupt in step 2? Such as a result of memory defragmentation? If there are issues, what would be the best way to fix them?
As a follow-up question: It seems the notification API can only query one index at a time (via xTaskNotifyWait), is there a way to get a bitmap of all the notification state and without blocking? So I can do a quick binary hack to handle the correct notification and skip there is no notification to handle.
I know I can always use a queue, but I want to make it efficient and elegant.