VirtualBox

Changeset 71150 in vbox


Ignore:
Timestamp:
Feb 28, 2018 10:44:38 AM (7 years ago)
Author:
vboxsync
Message:

IPRT: Added a RTThreadPoke implementation for windows that uses NtAlertThread.

Location:
trunk
Files:
4 edited

Legend:

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

    r71127 r71150  
    483483 * Pokes the thread.
    484484 *
    485  * This will signal the thread, attempting to interrupt whatever it's currently
    486  * doing.  This is *NOT* implemented on all platforms and may cause unresolved
    487  * symbols during linking or VERR_NOT_IMPLEMENTED at runtime.
     485 * This will wake up or/and signal the thread, attempting to interrupt whatever
     486 * it's currently doing.
     487 *
     488 * The posixy version of this will send a signal to the thread, quite likely
     489 * waking it up from normal sleeps, waits, and I/O.  When IPRT is in
     490 * non-obtrusive mode, the posixy version will definitely return
     491 * VERR_NOT_IMPLEMENTED, and it may also do so if no usable signal was found.
     492 *
     493 * On Windows the thread will be alerted, waking it up from most sleeps and
     494 * waits, but not probably very little in the I/O area (needs testing).  On NT
     495 * 3.50 and 3.1 VERR_NOT_IMPLEMENTED will be returned.
    488496 *
    489497 * @returns IPRT status code.
     
    491499 * @param   hThread             The thread to poke.  This must not be the
    492500 *                              calling thread.
     501 *
     502 * @note    This is *NOT* implemented on all platforms and may cause unresolved
     503 *          symbols during linking or VERR_NOT_IMPLEMENTED at runtime.
     504 *
    493505 */
    494506RTDECL(int) RTThreadPoke(RTTHREAD hThread);
  • trunk/src/VBox/Runtime/r3/win/init-win.cpp

    r70361 r71150  
    8484/** NtDuplicateToken (NT 3.51). */
    8585DECLHIDDEN(PFNNTDUPLICATETOKEN)             g_pfnNtDuplicateToken = NULL;
     86/** NtAlertThread (NT 3.51). */
     87decltype(NtAlertThread)                    *g_pfnNtAlertThread = NULL;
    8688
    8789/** Either ws2_32.dll (NT4+) or wsock32.dll (NT3.x). */
     
    513515    g_pfnNtQueryFullAttributesFile = (PFNNTQUERYFULLATTRIBUTESFILE)GetProcAddress(g_hModNtDll, "NtQueryFullAttributesFile");
    514516    g_pfnNtDuplicateToken          = (PFNNTDUPLICATETOKEN)GetProcAddress(         g_hModNtDll, "NtDuplicateToken");
    515 
     517    g_pfnNtAlertThread             = (decltype(NtAlertThread) *)GetProcAddress(   g_hModNtDll, "NtAlertThread");
    516518
    517519    /*
  • trunk/src/VBox/Runtime/r3/win/internal-r3-win.h

    r70345 r71150  
    109109typedef NTSTATUS (NTAPI *PFNNTDUPLICATETOKEN)(HANDLE, ACCESS_MASK, struct _OBJECT_ATTRIBUTES *, BOOLEAN, TOKEN_TYPE, PHANDLE);
    110110extern DECLHIDDEN(PFNNTDUPLICATETOKEN)             g_pfnNtDuplicateToken;
     111#ifdef ___iprt_nt_nt_h___
     112extern decltype(NtAlertThread)                    *g_pfnNtAlertThread;
     113#endif
    111114
    112115extern DECLHIDDEN(HMODULE)                         g_hModWinSock;
  • trunk/src/VBox/Runtime/r3/win/thread-win.cpp

    r71127 r71150  
    4545#include <iprt/mem.h>
    4646#include "internal/thread.h"
     47#include "internal-r3-win.h"
    4748
    4849
     
    400401RT_EXPORT_SYMBOL(RTThreadGetNativeHandle);
    401402
     403
     404RTDECL(int) RTThreadPoke(RTTHREAD hThread)
     405{
     406    AssertReturn(hThread != RTThreadSelf(), VERR_INVALID_PARAMETER);
     407    if (g_pfnNtAlertThread)
     408    {
     409        PRTTHREADINT pThread = rtThreadGet(hThread);
     410        AssertReturn(pThread, VERR_INVALID_HANDLE);
     411
     412        NTSTATUS rcNt = g_pfnNtAlertThread((HANDLE)pThread->hThread);
     413
     414        rtThreadRelease(pThread);
     415        if (NT_SUCCESS(rcNt))
     416            return VINF_SUCCESS;
     417        return RTErrConvertFromErrno(rcNt);
     418    }
     419    return VERR_NOT_IMPLEMENTED;
     420}
     421
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