isrthread: add configuring the stack of an isrthread as static

reason:
we configure the isr thread stack as static to allow for more flexible placement of the stack.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5
2024-09-29 09:03:56 +08:00
committed by Xiang Xiao
parent 5080ab7818
commit 6611480904
6 changed files with 35 additions and 8 deletions
+2
View File
@@ -349,6 +349,7 @@ int work_usrstart(void);
* Input Parameters: * Input Parameters:
* name - Name of the new task * name - Name of the new task
* priority - Priority of the new task * priority - Priority of the new task
* stack_addr - Stack buffer of the new task
* stack_size - size (in bytes) of the stack needed * stack_size - size (in bytes) of the stack needed
* nthreads - Number of work thread should be created * nthreads - Number of work thread should be created
* *
@@ -359,6 +360,7 @@ int work_usrstart(void);
FAR struct kwork_wqueue_s *work_queue_create(FAR const char *name, FAR struct kwork_wqueue_s *work_queue_create(FAR const char *name,
int priority, int priority,
FAR void *stack_addr,
int stack_size, int nthreads); int stack_size, int nthreads);
/**************************************************************************** /****************************************************************************
+5
View File
@@ -346,6 +346,11 @@ config IRQ_NWORKS
---help--- ---help---
The max num of active irq wqueue. The max num of active irq wqueue.
config IRQ_WORK_SECTION
string "The section where irq stack is located"
---help---
The section where irq stack is located.
config IRQ_WORK_STACKSIZE config IRQ_WORK_STACKSIZE
int "The default stack size for isr wqueue" int "The default stack size for isr wqueue"
default DEFAULT_TASK_STACKSIZE default DEFAULT_TASK_STACKSIZE
+5
View File
@@ -42,4 +42,9 @@ if(CONFIG_IRQCHAIN)
list(APPEND SRCS irq_chain.c) list(APPEND SRCS irq_chain.c)
endif() endif()
if(CONFIG_IRQ_WORK_SECTION)
target_compile_definitions(
sched PRIVATE -DIRQ_WORK_SECTION="${CONFIG_IRQ_WORK_SECTION}")
endif()
target_sources(sched PRIVATE ${SRCS}) target_sources(sched PRIVATE ${SRCS})
+4
View File
@@ -42,6 +42,10 @@ ifeq ($(CONFIG_IRQCHAIN),y)
CSRCS += irq_chain.c CSRCS += irq_chain.c
endif endif
ifneq ($(CONFIG_IRQ_WORK_SECTION),"")
CFLAGS += ${DEFINE_PREFIX}IRQ_WORK_SECTION=CONFIG_IRQ_WORK_SECTION
endif
# Include irq build support # Include irq build support
DEPPATH += --dep-path irq DEPPATH += --dep-path irq
+9 -1
View File
@@ -71,6 +71,14 @@ static struct irq_work_info_s g_irq_work_vector[NR_IRQS];
static mutex_t g_irq_wqueue_lock = NXMUTEX_INITIALIZER; static mutex_t g_irq_wqueue_lock = NXMUTEX_INITIALIZER;
static FAR struct kwork_wqueue_s *g_irq_wqueue[CONFIG_IRQ_NWORKS]; static FAR struct kwork_wqueue_s *g_irq_wqueue[CONFIG_IRQ_NWORKS];
#ifdef IRQ_WORK_SECTION
static uint8_t g_irq_work_stack[CONFIG_IRQ_NWORKS][CONFIG_IRQ_WORK_STACKSIZE]
locate_data(IRQ_WORK_SECTION);
#else
static uint8_t g_irq_work_stack[CONFIG_IRQ_NWORKS]
[CONFIG_IRQ_WORK_STACKSIZE];
#endif
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
@@ -98,7 +106,7 @@ inline_function FAR struct kwork_wqueue_s *irq_get_wqueue(int priority)
DEBUGASSERT(i < CONFIG_IRQ_NWORKS); DEBUGASSERT(i < CONFIG_IRQ_NWORKS);
queue = work_queue_create("isrwork", priority, queue = work_queue_create("isrwork", priority, g_irq_work_stack[i],
CONFIG_IRQ_WORK_STACKSIZE, 1); CONFIG_IRQ_WORK_STACKSIZE, 1);
g_irq_wqueue[i] = queue; g_irq_wqueue[i] = queue;
+10 -7
View File
@@ -230,6 +230,7 @@ static int work_thread(int argc, FAR char *argv[])
* Input Parameters: * Input Parameters:
* name - Name of the new task * name - Name of the new task
* priority - Priority of the new task * priority - Priority of the new task
* stack_addr - Stack buffer of the new task
* stack_size - size (in bytes) of the stack needed * stack_size - size (in bytes) of the stack needed
* wqueue - Work queue instance * wqueue - Work queue instance
* *
@@ -239,7 +240,7 @@ static int work_thread(int argc, FAR char *argv[])
****************************************************************************/ ****************************************************************************/
static int work_thread_create(FAR const char *name, int priority, static int work_thread_create(FAR const char *name, int priority,
int stack_size, FAR void *stack_addr, int stack_size,
FAR struct kwork_wqueue_s *wqueue) FAR struct kwork_wqueue_s *wqueue)
{ {
FAR char *argv[3]; FAR char *argv[3];
@@ -264,8 +265,8 @@ static int work_thread_create(FAR const char *name, int priority,
argv[1] = arg1; argv[1] = arg1;
argv[2] = NULL; argv[2] = NULL;
pid = kthread_create(name, priority, stack_size, pid = kthread_create_with_stack(name, priority, stack_addr, stack_size,
work_thread, argv); work_thread, argv);
DEBUGASSERT(pid > 0); DEBUGASSERT(pid > 0);
if (pid < 0) if (pid < 0)
@@ -299,8 +300,9 @@ static int work_thread_create(FAR const char *name, int priority,
* Input Parameters: * Input Parameters:
* name - Name of the new task * name - Name of the new task
* priority - Priority of the new task * priority - Priority of the new task
* stack_addr - Stack buffer of the new task
* stack_size - size (in bytes) of the stack needed * stack_size - size (in bytes) of the stack needed
* nthreads - Number of work thread should be created * nthreads - Number of work thread should be created
* *
* Returned Value: * Returned Value:
* The work queue handle returned on success. Otherwise, NULL * The work queue handle returned on success. Otherwise, NULL
@@ -309,6 +311,7 @@ static int work_thread_create(FAR const char *name, int priority,
FAR struct kwork_wqueue_s *work_queue_create(FAR const char *name, FAR struct kwork_wqueue_s *work_queue_create(FAR const char *name,
int priority, int priority,
FAR void *stack_addr,
int stack_size, int nthreads) int stack_size, int nthreads)
{ {
FAR struct kwork_wqueue_s *wqueue; FAR struct kwork_wqueue_s *wqueue;
@@ -337,7 +340,7 @@ FAR struct kwork_wqueue_s *work_queue_create(FAR const char *name,
/* Create the work queue thread pool */ /* Create the work queue thread pool */
ret = work_thread_create(name, priority, stack_size, wqueue); ret = work_thread_create(name, priority, stack_addr, stack_size, wqueue);
if (ret < 0) if (ret < 0)
{ {
kmm_free(wqueue); kmm_free(wqueue);
@@ -457,7 +460,7 @@ int work_start_highpri(void)
sinfo("Starting high-priority kernel worker thread(s)\n"); sinfo("Starting high-priority kernel worker thread(s)\n");
return work_thread_create(HPWORKNAME, CONFIG_SCHED_HPWORKPRIORITY, return work_thread_create(HPWORKNAME, CONFIG_SCHED_HPWORKPRIORITY, NULL,
CONFIG_SCHED_HPWORKSTACKSIZE, CONFIG_SCHED_HPWORKSTACKSIZE,
(FAR struct kwork_wqueue_s *)&g_hpwork); (FAR struct kwork_wqueue_s *)&g_hpwork);
} }
@@ -485,7 +488,7 @@ int work_start_lowpri(void)
sinfo("Starting low-priority kernel worker thread(s)\n"); sinfo("Starting low-priority kernel worker thread(s)\n");
return work_thread_create(LPWORKNAME, CONFIG_SCHED_LPWORKPRIORITY, return work_thread_create(LPWORKNAME, CONFIG_SCHED_LPWORKPRIORITY, NULL,
CONFIG_SCHED_LPWORKSTACKSIZE, CONFIG_SCHED_LPWORKSTACKSIZE,
(FAR struct kwork_wqueue_s *)&g_lpwork); (FAR struct kwork_wqueue_s *)&g_lpwork);
} }