Changeset 4229 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Aug 19, 2007 4:24:51 PM (17 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/Makefile.kmk
r4219 r4229 777 777 r0drv/nt/spinlock-r0drv-nt.cpp \ 778 778 r0drv/nt/thread-r0drv-nt.cpp \ 779 r0drv/nt/thread2-r0drv-nt.cpp \ 779 780 string/strncmp.cpp 780 781 -
trunk/src/VBox/Runtime/include/internal/thread.h
r4071 r4229 85 85 RTTHREADSTATE volatile enmState; 86 86 #if defined(RT_OS_WINDOWS) && defined(IN_RING3) 87 /** The thread handle .87 /** The thread handle 88 88 * This is not valid until the create function has returned! */ 89 89 uintptr_t hThread; -
trunk/src/VBox/Runtime/r0drv/nt/thread2-r0drv-nt.cpp
r4071 r4229 22 22 23 23 #include <iprt/thread.h> 24 #include <iprt/assert.h> 24 25 #include <iprt/err.h> 25 26 26 27 #include "internal/thread.h" 28 29 30 int rtThreadNativeInit(void) 31 { 32 /* No TLS in Ring-0. :-/ */ 33 return VINF_SUCCESS; 34 } 27 35 28 36 … … 32 40 } 33 41 42 43 int rtThreadNativeSetPriority(PRTTHREADINT pThread, RTTHREADTYPE enmType) 44 { 45 /* 46 * Convert the IPRT priority type to NT priority. 47 * 48 * The NT priority is in the range 0..32, with realtime starting 49 * at 16 and the default for user processes at 8. (Should try find 50 * the appropriate #defines for some of this...) 51 */ 52 KPRIORITY Priority; 53 switch (enmType) 54 { 55 case RTTHREADTYPE_INFREQUENT_POLLER: Priority = 6; break; 56 case RTTHREADTYPE_EMULATION: Priority = 7; break; 57 case RTTHREADTYPE_DEFAULT: Priority = 8; break; 58 case RTTHREADTYPE_MSG_PUMP: Priority = 9; break; 59 case RTTHREADTYPE_IO: Priority = LOW_REALTIME_PRIORITY; break; 60 case RTTHREADTYPE_TIMER: Priority = MAXIMUM_PRIORITY; break; 61 62 default: 63 AssertMsgFailed(("enmType=%d\n", enmType)); 64 return VERR_INVALID_PARAMETER; 65 } 66 67 /* 68 * Do the actual modification. 69 */ 70 NTSTATUS rc = KeSetPriorityThread((PKTHREAD)pThread->Core.Key, Priority); 71 AssertMsg(NT_SUCCESS(rc), ("%#x\n", rc)); 72 return RTErrConvertFromNtStatus(rc); 73 } 74 75 76 int rtThreadNativeAdopt(PRTTHREADINT pThread) 77 { 78 return VERR_NOT_IMPLEMENTED; 79 } 80 81 82 /** 83 * Native kernel thread wrapper function. 84 * 85 * This will forward to rtThreadMain and do termination upon return. 86 * 87 * @param pvArg Pointer to the argument package. 88 */ 89 static VOID __stdcall rtThreadNativeMain(PVOID pvArg) 90 { 91 PETHREAD Self = PsGetCurrentThread(); 92 PRTTHREADINT pThread = (PRTTHREADINT)pvArg; 93 94 rtThreadMain(pThread, (RTNATIVETHREAD)Self, &pThread->szName[0]); 95 96 ObDereferenceObject(Self); /* the rtThreadNativeCreate ref. */ 97 } 98 99 100 int rtThreadNativeCreate(PRTTHREADINT pThreadInt, PRTNATIVETHREAD pNativeThread) 101 { 102 /* 103 * PsCreateSysemThread create a thread an give us a handle in return. 104 * We requests the object for that handle and then close it, so what 105 * we keep around is the pointer to the thread object and not a handle. 106 * The thread will dereference the object before returning. 107 */ 108 HANDLE hThread = NULL; 109 OBJECT_ATTRIBUTES ObjAttr; 110 InitializeObjectAttributes(&ObjAttr, NULL, OBJ_KERNEL_HANDLE, NULL, NULL); 111 NTSTATUS rc = PsCreateSystemThread(&hThread, 112 THREAD_ALL_ACCESS, 113 &ObjAttr, 114 NULL /* ProcessHandle - kernel */, 115 NULL /* ClientID - kernel */, 116 rtThreadNativeMain, 117 pThreadInt); 118 if (NT_SUCCESS(rc)) 119 { 120 PVOID pvThreadObj; 121 rc = ObReferenceObjectByHandle(hThread, THREAD_ALL_ACCESS, NULL /* object type */, 122 KernelMode, &pvThreadObj, NULL /* handle info */); 123 if (NT_SUCCESS(rc)) 124 { 125 ZwClose(hThread); 126 *pNativeThread = (RTNATIVETHREAD)pvThreadObj; 127 } 128 else 129 AssertMsgFailed(("%#x\n", rc)); 130 } 131 return RTErrConvertFromNtStatus(rc); 132 } 133
Note:
See TracChangeset
for help on using the changeset viewer.