Commit 17d2e9d0 authored by Uday Ammu's avatar Uday Ammu Committed by Christopher Friedt
Browse files

shell: optionally configure priority of the shell thread



Currently, in Zephyr the shell thread is the lowest priority i.e.
K_LOWEST_APPLICATION_THREAD_PRIO. Due to this all the other threads can
preempt the shell thread. Proposed solution is to add Kconfig which
gives the flexibility to change the priority of the shell thread.

This is now implemented using a new Kconfig variable
SHELL_THREAD_PRIORITY_OVERRIDE. By setting this option
SHELL_THREAD_PRIORITY can be set.

Signed-off-by: default avatarUday Ammu <udaykiran@google.com>
parent 6976800c
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -25,6 +25,19 @@ config SHELL_MINIMAL
	  defaults which favor reduced flash or memory requirements over extra
	  features.

config SHELL_THREAD_PRIORITY_OVERRIDE
	bool "Override default shell thread priority"
	help
	  Option to change the default value of shell thread priority.

if SHELL_THREAD_PRIORITY_OVERRIDE
config SHELL_THREAD_PRIORITY
	int "Shell thread priority"
	default 0
	help
	  Set thread priority of the shell
endif

config SHELL_STACK_SIZE
	int "Shell thread stack size"
	default 3168 if OPENTHREAD_SHELL && OPENTHREAD_JOINER
+13 −4
Original line number Diff line number Diff line
@@ -32,6 +32,15 @@
#define SHELL_MSG_TOO_MANY_ARGS		"Too many arguments in the command.\n"
#define SHELL_INIT_OPTION_PRINTER	(NULL)

#define SHELL_THREAD_PRIORITY \
	COND_CODE_1(CONFIG_SHELL_THREAD_PRIORITY_OVERRIDE, \
			(CONFIG_SHELL_THREAD_PRIORITY), (K_LOWEST_APPLICATION_THREAD_PRIO))

BUILD_ASSERT(SHELL_THREAD_PRIORITY >=
		  K_HIGHEST_APPLICATION_THREAD_PRIO
		&& SHELL_THREAD_PRIORITY <= K_LOWEST_APPLICATION_THREAD_PRIO,
		  "Invalid range for thread priority");

static inline void receive_state_change(const struct shell *shell,
					enum shell_receive_state state)
{
@@ -1349,7 +1358,7 @@ int shell_init(const struct shell *shell, const void *transport_config,
				  shell->stack, CONFIG_SHELL_STACK_SIZE,
				  shell_thread, (void *)shell, (void *)log_backend,
				  UINT_TO_POINTER(init_log_level),
			      K_LOWEST_APPLICATION_THREAD_PRIO, 0, K_NO_WAIT);
				  SHELL_THREAD_PRIORITY, 0, K_NO_WAIT);

	shell->ctx->tid = tid;
	k_thread_name_set(tid, shell->thread_name);