46a02322ec
It was possible to deadlock the shell when command suspended shell's thread and next another thread wanted to print something on the shell. To avoid that shell releases mutex before entering command handler. Due to this change some adapations to shell internal print functions have been applied. This change addresses following usecase: 1. A command handler needs to call a (system) function which communicate results via a callback, and this callback is expected to print these results. The callback is called by the system from another thread. 2. To achieve that, the handler needs to pass `struct shell *` to callbacks, but also some other data specific to callback. Thus, handles allocates some structure will those fields on the stack. 3. The handler schedules this callback to be called. 4. As a reference to stack structure is passed to the callback, the handler can't return immediately (or stack data will go out of scope and will be overwritten). 5. So, the handler blocks waiting for callback to finish. Previously, this scenario led to deadlock when the callback trying or print to shell. With these changes, it just works, as long as main handler and callback serialize there access to the shell structure (i.e. when callback prints, the main handler is blocked waiting for its completion). Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no> |
||
---|---|---|
.. | ||
shell.h | ||
shell_dummy.h | ||
shell_fprintf.h | ||
shell_history.h | ||
shell_log_backend.h | ||
shell_rtt.h | ||
shell_types.h | ||
shell_uart.h |