2008-01-10 20:16:50 +01:00
|
|
|
/****************************************************************************
|
2014-08-08 20:44:44 +02:00
|
|
|
* sched/signal/signal.h
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
2014-08-08 20:44:44 +02:00
|
|
|
* Copyright (C) 2007-2009, 2013-2014 Gregory Nutt. All rights reserved.
|
2012-07-14 21:30:31 +02:00
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
2007-02-18 00:21:28 +01:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
2008-01-10 20:16:50 +01:00
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
2007-02-18 00:21:28 +01:00
|
|
|
* used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
2008-01-10 20:16:50 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2014-08-08 20:44:44 +02:00
|
|
|
#ifndef __SCHED_SIGNAL_SIGNAL_H
|
|
|
|
#define __SCHED_SIGNAL_SIGNAL_H
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Included Files
|
2008-01-10 20:16:50 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2007-02-27 22:17:21 +01:00
|
|
|
#include <nuttx/compiler.h>
|
2009-12-14 20:30:18 +01:00
|
|
|
|
|
|
|
#include <stdint.h>
|
2007-02-18 00:21:28 +01:00
|
|
|
#include <queue.h>
|
|
|
|
#include <sched.h>
|
2009-12-14 20:30:18 +01:00
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
#include <nuttx/kmalloc.h>
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/****************************************************************************
|
2015-04-08 14:47:36 +02:00
|
|
|
* Pre-processor Definitions
|
2008-01-10 20:16:50 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* The following definition determines the number of signal structures to
|
|
|
|
* allocate in a block
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define NUM_SIGNAL_ACTIONS 16
|
|
|
|
#define NUM_PENDING_ACTIONS 16
|
|
|
|
#define NUM_PENDING_INT_ACTIONS 8
|
|
|
|
#define NUM_SIGNALS_PENDING 16
|
|
|
|
#define NUM_INT_SIGNALS_PENDING 8
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Public Type Definitions
|
2008-01-10 20:16:50 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
enum sigalloc_e
|
|
|
|
{
|
|
|
|
SIG_ALLOC_FIXED = 0, /* pre-allocated; never freed */
|
|
|
|
SIG_ALLOC_DYN, /* dynamically allocated; free when unused */
|
|
|
|
SIG_ALLOC_IRQ /* Preallocated, reserved for interrupt handling */
|
|
|
|
};
|
|
|
|
typedef enum sigalloc_e sigalloc_t;
|
|
|
|
|
|
|
|
/* The following defines the sigaction queue entry */
|
|
|
|
|
|
|
|
struct sigactq
|
|
|
|
{
|
2007-02-27 22:17:21 +01:00
|
|
|
FAR struct sigactq *flink; /* Forward link */
|
|
|
|
struct sigaction act; /* Sigaction data */
|
2009-12-14 19:39:29 +01:00
|
|
|
uint8_t signo; /* Signal associated with action */
|
2007-02-18 00:21:28 +01:00
|
|
|
};
|
|
|
|
typedef struct sigactq sigactq_t;
|
|
|
|
|
2012-07-14 21:30:31 +02:00
|
|
|
/* The following defines the queue structure within each TCB to hold pending
|
|
|
|
* signals received by the task. These are signals that cannot be processed
|
|
|
|
* because: (1) the task is not waiting for them, or (2) the task has no
|
|
|
|
* action associated with the signal.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct sigpendq
|
|
|
|
{
|
2007-02-27 22:17:21 +01:00
|
|
|
FAR struct sigpendq *flink; /* Forward link */
|
|
|
|
siginfo_t info; /* Signal information */
|
2009-12-14 19:39:29 +01:00
|
|
|
uint8_t type; /* (Used to manage allocations) */
|
2007-02-18 00:21:28 +01:00
|
|
|
};
|
|
|
|
typedef struct sigpendq sigpendq_t;
|
|
|
|
|
2012-07-14 21:30:31 +02:00
|
|
|
/* The following defines the queue structure within each TCB to hold queued
|
|
|
|
* signal actions that need action by the task
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct sigq_s
|
|
|
|
{
|
2007-02-27 22:17:21 +01:00
|
|
|
FAR struct sigq_s *flink; /* Forward link */
|
2007-02-18 00:21:28 +01:00
|
|
|
union
|
|
|
|
{
|
2007-02-21 03:19:19 +01:00
|
|
|
void (*sighandler)(int signo, siginfo_t *info, void *context);
|
2007-02-18 00:21:28 +01:00
|
|
|
} action; /* Signal action */
|
2007-02-27 22:17:21 +01:00
|
|
|
sigset_t mask; /* Additional signals to mask while the
|
2012-07-14 21:30:31 +02:00
|
|
|
* the signal-catching function executes */
|
2007-02-27 22:17:21 +01:00
|
|
|
siginfo_t info; /* Signal information */
|
2009-12-14 19:39:29 +01:00
|
|
|
uint8_t type; /* (Used to manage allocations) */
|
2007-02-18 00:21:28 +01:00
|
|
|
};
|
|
|
|
typedef struct sigq_s sigq_t;
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/****************************************************************************
|
2015-10-03 00:30:35 +02:00
|
|
|
* Public Data
|
2008-01-10 20:16:50 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* The g_sigfreeaction data structure is a list of available signal action
|
|
|
|
* structures.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern sq_queue_t g_sigfreeaction;
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* The g_sigpendingaction data structure is a list of available pending
|
|
|
|
* signal action structures.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern sq_queue_t g_sigpendingaction;
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* The g_sigpendingirqaction is a list of available pending signal actions
|
|
|
|
* that are reserved for use by interrupt handlers.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern sq_queue_t g_sigpendingirqaction;
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* The g_sigpendingsignal data structure is a list of available pending
|
|
|
|
* signal structures.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern sq_queue_t g_sigpendingsignal;
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* The g_sigpendingirqsignal data structure is a list of available pending
|
|
|
|
* signal structures that are reserved for use by interrupt handlers.
|
2007-02-18 00:21:28 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
extern sq_queue_t g_sigpendingirqsignal;
|
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/****************************************************************************
|
2007-02-18 00:21:28 +01:00
|
|
|
* Public Function Prototypes
|
2008-01-10 20:16:50 +01:00
|
|
|
****************************************************************************/
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2008-01-10 20:16:50 +01:00
|
|
|
/* Internal signal-related interfaces ***************************************/
|
2013-10-01 20:10:09 +02:00
|
|
|
/* Forward references */
|
|
|
|
|
|
|
|
struct task_group_s;
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-12-05 17:37:55 +01:00
|
|
|
/* sig_initializee.c */
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2012-07-14 21:30:31 +02:00
|
|
|
void weak_function sig_initialize(void);
|
|
|
|
void sig_allocateactionblock(void);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
/* sig_action.c */
|
|
|
|
|
2012-07-14 21:30:31 +02:00
|
|
|
void sig_releaseaction(FAR sigactq_t *sigact);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
|
|
|
/* sig_pending.c */
|
|
|
|
|
2013-02-04 19:46:28 +01:00
|
|
|
sigset_t sig_pendingset(FAR struct tcb_s *stcb);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2013-02-05 20:50:37 +01:00
|
|
|
/* sig_dispatch.c */
|
|
|
|
|
|
|
|
int sig_tcbdispatch(FAR struct tcb_s *stcb, FAR siginfo_t *info);
|
|
|
|
int sig_dispatch(pid_t pid, FAR siginfo_t *info);
|
|
|
|
|
|
|
|
/* sig_cleanup.c */
|
|
|
|
|
|
|
|
void sig_cleanup(FAR struct tcb_s *stcb);
|
|
|
|
void sig_release(FAR struct task_group_s *group);
|
|
|
|
|
2007-02-18 00:21:28 +01:00
|
|
|
/* In files of the same name */
|
|
|
|
|
2012-07-14 21:30:31 +02:00
|
|
|
FAR sigq_t *sig_allocatependingsigaction(void);
|
2013-02-04 19:46:28 +01:00
|
|
|
void sig_deliver(FAR struct tcb_s *stcb);
|
2016-02-18 15:34:11 +01:00
|
|
|
FAR sigactq_t *sig_findaction(FAR struct task_group_s *group, int signo);
|
2012-07-14 21:30:31 +02:00
|
|
|
int sig_lowest(FAR sigset_t *set);
|
2007-02-21 00:51:56 +01:00
|
|
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
2012-07-14 21:30:31 +02:00
|
|
|
int sig_mqnotempty(int tid, int signo, union sigval value);
|
2007-02-21 00:51:56 +01:00
|
|
|
#else
|
2012-07-14 21:30:31 +02:00
|
|
|
int sig_mqnotempty(int tid, int signo, FAR void *sival_ptr);
|
2007-02-21 00:51:56 +01:00
|
|
|
#endif
|
2012-07-14 21:30:31 +02:00
|
|
|
void sig_releasependingsigaction(FAR sigq_t *sigq);
|
|
|
|
void sig_releasependingsignal(FAR sigpendq_t *sigpend);
|
2013-02-04 19:46:28 +01:00
|
|
|
FAR sigpendq_t *sig_removependingsignal(FAR struct tcb_s *stcb, int signo);
|
2012-07-14 21:30:31 +02:00
|
|
|
void sig_unmaskpendingsignal(void);
|
2007-02-18 00:21:28 +01:00
|
|
|
|
2014-08-08 20:44:44 +02:00
|
|
|
#endif /* __SCHED_SIGNAL_SIGNAL_H */
|