Am 10.11.2021 um 20:43 schrieb Grant Edwards:
I'm workikng on a port done by somebody else, and they seem to have
assumed that functions like sys_mbox_set_invalid() don't need to be
thread-safe.  But, they did add mutexes to make sure that some other
functions like like sys_mbox_free() and _new() are thread-safe.

Thread-safe related to what? Globally (all mboxes) or local to the mbox?

I don't think thread-safety is required. It should just work. If you
need guidance, take a look at our FreeRTOS port, which should work
(without additional thread-safety):

https://git.savannah.nongnu.org/cgit/lwip.git/tree/contrib/ports/freertos/sys_arch.c


The documentation I've found at https://www.nongnu.org/lwip/2_1_x/
seems to be mute on that subject.

Do the varios sys_* functions for mutex, semaphore, mailbox functions
in the "OS abstraction layer" need to be thread safe?

Or are they only called under some sort of mutex/protection?

I'm still not sure which specific thread-safety you mean:
- allocation is per definition thread-safe since noone knows the object
at that state
- using the mbox/semaphore is normally thread-safe because you normally
just pass on some variables to OS core functions
- deallocation is only done when the stack knows the object is not used
any more


Is this documented somewhere I should have looked and didn't?

Noone before you has expressed a need for documentation on this topic,
so no, it's not documented yet.

Regards,
Simon

_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to