mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-08-30 22:21:42 +08:00
posix: Use thread action for signals
This commit is contained in:
@@ -69,8 +69,6 @@ extern Chain_Control _POSIX_signals_Inactive_siginfo;
|
||||
|
||||
extern Chain_Control _POSIX_signals_Siginfo[ SIG_ARRAY_MAX ];
|
||||
|
||||
extern API_extensions_Post_switch_control _POSIX_signals_Post_switch;
|
||||
|
||||
/*
|
||||
* Internal routines
|
||||
*/
|
||||
@@ -86,10 +84,12 @@ void _POSIX_signals_Manager_Initialization(void);
|
||||
#define _POSIX_signals_Release( lock_context ) \
|
||||
_ISR_lock_Release_and_ISR_enable( &_POSIX_signals_Lock, lock_context )
|
||||
|
||||
static inline void _POSIX_signals_Add_post_switch_extension(void)
|
||||
{
|
||||
_API_extensions_Add_post_switch( &_POSIX_signals_Post_switch );
|
||||
}
|
||||
void _POSIX_signals_Action_handler(
|
||||
Thread_Control *executing,
|
||||
Thread_Action *action,
|
||||
Per_CPU_Control *cpu,
|
||||
ISR_Level level
|
||||
);
|
||||
|
||||
/**
|
||||
* @brief Unlock POSIX signals thread.
|
||||
|
||||
@@ -68,6 +68,11 @@ typedef struct {
|
||||
/** This is the set of signals which are currently pending. */
|
||||
sigset_t signals_pending;
|
||||
|
||||
/**
|
||||
* @brief Signal post-switch action in case signals are pending.
|
||||
*/
|
||||
Thread_Action Signal_action;
|
||||
|
||||
/*******************************************************************/
|
||||
/*******************************************************************/
|
||||
/*************** POSIX Cancelability ***************/
|
||||
|
||||
@@ -121,8 +121,6 @@ int killinfo(
|
||||
|
||||
_Thread_Disable_dispatch();
|
||||
|
||||
_POSIX_signals_Add_post_switch_extension();
|
||||
|
||||
/*
|
||||
* Is the currently executing thread interested? If so then it will
|
||||
* get it an execute it as soon as the dispatcher executes.
|
||||
|
||||
+10
-13
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <rtems/score/isrlevel.h>
|
||||
#include <rtems/score/statesimpl.h>
|
||||
#include <rtems/score/threadimpl.h>
|
||||
#include <rtems/score/threadqimpl.h>
|
||||
#include <rtems/score/watchdogimpl.h>
|
||||
#include <rtems/score/wkspace.h>
|
||||
@@ -108,22 +109,22 @@ Chain_Control _POSIX_signals_Siginfo[ SIG_ARRAY_MAX ];
|
||||
(STATES_WAITING_FOR_SIGNAL|STATES_INTERRUPTIBLE_BY_SIGNAL)) == \
|
||||
(STATES_WAITING_FOR_SIGNAL|STATES_INTERRUPTIBLE_BY_SIGNAL))
|
||||
|
||||
/*
|
||||
* _POSIX_signals_Post_switch_extension
|
||||
*/
|
||||
|
||||
static void _POSIX_signals_Post_switch_hook(
|
||||
Thread_Control *the_thread
|
||||
void _POSIX_signals_Action_handler(
|
||||
Thread_Control *executing,
|
||||
Thread_Action *action,
|
||||
Per_CPU_Control *cpu,
|
||||
ISR_Level level
|
||||
)
|
||||
{
|
||||
POSIX_API_Control *api;
|
||||
int signo;
|
||||
ISR_lock_Context lock_context;
|
||||
int hold_errno;
|
||||
Thread_Control *executing;
|
||||
|
||||
executing = _Thread_Get_executing();
|
||||
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||
(void) action;
|
||||
_Thread_Action_release_and_ISR_enable( cpu, level );
|
||||
|
||||
api = executing->API_Extensions[ THREAD_API_POSIX ];
|
||||
|
||||
/*
|
||||
* We need to ensure that if the signal handler executes a call
|
||||
@@ -169,10 +170,6 @@ static void _POSIX_signals_Post_switch_hook(
|
||||
executing->Wait.return_code = hold_errno;
|
||||
}
|
||||
|
||||
API_extensions_Post_switch_control _POSIX_signals_Post_switch = {
|
||||
.hook = _POSIX_signals_Post_switch_hook
|
||||
};
|
||||
|
||||
void _POSIX_signals_Manager_Initialization(void)
|
||||
{
|
||||
uint32_t signo;
|
||||
|
||||
@@ -47,6 +47,8 @@ bool _POSIX_signals_Unblock_thread(
|
||||
|
||||
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||
|
||||
_Thread_Add_post_switch_action( the_thread, &api->Signal_action );
|
||||
|
||||
mask = signo_to_mask( signo );
|
||||
|
||||
/*
|
||||
|
||||
@@ -233,6 +233,11 @@ static bool _POSIX_Threads_Create_extension(
|
||||
api->signals_blocked = SIGNAL_ALL_MASK;
|
||||
}
|
||||
|
||||
_Thread_Action_initialize(
|
||||
&api->Signal_action,
|
||||
_POSIX_signals_Action_handler
|
||||
);
|
||||
|
||||
_Thread_queue_Initialize(
|
||||
&api->Join_List,
|
||||
THREAD_QUEUE_DISCIPLINE_FIFO,
|
||||
|
||||
@@ -53,8 +53,6 @@ int pthread_kill(
|
||||
* If sig == 0 then just validate arguments
|
||||
*/
|
||||
|
||||
_POSIX_signals_Add_post_switch_extension();
|
||||
|
||||
api = the_thread->API_Extensions[ THREAD_API_POSIX ];
|
||||
|
||||
if ( sig ) {
|
||||
|
||||
Reference in New Issue
Block a user