kernel: do not export z_thread_priority_set
This function is only being used by a test, so instead of reimplementing a syscall in the test, provide a Kconfig option to provide the functionality that only works with tests and remove some of the duplication and extra code. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
3ca50f5060
commit
5e591c38f1
|
@ -208,6 +208,13 @@ config THREAD_USERSPACE_LOCAL_DATA
|
||||||
depends on USERSPACE
|
depends on USERSPACE
|
||||||
default y if ERRNO && !ERRNO_IN_TLS && !LIBC_ERRNO
|
default y if ERRNO && !ERRNO_IN_TLS && !LIBC_ERRNO
|
||||||
|
|
||||||
|
config USERSPACE_THREAD_MAY_RAISE_PRIORITY
|
||||||
|
bool "Thread can raise own priority"
|
||||||
|
depends on USERSPACE
|
||||||
|
depends on TEST # This should only be enabled by tests.
|
||||||
|
help
|
||||||
|
Thread can raise its own priority in userspace mode.
|
||||||
|
|
||||||
config DYNAMIC_THREAD
|
config DYNAMIC_THREAD
|
||||||
bool "Support for dynamic threads [EXPERIMENTAL]"
|
bool "Support for dynamic threads [EXPERIMENTAL]"
|
||||||
select EXPERIMENTAL
|
select EXPERIMENTAL
|
||||||
|
|
|
@ -51,7 +51,6 @@ void z_reschedule_irqlock(uint32_t key);
|
||||||
struct k_thread *z_unpend_first_thread(_wait_q_t *wait_q);
|
struct k_thread *z_unpend_first_thread(_wait_q_t *wait_q);
|
||||||
void z_unpend_thread(struct k_thread *thread);
|
void z_unpend_thread(struct k_thread *thread);
|
||||||
int z_unpend_all(_wait_q_t *wait_q);
|
int z_unpend_all(_wait_q_t *wait_q);
|
||||||
void z_thread_priority_set(struct k_thread *thread, int prio);
|
|
||||||
bool z_set_prio(struct k_thread *thread, int prio);
|
bool z_set_prio(struct k_thread *thread, int prio);
|
||||||
void *z_get_next_switch_handle(void *interrupted);
|
void *z_get_next_switch_handle(void *interrupted);
|
||||||
void idle(void *unused1, void *unused2, void *unused3);
|
void idle(void *unused1, void *unused2, void *unused3);
|
||||||
|
|
|
@ -1013,17 +1013,6 @@ bool z_set_prio(struct k_thread *thread, int prio)
|
||||||
return need_sched;
|
return need_sched;
|
||||||
}
|
}
|
||||||
|
|
||||||
void z_thread_priority_set(struct k_thread *thread, int prio)
|
|
||||||
{
|
|
||||||
bool need_sched = z_set_prio(thread, prio);
|
|
||||||
|
|
||||||
flag_ipi();
|
|
||||||
|
|
||||||
if (need_sched && _current->base.sched_locked == 0U) {
|
|
||||||
z_reschedule_unlocked();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool resched(uint32_t key)
|
static inline bool resched(uint32_t key)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
|
@ -1286,9 +1275,12 @@ void z_impl_k_thread_priority_set(k_tid_t thread, int prio)
|
||||||
Z_ASSERT_VALID_PRIO(prio, NULL);
|
Z_ASSERT_VALID_PRIO(prio, NULL);
|
||||||
__ASSERT(!arch_is_in_isr(), "");
|
__ASSERT(!arch_is_in_isr(), "");
|
||||||
|
|
||||||
struct k_thread *th = (struct k_thread *)thread;
|
bool need_sched = z_set_prio((struct k_thread *)thread, prio);
|
||||||
|
|
||||||
z_thread_priority_set(th, prio);
|
flag_ipi();
|
||||||
|
if (need_sched && _current->base.sched_locked == 0U) {
|
||||||
|
z_reschedule_unlocked();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_USERSPACE
|
#ifdef CONFIG_USERSPACE
|
||||||
|
@ -1297,10 +1289,11 @@ static inline void z_vrfy_k_thread_priority_set(k_tid_t thread, int prio)
|
||||||
K_OOPS(K_SYSCALL_OBJ(thread, K_OBJ_THREAD));
|
K_OOPS(K_SYSCALL_OBJ(thread, K_OBJ_THREAD));
|
||||||
K_OOPS(K_SYSCALL_VERIFY_MSG(_is_valid_prio(prio, NULL),
|
K_OOPS(K_SYSCALL_VERIFY_MSG(_is_valid_prio(prio, NULL),
|
||||||
"invalid thread priority %d", prio));
|
"invalid thread priority %d", prio));
|
||||||
|
#ifndef CONFIG_USERSPACE_THREAD_MAY_RAISE_PRIORITY
|
||||||
K_OOPS(K_SYSCALL_VERIFY_MSG((int8_t)prio >= thread->base.prio,
|
K_OOPS(K_SYSCALL_VERIFY_MSG((int8_t)prio >= thread->base.prio,
|
||||||
"thread priority may only be downgraded (%d < %d)",
|
"thread priority may only be downgraded (%d < %d)",
|
||||||
prio, thread->base.prio));
|
prio, thread->base.prio));
|
||||||
|
#endif
|
||||||
z_impl_k_thread_priority_set(thread, prio);
|
z_impl_k_thread_priority_set(thread, prio);
|
||||||
}
|
}
|
||||||
#include <syscalls/k_thread_priority_set_mrsh.c>
|
#include <syscalls/k_thread_priority_set_mrsh.c>
|
||||||
|
|
|
@ -25,3 +25,4 @@ CONFIG_USERSPACE=y
|
||||||
|
|
||||||
# Disable time slicing
|
# Disable time slicing
|
||||||
CONFIG_TIMESLICING=n
|
CONFIG_TIMESLICING=n
|
||||||
|
CONFIG_USERSPACE_THREAD_MAY_RAISE_PRIORITY=y
|
||||||
|
|
|
@ -78,29 +78,6 @@ K_PIPE_DEFINE(PIPE_BIGBUFF, 4096, 4);
|
||||||
* Custom syscalls
|
* Custom syscalls
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Change a thread's priority
|
|
||||||
*
|
|
||||||
* Unlike the normal k_thread_priority_set(), this custom syscall allows
|
|
||||||
* a user thread to raise its priority.
|
|
||||||
*/
|
|
||||||
void z_impl_test_thread_priority_set(k_tid_t thread, int prio)
|
|
||||||
{
|
|
||||||
extern void z_thread_priority_set(struct k_thread *thread, int prio);
|
|
||||||
|
|
||||||
z_thread_priority_set((struct k_thread *)thread, prio);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef CONFIG_USERSPACE
|
|
||||||
static void z_vrfy_test_thread_priority_set(k_tid_t thread, int prio)
|
|
||||||
{
|
|
||||||
z_impl_test_thread_priority_set(thread, prio);
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <syscalls/test_thread_priority_set_mrsh.c>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Obtain a timestamp
|
* @brief Obtain a timestamp
|
||||||
*
|
*
|
||||||
|
|
|
@ -115,7 +115,7 @@ void pipe_test(void)
|
||||||
PRINT_STRING("| "
|
PRINT_STRING("| "
|
||||||
"non-matching sizes (1_TO_N) to lower priority"
|
"non-matching sizes (1_TO_N) to lower priority"
|
||||||
" |\n");
|
" |\n");
|
||||||
test_thread_priority_set(k_current_get(), TaskPrio - 2);
|
k_thread_priority_set(k_current_get(), TaskPrio - 2);
|
||||||
}
|
}
|
||||||
PRINT_STRING(dashline);
|
PRINT_STRING(dashline);
|
||||||
PRINT_1_TO_N_HEADER();
|
PRINT_1_TO_N_HEADER();
|
||||||
|
@ -136,7 +136,7 @@ void pipe_test(void)
|
||||||
PRINT_1_TO_N();
|
PRINT_1_TO_N();
|
||||||
}
|
}
|
||||||
PRINT_STRING(dashline);
|
PRINT_STRING(dashline);
|
||||||
test_thread_priority_set(k_current_get(), TaskPrio);
|
k_thread_priority_set(k_current_get(), TaskPrio);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue