Changeset 77910 in vbox for trunk/src/VBox/Runtime/r3/darwin/sched-darwin.cpp
- Timestamp:
- Mar 27, 2019 11:33:01 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/darwin/sched-darwin.cpp
r76553 r77910 99 99 { 100 100 { 101 RTPROCPRIORITY_DEFAULT, "Default", 102 { 103 { RTTHREADTYPE_INVALID, INT_MIN, INT_MIN }, 104 { RTTHREADTYPE_INFREQUENT_POLLER, 29, 29 }, 105 { RTTHREADTYPE_MAIN_HEAVY_WORKER, 30, 30 }, 106 { RTTHREADTYPE_EMULATION, 31, 31 }, /* the default priority */ 107 { RTTHREADTYPE_DEFAULT, 32, 32 }, 108 { RTTHREADTYPE_GUI, 32, 32 }, 109 { RTTHREADTYPE_MAIN_WORKER, 32, 32 }, 110 { RTTHREADTYPE_VRDP_IO, 39, 39 }, 111 { RTTHREADTYPE_DEBUGGER, 42, 42 }, 112 { RTTHREADTYPE_MSG_PUMP, 47, 47 }, 113 { RTTHREADTYPE_IO, 52, 52 }, 114 { RTTHREADTYPE_TIMER, 55, 55 } 115 } 116 }, 117 { 101 118 RTPROCPRIORITY_LOW, "Low", 102 119 { … … 207 224 * 208 225 * @returns The base priority 209 */ 210 static int rtSchedDarwinGetBasePriority(void) 226 * @param pThread The thread to get it for. NULL for current. 227 */ 228 static int rtSchedDarwinGetBasePriority(PRTTHREADINT pThread) 211 229 { 212 230 /* the base_priority. */ 213 mach_msg_type_number_t Count= POLICY_TIMESHARE_INFO_COUNT;214 struct policy_timeshare_info 215 kern_return_t krc;216 krc = thread_info(mach_thread_self(),THREAD_SCHED_TIMESHARE_INFO, (thread_info_t)&TSInfo, &Count);231 mach_msg_type_number_t Count = POLICY_TIMESHARE_INFO_COUNT; 232 struct policy_timeshare_info TSInfo = {0,0,0,0,0}; 233 kern_return_t krc = thread_info(!pThread ? mach_thread_self() : pthread_mach_thread_np((pthread_t)pThread->Core.Key), 234 THREAD_SCHED_TIMESHARE_INFO, (thread_info_t)&TSInfo, &Count); 217 235 Assert(krc == KERN_SUCCESS); 218 236 … … 228 246 * Get the current priority. 229 247 */ 230 int iBasePriority = rtSchedDarwinGetBasePriority( );248 int iBasePriority = rtSchedDarwinGetBasePriority(NULL); 231 249 Assert(iBasePriority >= 0 && iBasePriority <= 63); 232 250 … … 277 295 DECLHIDDEN(int) rtThreadNativeSetPriority(PRTTHREADINT pThread, RTTHREADTYPE enmType) 278 296 { 279 Assert(pThread->Core.Key == pthread_self());280 297 Assert(enmType > RTTHREADTYPE_INVALID && enmType < RTTHREADTYPE_END); 281 298 AssertMsg(g_pProcessPriority && g_pProcessPriority->aTypes[enmType].enmType == enmType, … … 305 322 { 306 323 int i = 0; 307 int iBasePriority = rtSchedDarwinGetBasePriority(); 308 309 while (!err && iBasePriority < iDesiredBasePriority && i++ < 256) 324 int iBasePriority = rtSchedDarwinGetBasePriority(pThread); 325 326 while ( !err 327 && iBasePriority < iDesiredBasePriority 328 && i++ < 256) 310 329 { 311 330 SchedParam.sched_priority = ++iPriority; 312 331 err = pthread_setschedparam((pthread_t)pThread->Core.Key, iSchedPolicy, &SchedParam); 313 iBasePriority = rtSchedDarwinGetBasePriority( );332 iBasePriority = rtSchedDarwinGetBasePriority(pThread); 314 333 } 315 334 316 while (!err && iBasePriority > iDesiredBasePriority && i++ < 256) 335 while ( !err 336 && iPriority > 0 337 && iBasePriority > iDesiredBasePriority 338 && i++ < 256) 317 339 { 318 340 SchedParam.sched_priority = --iPriority; 319 341 err = pthread_setschedparam((pthread_t)pThread->Core.Key, iSchedPolicy, &SchedParam); 320 iBasePriority = rtSchedDarwinGetBasePriority( );342 iBasePriority = rtSchedDarwinGetBasePriority(pThread); 321 343 } 344 345 return VINF_SUCCESS; 322 346 } 323 347 }
Note:
See TracChangeset
for help on using the changeset viewer.