mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
arch, sched/signal: Fix compilation with ENABLE_PARTIAL_SIGNALS=y
Correct build errors when CONFIG_ENABLE_ALL_SIGNALS is not defined - sched makefiles: Move pending-signal helpers from the ENABLE_ALL_SIGNALS-only list to the !DISABLE_ALL_SIGNALS list so signal dispatch is available in PARTIAL builds sched: make SIG_PREALLOC_ACTIONS, SIG_ALLOC_ACTIONS and SIG_DEFAULT depend on ENABLE_ALL_SIGNALS - sched: fix ifdefs around pending-signal queue access and signal-mask for PARTIAL/DISABLE modes - arch: gate SYS_signal_handler / _return calls and SYSCALL_LOOKUP(signal) with ENABLE_ALL_SIGNALS Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
This commit is contained in:
parent
0d93f2eb20
commit
7f8f800e63
30 changed files with 147 additions and 102 deletions
|
|
@ -238,7 +238,7 @@ int arm_svcall(int irq, void *context, void *arg)
|
|||
* R4 = ucontext
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
|
||||
case SYS_signal_handler:
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
|
|
@ -280,7 +280,7 @@ int arm_svcall(int irq, void *context, void *arg)
|
|||
* R0 = SYS_signal_handler_return
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
|
||||
case SYS_signal_handler_return:
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ int arm_svcall(int irq, void *context, void *arg)
|
|||
* R4 = ucontext
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
|
||||
case SYS_signal_handler:
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
|
|
@ -282,7 +282,7 @@ int arm_svcall(int irq, void *context, void *arg)
|
|||
* R0 = SYS_signal_handler_return
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
|
||||
case SYS_signal_handler_return:
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ int arm_svcall(int irq, void *context, void *arg)
|
|||
* R4 = ucontext
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
|
||||
case SYS_signal_handler:
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
|
|
@ -282,7 +282,7 @@ int arm_svcall(int irq, void *context, void *arg)
|
|||
* R0 = SYS_signal_handler_return
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
|
||||
case SYS_signal_handler_return:
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ uint32_t *arm_syscall(uint32_t *regs)
|
|||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
|
||||
/* R0=SYS_signal_handler: This a user signal handler callback
|
||||
*
|
||||
* void signal_handler(_sa_sigaction_t sighand, int signo,
|
||||
|
|
@ -438,7 +438,7 @@ uint32_t *arm_syscall(uint32_t *regs)
|
|||
break;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ENABLE_ALL_SIGNALS)
|
||||
/* R0=SYS_signal_handler_return: This a user signal handler callback
|
||||
*
|
||||
* void signal_handler_return(void);
|
||||
|
|
|
|||
|
|
@ -159,7 +159,8 @@ uint64_t *arm64_syscall(uint64_t *regs)
|
|||
struct tcb_s **running_task = &g_running_tasks[cpu];
|
||||
struct tcb_s *tcb = this_task();
|
||||
uint64_t cmd;
|
||||
#if defined(CONFIG_BUILD_KERNEL) || defined(CONFIG_BUILD_PROTECTED)
|
||||
#if (defined(CONFIG_BUILD_KERNEL) || defined(CONFIG_BUILD_PROTECTED)) \
|
||||
&& defined(CONFIG_ENABLE_ALL_SIGNALS)
|
||||
uint64_t spsr;
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ int riscv_swint(int irq, void *context, void *arg)
|
|||
* A4 = ucontext
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_BUILD_FLAT
|
||||
#if !defined(CONFIG_BUILD_FLAT) && defined(CONFIG_ENABLE_ALL_SIGNALS)
|
||||
case SYS_signal_handler:
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
|
|
@ -272,7 +272,7 @@ int riscv_swint(int irq, void *context, void *arg)
|
|||
* R0 = SYS_signal_handler_return
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_BUILD_FLAT
|
||||
#if !defined(CONFIG_BUILD_FLAT) && defined(CONFIG_ENABLE_ALL_SIGNALS)
|
||||
case SYS_signal_handler_return:
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ int xtensa_swint(int irq, void *context, void *arg)
|
|||
* A6 = ucontext
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_BUILD_FLAT
|
||||
#if !defined(CONFIG_BUILD_FLAT) && defined(CONFIG_ENABLE_ALL_SIGNALS)
|
||||
case SYS_signal_handler:
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
|
|
@ -300,7 +300,7 @@ int xtensa_swint(int irq, void *context, void *arg)
|
|||
* A2 = SYS_signal_handler_return
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_BUILD_FLAT
|
||||
#if !defined(CONFIG_BUILD_FLAT) && defined(CONFIG_ENABLE_ALL_SIGNALS)
|
||||
case SYS_signal_handler_return:
|
||||
{
|
||||
struct tcb_s *rtcb = this_task();
|
||||
|
|
|
|||
|
|
@ -519,8 +519,10 @@ struct task_group_s
|
|||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
sq_queue_t tg_sigactionq; /* List of actions for signals */
|
||||
sq_queue_t tg_sigpendingq; /* List of pending signals */
|
||||
#endif /* CONFIG_ENABLE_ALL_SIGNALS */
|
||||
#ifndef CONFIG_DISABLE_ALL_SIGNALS
|
||||
sq_queue_t tg_sigpendingq; /* List of pending signals */
|
||||
#endif /* !CONFIG_DISABLE_ALL_SIGNALS */
|
||||
#ifdef CONFIG_SIG_DEFAULT
|
||||
sigset_t tg_sigdefault; /* Set of signals set to the default action */
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -217,8 +217,10 @@ SYSCALL_LOOKUP(pwrite, 4)
|
|||
#endif
|
||||
SYSCALL_LOOKUP(poll, 3)
|
||||
SYSCALL_LOOKUP(select, 5)
|
||||
#ifndef CONFIG_DISABLE_ALL_SIGNALS
|
||||
SYSCALL_LOOKUP(ppoll, 4)
|
||||
SYSCALL_LOOKUP(pselect, 6)
|
||||
#endif
|
||||
#ifdef CONFIG_EVENT_FD
|
||||
SYSCALL_LOOKUP(eventfd, 2)
|
||||
#endif
|
||||
|
|
@ -397,7 +399,9 @@ SYSCALL_LOOKUP(settimeofday, 2)
|
|||
|
||||
/* ANSI C signal handling */
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
SYSCALL_LOOKUP(signal, 2)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP
|
||||
SYSCALL_LOOKUP(sched_note_vprintf_ip, 5)
|
||||
|
|
|
|||
|
|
@ -131,9 +131,7 @@ if(NOT CONFIG_DISABLE_PTHREAD)
|
|||
list(APPEND SRCS pthread_spinlock.c)
|
||||
endif()
|
||||
|
||||
if(NOT CONFIG_DISABLE_ALL_SIGNALS)
|
||||
list(APPEND SRCS pthread_kill.c)
|
||||
endif()
|
||||
list(APPEND SRCS pthread_kill.c)
|
||||
|
||||
if(NOT CONFIG_TLS_NCLEANUP EQUAL 0)
|
||||
list(APPEND SRCS pthread_cleanup.c)
|
||||
|
|
|
|||
|
|
@ -68,10 +68,7 @@ CSRCS += pthread_setcancelstate.c pthread_setcanceltype.c
|
|||
CSRCS += pthread_testcancel.c pthread_getcpuclockid.c
|
||||
CSRCS += pthread_self.c pthread_gettid_np.c
|
||||
CSRCS += pthread_concurrency.c
|
||||
|
||||
ifneq ($(CONFIG_DISABLE_ALL_SIGNALS),y)
|
||||
CSRCS += pthread_kill.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SMP),y)
|
||||
CSRCS += pthread_attr_getaffinity.c pthread_attr_setaffinity.c
|
||||
|
|
|
|||
|
|
@ -90,7 +90,6 @@ int pthread_mutex_destroy(FAR pthread_mutex_t *mutex)
|
|||
* nxsched_get_tcb() does.
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_DISABLE_ALL_SIGNALS
|
||||
if (pthread_kill(pid, 0) != 0)
|
||||
{
|
||||
/* The thread associated with the PID no longer exists */
|
||||
|
|
@ -122,7 +121,6 @@ int pthread_mutex_destroy(FAR pthread_mutex_t *mutex)
|
|||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
ret = EBUSY;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1601,6 +1601,16 @@ config DISABLE_ALL_SIGNALS
|
|||
|
||||
endchoice
|
||||
|
||||
config SIG_PREALLOC_IRQ_ACTIONS
|
||||
int "Number of pre-allocated irq actions"
|
||||
default 4 if DEFAULT_SMALL
|
||||
default 8 if !DEFAULT_SMALL
|
||||
depends on !DISABLE_ALL_SIGNALS
|
||||
---help---
|
||||
The number of pre-allocated irq action structures.
|
||||
|
||||
if ENABLE_ALL_SIGNALS
|
||||
|
||||
config SIG_PREALLOC_ACTIONS
|
||||
int "Number of pre-allocated sigactions"
|
||||
default 4
|
||||
|
|
@ -1615,13 +1625,6 @@ config SIG_ALLOC_ACTIONS
|
|||
if this number is larger than 1, the allocation won't be
|
||||
returned to the heap but kept in a free list for reuse.
|
||||
|
||||
config SIG_PREALLOC_IRQ_ACTIONS
|
||||
int "Number of pre-allocated irq actions"
|
||||
default 4 if DEFAULT_SMALL
|
||||
default 8 if !DEFAULT_SMALL
|
||||
---help---
|
||||
The number of pre-allocated irq action structures.
|
||||
|
||||
config SIG_EVTHREAD
|
||||
bool "Support SIGEV_THREAD"
|
||||
default n
|
||||
|
|
@ -1736,6 +1739,8 @@ config SIG_SIGURG_ACTION
|
|||
|
||||
endif # SIG_DEFAULT
|
||||
|
||||
endif # ENABLE_ALL_SIGNALS
|
||||
|
||||
endmenu # Signal Configuration
|
||||
|
||||
menu "Message Queue Options"
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ static inline void group_release(FAR struct task_group_s *group)
|
|||
|
||||
/* Release pending signals */
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
#ifndef CONFIG_DISABLE_ALL_SIGNALS
|
||||
nxsig_release(group);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -643,7 +643,7 @@ void nx_start(void)
|
|||
|
||||
/* Initialize the signal facility (if in link) */
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
#ifndef CONFIG_DISABLE_ALL_SIGNALS
|
||||
nxsig_initialize();
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -103,12 +103,15 @@ void nxsched_suspend(FAR struct tcb_s *tcb)
|
|||
{
|
||||
irqstate_t flags;
|
||||
bool switch_needed;
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
FAR sq_entry_t *entry;
|
||||
#endif
|
||||
|
||||
DEBUGASSERT(tcb != NULL);
|
||||
|
||||
flags = enter_critical_section();
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
/* Check if received SIGCONT */
|
||||
|
||||
sq_for_every(&tcb->sigpendactionq, entry)
|
||||
|
|
@ -120,6 +123,7 @@ void nxsched_suspend(FAR struct tcb_s *tcb)
|
|||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Check the current state of the task */
|
||||
|
||||
|
|
|
|||
|
|
@ -34,9 +34,7 @@
|
|||
#include <nuttx/irq.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/mm/kmap.h>
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
#include <nuttx/signal.h>
|
||||
#endif
|
||||
|
||||
#include "sched/sched.h"
|
||||
#include "semaphore/semaphore.h"
|
||||
|
|
@ -74,7 +72,7 @@
|
|||
|
||||
int nxsem_wait_slow(FAR sem_t *sem)
|
||||
{
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
#ifndef CONFIG_DISABLE_ALL_SIGNALS
|
||||
sigset_t pendingset;
|
||||
#endif
|
||||
FAR struct tcb_s *rtcb = this_task();
|
||||
|
|
@ -93,7 +91,7 @@ int nxsem_wait_slow(FAR sem_t *sem)
|
|||
|
||||
/* Make sure we were supplied with a valid semaphore. */
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
#ifndef CONFIG_DISABLE_ALL_SIGNALS
|
||||
/* A signal can arrive before sem_wait transitions the task to
|
||||
* TSTATE_WAIT_SEM. In that window, the wait cannot yet be aborted by
|
||||
* sem_wait_irq(). If sem_wait then blocks without re-checking unmasked
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@
|
|||
#
|
||||
# ##############################################################################
|
||||
|
||||
set(SRCS sig_nanosleep.c sig_usleep.c sig_sleep.c sig_clockwait.c)
|
||||
set(SRCS sig_nanosleep.c sig_usleep.c sig_sleep.c sig_clockwait.c sig_kill.c
|
||||
sig_tgkill.c)
|
||||
|
||||
if(NOT CONFIG_DISABLE_ALL_SIGNALS)
|
||||
list(
|
||||
|
|
@ -28,8 +29,6 @@ if(NOT CONFIG_DISABLE_ALL_SIGNALS)
|
|||
SRCS
|
||||
sig_procmask.c
|
||||
sig_suspend.c
|
||||
sig_kill.c
|
||||
sig_tgkill.c
|
||||
sig_queue.c
|
||||
sig_waitinfo.c
|
||||
sig_timedwait.c
|
||||
|
|
@ -38,7 +37,13 @@ if(NOT CONFIG_DISABLE_ALL_SIGNALS)
|
|||
sig_dispatch.c
|
||||
sig_pause.c
|
||||
sig_ppoll.c
|
||||
sig_pselect.c)
|
||||
sig_pselect.c
|
||||
sig_cleanup.c
|
||||
sig_initialize.c
|
||||
sig_pending.c
|
||||
sig_releasependingsignal.c
|
||||
sig_removependingsignal.c
|
||||
sig_unmaskpendingsignal.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_ENABLE_ALL_SIGNALS)
|
||||
|
|
@ -47,15 +52,9 @@ if(CONFIG_ENABLE_ALL_SIGNALS)
|
|||
SRCS
|
||||
sig_action.c
|
||||
sig_allocpendingsigaction.c
|
||||
sig_cleanup.c
|
||||
sig_deliver.c
|
||||
sig_findaction.c
|
||||
sig_initialize.c
|
||||
sig_pending.c
|
||||
sig_releasependingsigaction.c
|
||||
sig_releasependingsignal.c
|
||||
sig_removependingsignal.c
|
||||
sig_unmaskpendingsignal.c)
|
||||
sig_releasependingsigaction.c)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SIG_DEFAULT)
|
||||
|
|
|
|||
|
|
@ -21,18 +21,21 @@
|
|||
############################################################################
|
||||
|
||||
CSRCS += sig_nanosleep.c sig_sleep.c sig_usleep.c sig_clockwait.c
|
||||
CSRCS += sig_kill.c sig_tgkill.c
|
||||
|
||||
ifneq ($(CONFIG_DISABLE_ALL_SIGNALS),y)
|
||||
CSRCS += sig_dispatch.c sig_kill.c sig_lowest.c
|
||||
CSRCS += sig_dispatch.c sig_lowest.c
|
||||
CSRCS += sig_notification.c sig_pause.c sig_ppoll.c sig_procmask.c
|
||||
CSRCS += sig_pselect.c sig_queue.c sig_suspend.c sig_tgkill.c
|
||||
CSRCS += sig_pselect.c sig_queue.c sig_suspend.c
|
||||
CSRCS += sig_timedwait.c sig_waitinfo.c
|
||||
CSRCS += sig_cleanup.c sig_initialize.c sig_pending.c
|
||||
CSRCS += sig_releasependingsignal.c sig_removependingsignal.c
|
||||
CSRCS += sig_unmaskpendingsignal.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_ENABLE_ALL_SIGNALS),y)
|
||||
CSRCS += sig_action.c sig_allocpendingsigaction.c sig_cleanup.c sig_deliver.c
|
||||
CSRCS += sig_findaction.c sig_initialize.c sig_pending.c sig_releasependingsigaction.c
|
||||
CSRCS += sig_releasependingsignal.c sig_removependingsignal.c sig_unmaskpendingsignal.c
|
||||
CSRCS += sig_action.c sig_allocpendingsigaction.c sig_deliver.c
|
||||
CSRCS += sig_findaction.c sig_releasependingsigaction.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SIG_DEFAULT),y)
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@
|
|||
|
||||
void nxsig_cleanup(FAR struct tcb_s *stcb)
|
||||
{
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
FAR sigq_t *sigq;
|
||||
|
||||
/* Deallocate all entries in the list of pending signal actions */
|
||||
|
|
@ -61,6 +62,7 @@ void nxsig_cleanup(FAR struct tcb_s *stcb)
|
|||
{
|
||||
nxsig_release_pendingsigaction(sigq);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Misc. signal-related clean-up */
|
||||
|
||||
|
|
@ -81,13 +83,17 @@ void nxsig_cleanup(FAR struct tcb_s *stcb)
|
|||
|
||||
void nxsig_release(FAR struct task_group_s *group)
|
||||
{
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
FAR sigactq_t *sigact;
|
||||
#endif
|
||||
FAR sigpendq_t *sigpend;
|
||||
irqstate_t flags;
|
||||
|
||||
flags = spin_lock_irqsave(&group->tg_lock);
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
/* Deallocate all entries in the list of signal actions */
|
||||
|
||||
flags = spin_lock_irqsave(&group->tg_lock);
|
||||
while ((sigact = (FAR sigactq_t *)sq_remfirst(&group->tg_sigactionq))
|
||||
!= NULL)
|
||||
{
|
||||
|
|
@ -95,6 +101,7 @@ void nxsig_release(FAR struct task_group_s *group)
|
|||
nxsig_release_action(sigact);
|
||||
flags = spin_lock_irqsave(&group->tg_lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Deallocate all entries in the list of pending signals */
|
||||
|
||||
|
|
|
|||
|
|
@ -204,6 +204,25 @@ static int nxsig_queue_action(FAR struct tcb_s *stcb,
|
|||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsig_dispatch_kernel_action
|
||||
****************************************************************************/
|
||||
|
||||
static void nxsig_dispatch_kernel_action(FAR struct tcb_s *stcb,
|
||||
FAR siginfo_t *info)
|
||||
{
|
||||
FAR struct task_group_s *group = stcb->group;
|
||||
FAR sigactq_t *sigact;
|
||||
|
||||
sigact = nxsig_find_action(group, info->si_signo);
|
||||
if (sigact && (sigact->act.sa_flags & SA_KERNELHAND))
|
||||
{
|
||||
info->si_user = sigact->act.sa_user;
|
||||
(sigact->act.sa_sigaction)(info->si_signo, info, NULL);
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_ENABLE_ALL_SIGNALS */
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsig_alloc_pendingsignal
|
||||
*
|
||||
|
|
@ -275,24 +294,6 @@ nxsig_find_pendingsignal(FAR struct task_group_s *group, int signo)
|
|||
return sigpend;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsig_dispatch_kernel_action
|
||||
****************************************************************************/
|
||||
|
||||
static void nxsig_dispatch_kernel_action(FAR struct tcb_s *stcb,
|
||||
FAR siginfo_t *info)
|
||||
{
|
||||
FAR struct task_group_s *group = stcb->group;
|
||||
FAR sigactq_t *sigact;
|
||||
|
||||
sigact = nxsig_find_action(group, info->si_signo);
|
||||
if (sigact && (sigact->act.sa_flags & SA_KERNELHAND))
|
||||
{
|
||||
info->si_user = sigact->act.sa_user;
|
||||
(sigact->act.sa_sigaction)(info->si_signo, info, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsig_add_pendingsignal
|
||||
*
|
||||
|
|
@ -381,12 +382,18 @@ static int nxsig_alloc_dyn_pending(FAR irqstate_t *flags)
|
|||
{
|
||||
int ret = OK;
|
||||
bool alloc_signal = sq_empty(&g_sigpendingsignal);
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
bool alloc_sigact = sq_empty(&g_sigpendingaction);
|
||||
|
||||
if (alloc_signal || alloc_sigact)
|
||||
#else
|
||||
if (alloc_signal)
|
||||
#endif
|
||||
{
|
||||
FAR sigpendq_t *sigpend = NULL;
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
FAR sigq_t *sigq = NULL;
|
||||
#endif
|
||||
|
||||
/* We can't do memory allocations in idle task or interrupt */
|
||||
|
||||
|
|
@ -406,12 +413,14 @@ static int nxsig_alloc_dyn_pending(FAR irqstate_t *flags)
|
|||
sigpend = kmm_malloc(sizeof(sigpendq_t));
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
/* Allocate more pending signal actions if there are no more */
|
||||
|
||||
if (alloc_sigact)
|
||||
{
|
||||
sigq = kmm_malloc(sizeof(sigq_t));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Restore critical section and add the allocated structures to
|
||||
* the free pending queues
|
||||
|
|
@ -432,6 +441,7 @@ static int nxsig_alloc_dyn_pending(FAR irqstate_t *flags)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
if (alloc_sigact)
|
||||
{
|
||||
if (sigq)
|
||||
|
|
@ -444,11 +454,11 @@ static int nxsig_alloc_dyn_pending(FAR irqstate_t *flags)
|
|||
ret = -EAGAIN;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
|
@ -483,9 +493,9 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info,
|
|||
irqstate_t flags;
|
||||
int masked;
|
||||
int ret = OK;
|
||||
FAR sigpendq_t *sigpend = NULL;
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
FAR sigactq_t *sigact;
|
||||
FAR sigpendq_t *sigpend = NULL;
|
||||
#endif
|
||||
|
||||
sinfo("TCB=%p pid=%d signo=%d code=%d value=%d masked=%s\n",
|
||||
|
|
@ -519,14 +529,12 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info,
|
|||
* needs to be done here before using the task state or sigprocmask.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
ret = nxsig_alloc_dyn_pending(&flags);
|
||||
if (ret < 0)
|
||||
{
|
||||
leave_critical_section(flags);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
masked = nxsig_ismember(&stcb->sigprocmask, info->si_signo);
|
||||
|
||||
|
|
@ -594,19 +602,16 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info,
|
|||
up_switch_context(this_task(), rtcb);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
# ifdef CONFIG_LIB_SYSCALL
|
||||
#if defined(CONFIG_LIB_SYSCALL) && defined(CONFIG_ENABLE_ALL_SIGNALS)
|
||||
/* Must also add signal action if in system call */
|
||||
|
||||
if (masked == 0)
|
||||
{
|
||||
sigpend = nxsig_add_pendingsignal(stcb, info, group_dispatch);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
/* Its not one we are waiting for... Add it to the list of pending
|
||||
* signals.
|
||||
*/
|
||||
|
|
@ -615,7 +620,6 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info,
|
|||
{
|
||||
sigpend = nxsig_add_pendingsignal(stcb, info, group_dispatch);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/************************* UNMASKED SIGNAL ACTIONS ************************/
|
||||
|
|
@ -727,14 +731,14 @@ int nxsig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info,
|
|||
|
||||
leave_critical_section(flags);
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
/* Dispatch kernel action, if needed, in case a pending signal was added */
|
||||
|
||||
if (sigpend != NULL)
|
||||
{
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
nxsig_dispatch_kernel_action(stcb, &sigpend->info);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* In case nxsig_ismember failed due to an invalid signal number */
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,10 @@
|
|||
|
||||
struct sigpool_s
|
||||
{
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
sigq_t sigq[NUM_PENDING_ACTIONS +
|
||||
CONFIG_SIG_PREALLOC_IRQ_ACTIONS];
|
||||
#endif
|
||||
sigpendq_t sigpendq[NUM_SIGNALS_PENDING +
|
||||
CONFIG_SIG_PREALLOC_IRQ_ACTIONS];
|
||||
};
|
||||
|
|
@ -53,9 +55,8 @@ struct sigpool_s
|
|||
|
||||
/* This is a pool of pre-allocated signal action structures buffers */
|
||||
|
||||
#if CONFIG_SIG_PREALLOC_ACTIONS > 0
|
||||
#if defined(CONFIG_ENABLE_ALL_SIGNALS) && CONFIG_SIG_PREALLOC_ACTIONS > 0
|
||||
sigactq_t g_sigactions[CONFIG_SIG_PREALLOC_ACTIONS];
|
||||
#endif
|
||||
|
||||
/* The g_sigfreeaction data structure is a list of available signal
|
||||
* action structures.
|
||||
|
|
@ -74,6 +75,7 @@ sq_queue_t g_sigpendingaction;
|
|||
*/
|
||||
|
||||
sq_queue_t g_sigpendingirqaction;
|
||||
#endif
|
||||
|
||||
/* The g_sigpendingsignal data structure is a list of available pending
|
||||
* signal structures.
|
||||
|
|
@ -100,7 +102,7 @@ static struct sigpool_s g_sigpool;
|
|||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
#if CONFIG_SIG_PREALLOC_ACTIONS > 0
|
||||
#if defined(CONFIG_ENABLE_ALL_SIGNALS) && CONFIG_SIG_PREALLOC_ACTIONS > 0
|
||||
static void nxsig_init_signalactionblock(sq_queue_t *siglist,
|
||||
FAR sigactq_t *sigact,
|
||||
uint16_t nsigs)
|
||||
|
|
@ -125,6 +127,7 @@ static void nxsig_init_signalactionblock(sq_queue_t *siglist,
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
static void *nxsig_init_block(sq_queue_t *siglist, FAR sigq_t *sigq,
|
||||
uint16_t nsigs, uint8_t sigtype)
|
||||
{
|
||||
|
|
@ -138,6 +141,7 @@ static void *nxsig_init_block(sq_queue_t *siglist, FAR sigq_t *sigq,
|
|||
|
||||
return sigq;
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxsig_init_pendingsignalblock
|
||||
|
|
@ -184,12 +188,15 @@ void nxsig_initialize(void)
|
|||
|
||||
/* Initialize free lists */
|
||||
|
||||
#if defined(CONFIG_ENABLE_ALL_SIGNALS) && CONFIG_SIG_PREALLOC_ACTIONS > 0
|
||||
sq_init(&g_sigfreeaction);
|
||||
sq_init(&g_sigpendingaction);
|
||||
sq_init(&g_sigpendingirqaction);
|
||||
#endif
|
||||
sq_init(&g_sigpendingsignal);
|
||||
sq_init(&g_sigpendingirqsignal);
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
nxsig_init_signalactionblock(&g_sigfreeaction,
|
||||
g_sigactions,
|
||||
CONFIG_SIG_PREALLOC_ACTIONS);
|
||||
|
|
@ -198,6 +205,8 @@ void nxsig_initialize(void)
|
|||
sigpool = nxsig_init_block(&g_sigpendingirqaction, sigpool,
|
||||
CONFIG_SIG_PREALLOC_IRQ_ACTIONS,
|
||||
SIG_ALLOC_IRQ);
|
||||
#endif
|
||||
|
||||
sigpool = nxsig_init_pendingsignalblock(&g_sigpendingsignal, sigpool,
|
||||
NUM_SIGNALS_PENDING,
|
||||
SIG_ALLOC_FIXED);
|
||||
|
|
|
|||
|
|
@ -77,10 +77,12 @@
|
|||
|
||||
int nxsig_kill(pid_t pid, int signo)
|
||||
{
|
||||
#ifdef CONFIG_SCHED_HAVE_PARENT
|
||||
#if !defined(CONFIG_DISABLE_ALL_SIGNALS) && defined(CONFIG_SCHED_HAVE_PARENT)
|
||||
FAR struct tcb_s *rtcb = this_task();
|
||||
#endif
|
||||
#ifndef CONFIG_DISABLE_ALL_SIGNALS
|
||||
siginfo_t info;
|
||||
#endif
|
||||
|
||||
/* We do not support sending signals to process groups */
|
||||
|
||||
|
|
@ -89,6 +91,14 @@ int nxsig_kill(pid_t pid, int signo)
|
|||
return -ENOSYS;
|
||||
}
|
||||
|
||||
if (signo == 0)
|
||||
{
|
||||
return (nxsched_get_tcb(pid) != NULL) ? 0 : -ESRCH;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DISABLE_ALL_SIGNALS
|
||||
return -ENOSYS;
|
||||
#else
|
||||
/* Make sure that the signal is valid */
|
||||
|
||||
if (!GOOD_SIGNO(signo))
|
||||
|
|
@ -110,6 +120,7 @@ int nxsig_kill(pid_t pid, int signo)
|
|||
/* Send the signal */
|
||||
|
||||
return nxsig_dispatch(pid, &info, false);
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
|||
|
|
@ -145,9 +145,7 @@ int nxsig_procmask(int how, FAR const sigset_t *set, FAR sigset_t *oset)
|
|||
|
||||
/* Now, process any pending signals that were just unmasked */
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
nxsig_unmask_pendingsignal();
|
||||
#endif
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -75,12 +75,22 @@ int nxsig_tgkill(pid_t pid, pid_t tid, int signo)
|
|||
* will just deliver the signal to the thread ID it is requested to use.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_SCHED_HAVE_PARENT
|
||||
#if !defined(CONFIG_DISABLE_ALL_SIGNALS) && defined(CONFIG_SCHED_HAVE_PARENT)
|
||||
FAR struct tcb_s *rtcb = this_task();
|
||||
#endif
|
||||
#ifndef CONFIG_DISABLE_ALL_SIGNALS
|
||||
siginfo_t info;
|
||||
int ret;
|
||||
#endif
|
||||
|
||||
if (signo == 0)
|
||||
{
|
||||
return (nxsched_get_tcb(tid) != NULL) ? 0 : -ESRCH;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DISABLE_ALL_SIGNALS
|
||||
return -ENOSYS;
|
||||
#else
|
||||
/* Make sure that the signal is valid */
|
||||
|
||||
if (!GOOD_SIGNO(signo))
|
||||
|
|
@ -104,6 +114,7 @@ int nxsig_tgkill(pid_t pid, pid_t tid, int signo)
|
|||
|
||||
errout:
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
|||
|
|
@ -103,10 +103,8 @@ int nxsig_timedwait(FAR const sigset_t *set, FAR struct siginfo *info,
|
|||
FAR const struct timespec *timeout)
|
||||
{
|
||||
FAR struct tcb_s *rtcb;
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
sigset_t intersection;
|
||||
FAR sigpendq_t *sigpend;
|
||||
#endif
|
||||
irqstate_t flags;
|
||||
siginfo_t unbinfo;
|
||||
int ret;
|
||||
|
|
@ -122,7 +120,6 @@ int nxsig_timedwait(FAR const sigset_t *set, FAR struct siginfo *info,
|
|||
flags = enter_critical_section();
|
||||
rtcb = this_task();
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
/* Check if there is a pending signal corresponding to one of the
|
||||
* signals in the pending signal set argument.
|
||||
*/
|
||||
|
|
@ -159,7 +156,6 @@ int nxsig_timedwait(FAR const sigset_t *set, FAR struct siginfo *info,
|
|||
/* We will have to wait for a signal to be posted to this task. */
|
||||
|
||||
else
|
||||
#endif
|
||||
{
|
||||
rtcb->sigunbinfo = (info == NULL) ? &unbinfo : info;
|
||||
|
||||
|
|
|
|||
|
|
@ -166,9 +166,7 @@ struct task_group_s;
|
|||
|
||||
/* sig_initializee.c */
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
void nxsig_initialize(void);
|
||||
#endif
|
||||
|
||||
/* sig_action.c */
|
||||
|
||||
|
|
@ -194,10 +192,8 @@ int nxsig_dispatch(pid_t pid, FAR siginfo_t *info,
|
|||
|
||||
/* sig_cleanup.c */
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
void nxsig_cleanup(FAR struct tcb_s *stcb);
|
||||
void nxsig_release(FAR struct task_group_s *group);
|
||||
#endif
|
||||
|
||||
/* sig_timedwait.c */
|
||||
|
||||
|
|
@ -215,6 +211,13 @@ void nxsig_release_pendingsigaction(FAR sigq_t *sigq);
|
|||
void nxsig_release_pendingsignal(FAR sigpendq_t *sigpend);
|
||||
FAR sigpendq_t *nxsig_remove_pendingsignal(FAR struct tcb_s *stcb,
|
||||
int signo);
|
||||
#ifndef CONFIG_DISABLE_ALL_SIGNALS
|
||||
bool nxsig_unmask_pendingsignal(void);
|
||||
#else
|
||||
static inline bool nxsig_unmask_pendingsignal(void)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __SCHED_SIGNAL_SIGNAL_H */
|
||||
|
|
|
|||
|
|
@ -455,7 +455,7 @@ void nxtask_exithook(FAR struct tcb_s *tcb, int status)
|
|||
|
||||
/* Deallocate anything left in the TCB's queues */
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
#ifndef CONFIG_DISABLE_ALL_SIGNALS
|
||||
nxsig_cleanup(tcb); /* Deallocate Signal lists */
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -119,10 +119,8 @@ static void nxtask_reset_task(FAR struct tcb_s *tcb, bool remove)
|
|||
|
||||
/* Deallocate anything left in the TCB's signal queues */
|
||||
|
||||
#ifdef CONFIG_ENABLE_ALL_SIGNALS
|
||||
nxsig_cleanup(tcb); /* Deallocate Signal lists */
|
||||
#endif
|
||||
#ifndef CONFIG_DISABLE_ALL_SIGNALS
|
||||
nxsig_cleanup(tcb); /* Deallocate Signal lists */
|
||||
sigemptyset(&tcb->sigprocmask); /* Reset sigprocmask */
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -403,7 +403,6 @@ static int nxthread_setup_scheduler(FAR struct tcb_s *tcb, int priority,
|
|||
start_t start, CODE void *entry,
|
||||
uint8_t ttype)
|
||||
{
|
||||
FAR struct tcb_s *rtcb = this_task();
|
||||
irqstate_t flags;
|
||||
int ret;
|
||||
|
||||
|
|
@ -462,7 +461,7 @@ static int nxthread_setup_scheduler(FAR struct tcb_s *tcb, int priority,
|
|||
*/
|
||||
|
||||
#ifndef CONFIG_DISABLE_ALL_SIGNALS
|
||||
tcb->sigprocmask = rtcb->sigprocmask;
|
||||
tcb->sigprocmask = this_task()->sigprocmask;
|
||||
#endif
|
||||
|
||||
/* Initialize the task state. It does not get a valid state
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue