Changeset 403 in vbox for trunk/src/VBox/Runtime/r0drv/darwin/thread2-r0drv-darwin.cpp
- Timestamp:
- Jan 28, 2007 8:45:05 AM (18 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/darwin/thread2-r0drv-darwin.cpp
r375 r403 1 1 /* $Id$ */ 2 2 /** @file 3 * InnoTek Portable Runtime - Threads , Ring-0 Driver, Darwin.3 * InnoTek Portable Runtime - Threads (Part 2), Ring-0 Driver, Darwin. 4 4 */ 5 5 … … 30 30 31 31 32 RTDECL(RTTHREAD) RTThreadSelf(void)32 int rtThreadNativeInit(void) 33 33 { 34 return (RTTHREAD)current_thread(); 35 } 36 37 38 RTDECL(int) RTThreadSleep(unsigned cMillies) 39 { 40 uint64_t u64Deadline; 41 clock_interval_to_deadline(cMillies, kMillisecondScale, &u64Deadline); 42 clock_delay_until(u64Deadline); 34 /* No TLS in Ring-0. :-/ */ 43 35 return VINF_SUCCESS; 44 36 } 45 37 46 38 47 RTDECL( bool) RTThreadYield(void)39 RTDECL(RTTHREAD) RTThreadSelf(void) 48 40 { 49 thread_block(THREAD_CONTINUE_NULL); 50 return true; /* this is fishy */ 41 return rtThreadGetByNative((RTNATIVETHREAD)current_thread()); 51 42 } 52 43 53 44 54 int rtThreadNativeSetPriority( RTTHREADThread, RTTHREADTYPE enmType)45 int rtThreadNativeSetPriority(PRTTHREADINT pThread, RTTHREADTYPE enmType) 55 46 { 56 47 /* 57 48 * Convert the priority type to scheduling policies. 49 * (This is really just guess work.) 58 50 */ 59 51 bool fSetExtended = false; … … 105 97 * Do the actual modification. 106 98 */ 107 kern_return_t rc = thread_policy_set((thread_t)Thread, THREAD_PRECEDENCE_POLICY,99 kern_return_t kr = thread_policy_set((thread_t)pThread->Core.Key, THREAD_PRECEDENCE_POLICY, 108 100 (thread_policy_t)&Precedence, THREAD_PRECEDENCE_POLICY_COUNT); 109 AssertMsg( rc == KERN_SUCCESS, ("%rc\n", rc)); NOREF(rc);101 AssertMsg(kr == KERN_SUCCESS, ("%rc\n", kr)); NOREF(kr); 110 102 111 103 if (fSetExtended) 112 104 { 113 rc = thread_policy_set((thread_t)Thread, THREAD_EXTENDED_POLICY,105 kr = thread_policy_set((thread_t)pThread->Core.Key, THREAD_EXTENDED_POLICY, 114 106 (thread_policy_t)&Extended, THREAD_EXTENDED_POLICY_COUNT); 115 AssertMsg( rc == KERN_SUCCESS, ("%rc\n", rc));107 AssertMsg(kr == KERN_SUCCESS, ("%rc\n", kr)); 116 108 } 117 109 118 110 if (fSetTimeContstraint) 119 111 { 120 rc = thread_policy_set((thread_t)Thread, THREAD_TIME_CONSTRAINT_POLICY,112 kr = thread_policy_set((thread_t)pThread->Core.Key, THREAD_TIME_CONSTRAINT_POLICY, 121 113 (thread_policy_t)&TimeConstraint, THREAD_TIME_CONSTRAINT_POLICY_COUNT); 122 AssertMsg( rc == KERN_SUCCESS, ("%rc\n", rc));114 AssertMsg(kr == KERN_SUCCESS, ("%rc\n", kr)); 123 115 } 124 116 125 117 return VINF_SUCCESS; /* ignore any errors for now */ 118 } 119 120 121 int rtThreadNativeAdopt(PRTTHREADINT pThread) 122 { 123 return VERR_NOT_IMPLEMENTED; 126 124 } 127 125 … … 139 137 const thread_t Self = current_thread(); 140 138 141 rtThreadMain((PRT R0THREADARGS)pvArg, (RTNATIVETHREAD)Self);139 rtThreadMain((PRTTHREADINT)pvArg, (RTNATIVETHREAD)Self); 142 140 143 kern_return_t rc= thread_terminate(Self);144 AssertFatalMsgFailed((" rc=%d\n", rc));141 kern_return_t kr = thread_terminate(Self); 142 AssertFatalMsgFailed(("kr=%d\n", kr)); 145 143 } 146 144 147 145 148 int rtThreadNativeCreate(PRT R0THREADARGS pArgs, PRTNATIVETHREAD pNativeThread)146 int rtThreadNativeCreate(PRTTHREADINT pThreadInt, PRTNATIVETHREAD pNativeThread) 149 147 { 150 148 thread_t NativeThread; 151 kern_return_t rc = kernel_thread_start(rtThreadNativeMain, pArgs, &NativeThread);152 if ( rc== KERN_SUCCESS)149 kern_return_t kr = kernel_thread_start(rtThreadNativeMain, pThreadInt, &NativeThread); 150 if (kr == KERN_SUCCESS) 153 151 { 154 152 *pNativeThread = (RTNATIVETHREAD)NativeThread; … … 156 154 return VINF_SUCCESS; 157 155 } 158 return RTErrConvertFromMachKernReturn( rc);156 return RTErrConvertFromMachKernReturn(kr); 159 157 } 160 158
Note:
See TracChangeset
for help on using the changeset viewer.