sched: signal: Introduce a private spinlock in sig_action.c

Summary:
- This commit introduces a private spinlock in sig_action.c

Impact:
- None

Testing:
- Tested with spresense:wifi_smp and spresense:wifi

Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com>
This commit is contained in:
Masayuki Ishikawa 2021-12-09 14:09:34 +09:00 committed by Xiang Xiao
parent 2f55807acb
commit 83edd2fbba

View File

@ -33,11 +33,18 @@
#include <errno.h> #include <errno.h>
#include <nuttx/irq.h> #include <nuttx/irq.h>
#include <nuttx/spinlock.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "group/group.h" #include "group/group.h"
#include "signal/signal.h" #include "signal/signal.h"
/****************************************************************************
* Private Data
****************************************************************************/
static spinlock_t g_sigaction_spin;
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
@ -62,14 +69,14 @@ static void nxsig_alloc_actionblock(void)
sigact = kmm_malloc((sizeof(sigactq_t)) * NUM_SIGNAL_ACTIONS); sigact = kmm_malloc((sizeof(sigactq_t)) * NUM_SIGNAL_ACTIONS);
if (sigact != NULL) if (sigact != NULL)
{ {
flags = spin_lock_irqsave(NULL); flags = spin_lock_irqsave(&g_sigaction_spin);
for (i = 0; i < NUM_SIGNAL_ACTIONS; i++) for (i = 0; i < NUM_SIGNAL_ACTIONS; i++)
{ {
sq_addlast((FAR sq_entry_t *)sigact++, &g_sigfreeaction); sq_addlast((FAR sq_entry_t *)sigact++, &g_sigfreeaction);
} }
spin_unlock_irqrestore(NULL, flags); spin_unlock_irqrestore(&g_sigaction_spin, flags);
} }
} }
@ -88,9 +95,9 @@ static FAR sigactq_t *nxsig_alloc_action(void)
/* Try to get the signal action structure from the free list */ /* Try to get the signal action structure from the free list */
flags = spin_lock_irqsave(NULL); flags = spin_lock_irqsave(&g_sigaction_spin);
sigact = (FAR sigactq_t *)sq_remfirst(&g_sigfreeaction); sigact = (FAR sigactq_t *)sq_remfirst(&g_sigfreeaction);
spin_unlock_irqrestore(NULL, flags); spin_unlock_irqrestore(&g_sigaction_spin, flags);
/* Check if we got one. */ /* Check if we got one. */
@ -102,9 +109,9 @@ static FAR sigactq_t *nxsig_alloc_action(void)
/* And try again */ /* And try again */
flags = spin_lock_irqsave(NULL); flags = spin_lock_irqsave(&g_sigaction_spin);
sigact = (FAR sigactq_t *)sq_remfirst(&g_sigfreeaction); sigact = (FAR sigactq_t *)sq_remfirst(&g_sigfreeaction);
spin_unlock_irqrestore(NULL, flags); spin_unlock_irqrestore(&g_sigaction_spin, flags);
DEBUGASSERT(sigact); DEBUGASSERT(sigact);
} }
@ -403,7 +410,7 @@ void nxsig_release_action(FAR sigactq_t *sigact)
/* Just put it back on the free list */ /* Just put it back on the free list */
flags = spin_lock_irqsave(NULL); flags = spin_lock_irqsave(&g_sigaction_spin);
sq_addlast((FAR sq_entry_t *)sigact, &g_sigfreeaction); sq_addlast((FAR sq_entry_t *)sigact, &g_sigfreeaction);
spin_unlock_irqrestore(NULL, flags); spin_unlock_irqrestore(&g_sigaction_spin, flags);
} }