From 58ad8962816b5e10213dce23d1cd86930183a407 Mon Sep 17 00:00:00 2001 From: chao an Date: Wed, 29 May 2024 09:14:53 +0800 Subject: [PATCH] sched/signal: move signal structures pool to bss Decoupling with memory allocator Signed-off-by: chao an --- sched/signal/sig_initialize.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/sched/signal/sig_initialize.c b/sched/signal/sig_initialize.c index 3f9e2a1e67..21b5c8025a 100644 --- a/sched/signal/sig_initialize.c +++ b/sched/signal/sig_initialize.c @@ -33,6 +33,18 @@ #include "signal/signal.h" +/**************************************************************************** + * Private Type Definitions + ****************************************************************************/ + +struct sigpool_s +{ + sigq_t sigq[NUM_PENDING_ACTIONS + + CONFIG_SIG_PREALLOC_IRQ_ACTIONS]; + sigpendq_t sigpendq[NUM_SIGNALS_PENDING + + CONFIG_SIG_PREALLOC_IRQ_ACTIONS]; +}; + /**************************************************************************** * Public Data ****************************************************************************/ @@ -68,6 +80,14 @@ sq_queue_t g_sigpendingsignal; sq_queue_t g_sigpendingirqsignal; +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* This is a pool of pre-allocated signal structures buffers */ + +static struct sigpool_s g_sigpool; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -134,7 +154,7 @@ static void *nxsig_init_pendingsignalblock(FAR sq_queue_t *siglist, void nxsig_initialize(void) { - FAR void *sigpool; + FAR void *sigpool = &g_sigpool; sched_trace_begin(); @@ -146,16 +166,6 @@ void nxsig_initialize(void) sq_init(&g_sigpendingsignal); sq_init(&g_sigpendingirqsignal); - /* Add a block of signal structures to each list */ - - sigpool = - kmm_malloc(sizeof(sigq_t) * - (NUM_PENDING_ACTIONS + CONFIG_SIG_PREALLOC_IRQ_ACTIONS) - + sizeof(sigpendq_t) * - (NUM_SIGNALS_PENDING + CONFIG_SIG_PREALLOC_IRQ_ACTIONS)); - - DEBUGASSERT(sigpool != NULL); - sigpool = nxsig_init_block(&g_sigpendingaction, sigpool, NUM_PENDING_ACTIONS, SIG_ALLOC_FIXED); sigpool = nxsig_init_block(&g_sigpendingirqaction, sigpool,