VirtualBox

Changeset 13653 in vbox


Ignore:
Timestamp:
Oct 29, 2008 2:28:27 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
38595
Message:

IPRT: RTThreadPoke for posix.

Location:
trunk
Files:
2 edited

Legend:

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

    r13254 r13653  
    371371 */
    372372RTDECL(int) RTThreadUserReset(RTTHREAD Thread);
     373
     374/**
     375 * Pokes the thread.
     376 *
     377 * This will signal the thread, attempting to interrupt whatever it's currently
     378 * doing.  This is *NOT* implemented on all platforms and may cause unresolved
     379 * symbols during or VERR_NOT_IMPLEMENTED at runtime.
     380 *
     381 * @returns IPRT status code.
     382 *
     383 * @param   hThread             The thread to poke.  This must not be the
     384 *                              calling thread.
     385 */
     386RTDECL(int) RTThreadPoke(RTTHREAD hThread);
    373387
    374388#ifdef IN_RING0
  • trunk/src/VBox/Runtime/r3/posix/thread-posix.cpp

    r8245 r13653  
    6161static void *rtThreadNativeMain(void *pvArgs);
    6262static void rtThreadKeyDestruct(void *pvValue);
    63 
     63static void rtThreadPosixPokeSignal(int iSignal);
    6464
    6565int rtThreadNativeInit(void)
     
    6969     * a threads RTTHREADINT structure.
    7070     */
    71 
    7271    int rc = pthread_key_create(&g_SelfKey, rtThreadKeyDestruct);
    73     if (!rc)
    74         return VINF_SUCCESS;
    75     return VERR_NO_TLS_FOR_SELF;
     72    if (rc)
     73        return VERR_NO_TLS_FOR_SELF;
     74
     75    /*
     76     * Register the dummy signal handler for RTThreadPoke.
     77     */
     78    void (*pfnOld)(int);
     79    pfnOld = signal(SIGUSR2, rtThreadPosixPokeSignal);
     80    Assert(pfnOld == SIG_DFL);
     81    return rc;
    7682}
    7783
     
    9399        pthread_setspecific(g_SelfKey, NULL);
    94100    }
     101}
     102
     103
     104/**
     105 * Dummy signal handler for the poke signal.
     106 *
     107 * @param   iSignal     The signal number.
     108 */
     109static void rtThreadPosixPokeSignal(int iSignal)
     110{
     111    Assert(iSignal == SIGUSR2);
     112    NOREF(iSignal);
    95113}
    96114
     
    277295}
    278296
     297
     298RTDECL(int) RTThreadPoke(RTTHREAD hThread)
     299{
     300    AssertReturn(hThread != RTThreadSelf(), VERR_INVALID_PARAMETER);
     301    PRTTHREADINT pThread = rtThreadGet(hThread);
     302    AssertReturn(pThread, VERR_INVALID_HANDLE);
     303
     304    int rc = pthread_kill((pthread_t)(uintptr_t)pThread->Core.Key, SIGUSR2);
     305
     306    rtThreadRelease(pThread);
     307    return RTErrConvertFromErrno(rc);
     308}
Note: See TracChangeset for help on using the changeset viewer.

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