mbox: initial import of a thread-independent IPC#4552
mbox: initial import of a thread-independent IPC#4552miri64 wants to merge 2 commits intoRIOT-OS:masterfrom
Conversation
79e8f71 to
c1467c2
Compare
|
Sorry, I don't have time to review this. |
|
@Kijewski since you have some experience with semaphores also, you might want to have a look too. |
9325a01 to
4cfc467
Compare
|
While I like the simplicity of the approach, it doesn't tackle some of the IMHO important aspects:
|
Could be fixed easily IMHO
As I mentioned in the description: there is room for optimization ;)
Since semaphores are based on the current messaging this doesn't surprise me really
Was that something we wanted? This should be adaptable easily, but it wouldn't make it stronger in the points you already gave.
What do you mean by that? |
|
@authmillenon Well, devising the API (mbox_put(), mbox_get(), ...) is simple, the other points make it hard ;)
e.g. |
|
Except for the fixed size for the message box this is exactly how it was done in lwIP (with void pointers). I'm not sure however, how this could put to a better use, than a fixed |
|
Needs a rebase, but is no longer waiting on anything. |
4cfc467 to
d6daee1
Compare
|
Rebased |
| SEMA_CREATE(1), SEMA_CREATE(0), 0 } | ||
|
|
||
| /** | ||
| * @brief Static initializer for message box. |
|
I have #4919 lying around, please consider that. |
|
I still need to test #4919, but I already know that I will prefer it => close. |
Introduction
I know @kaspar030 is working on something like this too, but when I was working with lwIP again, I decided to port out the messaging layer I implemented for it, to better test it and to give it as an alternative to @kaspar030's work (and since it was already laying around in my repo it took me only half a day and some hours of boredom on Christmas to port it to
msg_t).mboxis thought to be an alternative - not a replacement - to standard-IPC. There are probably many ways to make it a little bit smaller in memory consumption, but I based it on the unix support for mbox of lwIP (with many adaptations to make it more RIOT-y) so it is quite stable.Summary
mboxis a datatype with two base operations (of that there are some variations - more on that later):mbox_put()andmbox_get()Blocking IPC
mbox_put()allows a user to put amsg_tin thembox. If themboxis full the thread will block and be signaled through thembox::not_fullsemaphore, when there is space in themboxagain.mbox_get()allows a user to get amsg_tfrom thembox. If themboxis empty the thread will block and be signaled through thembox::not_emptysemaphore, when another thread puts something in thembox.Non-blocking IPC
There is a non-blocking variant
mbox_tryget()andmbox_tryput()for both operations, that just returns-EAGAINwhen the normal operations would block (they don't require the semaphores, though they both post them, so the blocking variants are woken up).mbox and time
Since the blocking mechanism is based on semaphores there is also a timeout-variant of
mbox_get():mbox_get_timed(). If we make this optional for semaphores we also can make it optional here.Dependencies
Depends on #4551 and maybe #4374 (though I did not run into any problems during tests, regarding this bug).