zephyr/subsys/shell
Jakub Rzeszutko 46a02322ec shell: allow commands to suspend shell thread
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>
2019-02-14 13:40:28 +01:00
..
modules shell: remove obsolete \r characters 2018-12-17 11:31:22 +01:00
CMakeLists.txt shell: removing legacy shell 2019-01-16 21:35:36 -05:00
Kconfig shell: improved shell_prompt_change function 2019-02-08 14:51:52 -05:00
Kconfig.backends dts: Convert CONFIG_ to DT_ symbols for chosen props 2019-02-08 11:41:26 -06:00
Kconfig.template.shell_log_queue_size shell: Improve handling of log messages 2018-12-19 14:37:00 +01:00
Kconfig.template.shell_log_queue_timeout shell: Improve handling of log messages 2018-12-19 14:37:00 +01:00
shell_cmds.c shell: safe print from different threads 2019-01-30 13:05:56 +01:00
shell_dummy.c shell: Improve handling of log messages 2018-12-19 14:37:00 +01:00
shell_fprintf.c shell: parsing output LF character 2018-10-10 10:45:28 +02:00
shell_help.c shell: allow commands to suspend shell thread 2019-02-14 13:40:28 +01:00
shell_help.h shell: creating new module for help functionality 2018-12-05 15:15:44 +01:00
shell_history.c shell: Allocate proper amount of history slab memory 2019-02-06 07:16:08 -05:00
shell_log_backend.c shell: Add handling of CONFIG_LOG_INPLACE_PROCESS option 2019-02-05 09:55:39 +01:00
shell_ops.c shell: allow commands to suspend shell thread 2019-02-14 13:40:28 +01:00
shell_ops.h shell: allow commands to suspend shell thread 2019-02-14 13:40:28 +01:00
shell_rtt.c shell: Add support to log_panic in RTT backend 2019-02-13 17:25:59 -05:00
shell_uart.c shell: Add handling of CONFIG_LOG_INPLACE_PROCESS option 2019-02-05 09:55:39 +01:00
shell_utils.c shell: unify commands execution 2019-02-08 14:58:44 -05:00
shell_utils.h shell: unify commands execution 2019-02-08 14:58:44 -05:00
shell_vt100.h shell: add meta-keys 2019-01-14 16:01:48 -05:00
shell_wildcard.c shell: allow commands to suspend shell thread 2019-02-14 13:40:28 +01:00
shell_wildcard.h shell: Add wildcard support 2018-09-19 09:30:29 -04:00
shell.c shell: allow commands to suspend shell thread 2019-02-14 13:40:28 +01:00