VirtualBox

Changeset 92507 in vbox


Ignore:
Timestamp:
Nov 19, 2021 1:57:29 AM (3 years ago)
Author:
vboxsync
Message:

IPRT/thread: Added RTThreadControlPokeSignal to help deal with RTTHREADFLAGS_NO_SIGNALS in NEM/linux mode. bugref:9044

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/mangling.h

    r92246 r92507  
    25122512# define RTThreadIsSelfKnown                            RT_MANGLER(RTThreadIsSelfKnown)
    25132513# define RTThreadNativeSelf                             RT_MANGLER(RTThreadNativeSelf)
     2514# define RTThreadControlPokeSignal                      RT_MANGLER(RTThreadControlPokeSignal) /* not-win not-os2 */
    25142515# define RTThreadPoke                                   RT_MANGLER(RTThreadPoke) /* not-win not-os2 */
    25152516# define RTThreadPreemptDisable                         RT_MANGLER(RTThreadPreemptDisable)     /* r0drv */
  • trunk/include/iprt/thread.h

    r90416 r92507  
    530530 */
    531531RTDECL(int) RTThreadPoke(RTTHREAD hThread);
     532
     533/**
     534 * Controls the masking of the signal used by RTThreadPoke on posix systems.
     535 *
     536 * This function is not available on non-posix systems.
     537 *
     538 * @returns IPRT status code.
     539 *
     540 * @param   hThread     The current thread.
     541 * @param   fEnable     Whether to enable poking (unblock) or to disable it
     542 *                      (block the signal).
     543 */
     544RTDECL(int) RTThreadControlPokeSignal(RTTHREAD hThread, bool fEnable);
     545
    532546
    533547# ifdef IN_RING0
  • trunk/src/VBox/Runtime/r3/posix/thread-posix.cpp

    r90392 r92507  
    641641
    642642#ifdef RTTHREAD_POSIX_WITH_POKE
     643
    643644RTDECL(int) RTThreadPoke(RTTHREAD hThread)
    644645{
     
    659660    return rc;
    660661}
     662
     663
     664RTDECL(int) RTThreadControlPokeSignal(RTTHREAD hThread, bool fEnable)
     665{
     666    AssertReturn(hThread == RTThreadSelf() && hThread != NIL_RTTHREAD, VERR_INVALID_PARAMETER);
     667    int rc;
     668    if (g_iSigPokeThread != -1)
     669    {
     670        sigset_t SigSet;
     671        sigemptyset(&SigSet);
     672        sigaddset(&SigSet, g_iSigPokeThread);
     673
     674        int rc2 = sigprocmask(fEnable ? SIG_UNBLOCK : SIG_BLOCK, &SigSet, NULL);
     675        if (rc2 == 0)
     676            rc = VINF_SUCCESS;
     677        else
     678        {
     679            rc = RTErrConvertFromErrno(errno);
     680            AssertMsgFailed(("rc=%Rrc errno=%d (rc2=%d)\n", rc, errno, rc2));
     681        }
     682    }
     683    else
     684        rc = VERR_NOT_SUPPORTED;
     685    return rc;
     686}
     687
     688
    661689#endif
    662690
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette