improve thread signal support, still far from good

This commit is contained in:
U-w7\vsc
2013-11-04 15:31:26 +00:00
parent a9b025e6a1
commit f2b90a1bb0
6 changed files with 57 additions and 2 deletions

View File

@@ -2479,6 +2479,41 @@ X_API int PL_thread_self(void)
#endif
}
static int
alertThread(int tid)
{
return pthread_kill(REMOTE_ThreadHandle(tid).pthread_handle, YAP_ALARM_SIGNAL) == 0;
}
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PL_thread_raise() is used for re-routing interrupts in the Windows
version, where the signal handler is running from a different thread as
Prolog.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
int
PL_thread_raise(int tid, int sig)
{
PL_LOCK(L_THREAD);
if ( tid < 1 )
{ error:
PL_UNLOCK(L_THREAD);
return FALSE;
}
if ( !REMOTE_ThreadHandle(tid).in_use )
goto error;
if ( !raiseSignal(tid, sig) ||
!alertThread(tid) )
goto error;
PL_UNLOCK(L_THREAD);
return TRUE;
}
X_API int PL_unify_thread_id(term_t t, int i)
{
CACHE_REGS