kernel: select work queue implementation

Attempts to reimplement the existing work API using a new work
implementation failed, primarily due to heavy use of whitebox testing
in validating the original API.  Add a temporary Kconfig that will
select between the two implementations so we can use the same
identifiers but select which implementation they reference.

This commit just adds the selection infrastructure and uses it to
conditionalize the existing implementation in anticipation of the new
one in the next commit.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This commit is contained in:
Peter Bigot 2020-11-21 06:58:58 -06:00 committed by Anas Nashif
parent 0259c864df
commit 44539ed645
5 changed files with 29 additions and 2 deletions

View File

@ -1973,6 +1973,7 @@ PREDEFINED = "CONFIG_ARCH_HAS_CUSTOM_BUSY_WAIT" \
"CONFIG_FPU" \
"CONFIG_FPU_SHARING" \
"CONFIG_HEAP_MEM_POOL_SIZE" \
"CONFIG_KERNEL_WORK1" \
"CONFIG_MMU" \
"CONFIG_NET_L2_ETHERNET_MGMT" \
"CONFIG_NET_MGMT_EVENT" \

View File

@ -2482,6 +2482,8 @@ __syscall int k_stack_pop(struct k_stack *stack, stack_data_t *data,
/** @} */
#ifdef CONFIG_KERNEL_WORK1
struct k_work;
/**
@ -2954,6 +2956,9 @@ static inline int32_t k_delayed_work_remaining_get(const struct k_delayed_work *
}
/** @} */
#endif /* CONFIG_KERNEL_WORK1 */
/**
* @defgroup mutex_apis Mutex APIs
* @ingroup kernel_apis

View File

@ -22,7 +22,6 @@ list(APPEND kernel_files
system_work_q.c
thread.c
version.c
work_q.c
condvar.c
smp.c
banner.c
@ -37,6 +36,7 @@ add_library(kernel ${kernel_files})
# Kernel files has the macro __ZEPHYR_SUPERVISOR__ set so that it
# optimizes the code when userspace is enabled.
set_target_properties(
kernel
PROPERTIES
@ -44,6 +44,8 @@ set_target_properties(
__ZEPHYR_SUPERVISOR__
)
target_sources_ifdef(CONFIG_KERNEL_WORK1 kernel PRIVATE work_q.c)
target_sources_ifdef(CONFIG_STACK_CANARIES kernel PRIVATE compiler_stack_protect.c)
target_sources_ifdef(CONFIG_SYS_CLOCK_EXISTS kernel PRIVATE timeout.c timer.c)
target_sources_ifdef(CONFIG_ATOMIC_OPERATIONS_C kernel PRIVATE atomic_c.c)

View File

@ -875,4 +875,22 @@ config THREAD_LOCAL_STORAGE
help
This option enables thread local storage (TLS) support in kernel.
choice KERNEL_WORK
prompt "Which work queue implementation to use"
default KERNEL_WORK1
config KERNEL_WORK1
bool "Select the original racy work API"
help
This selects the original k_work_* implementation, and excludes the
new simplementation.
config KERNEL_WORK2
bool "Select alternative work API"
help
This disables the original k_work_* implementation and replaces it
with a new one.
endchoice # KERNEL_WORK
endmenu

View File

@ -19,11 +19,12 @@ zephyr_sources(
sem.c
thread_entry.c
timeutil.c
work_q.c
heap.c
heap-validate.c
)
zephyr_sources_ifdef(CONFIG_KERNEL_WORK1 work_q.c)
zephyr_sources_ifdef(CONFIG_CBPRINTF_COMPLETE cbprintf_complete.c)
zephyr_sources_ifdef(CONFIG_CBPRINTF_NANO cbprintf_nano.c)