Changeset 36378 in vbox for trunk/src/VBox/Runtime/r0drv/linux/thread2-r0drv-linux.c
- Timestamp:
- Mar 23, 2011 5:48:42 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/linux/thread2-r0drv-linux.c
r36244 r36378 5 5 6 6 /* 7 * Copyright (C) 2006-20 07Oracle Corporation7 * Copyright (C) 2006-2011 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 43 43 } 44 44 45 45 46 int rtThreadNativeInit(void) 46 47 { … … 48 49 } 49 50 50 /*51 * Following is verbatim comment from Linux's sched.h.52 *53 * Priority of a process goes from 0..MAX_PRIO-1, valid RT54 * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH55 * tasks are in the range MAX_RT_PRIO..MAX_PRIO-1. Priority56 * values are inverted: lower p->prio value means higher priority.57 *58 * The MAX_USER_RT_PRIO value allows the actual maximum59 * RT priority to be separate from the value exported to60 * user-space. This allows kernel threads to set their61 * priority to a value higher than any user task. Note:62 * MAX_RT_PRIO must not be smaller than MAX_USER_RT_PRIO.63 */64 51 65 52 int rtThreadNativeSetPriority(PRTTHREADINT pThread, RTTHREADTYPE enmType) 66 53 { 67 int sched_class = SCHED_NORMAL; 68 struct sched_param param = { .sched_priority = MAX_PRIO-1 }; 54 /* See comment near MAX_RT_PRIO in linux/sched.h for details on 55 sched_priority. */ 56 int iSchedClass = SCHED_NORMAL; 57 struct sched_param Param = { .sched_priority = MAX_PRIO - 1 }; 69 58 switch (enmType) 70 59 { 71 60 case RTTHREADTYPE_INFREQUENT_POLLER: 72 { 73 param.sched_priority = MAX_RT_PRIO + 5; 61 Param.sched_priority = MAX_RT_PRIO + 5; 74 62 break; 75 } 63 76 64 case RTTHREADTYPE_EMULATION: 77 { 78 param.sched_priority = MAX_RT_PRIO + 4; 65 Param.sched_priority = MAX_RT_PRIO + 4; 79 66 break; 80 } 67 81 68 case RTTHREADTYPE_DEFAULT: 82 { 83 param.sched_priority = MAX_RT_PRIO + 3; 69 Param.sched_priority = MAX_RT_PRIO + 3; 84 70 break; 85 } 71 86 72 case RTTHREADTYPE_MSG_PUMP: 87 { 88 param.sched_priority = MAX_RT_PRIO + 2; 73 Param.sched_priority = MAX_RT_PRIO + 2; 89 74 break; 90 } 75 91 76 case RTTHREADTYPE_IO: 92 { 93 sched_class = SCHED_FIFO; 94 param.sched_priority = MAX_RT_PRIO - 1; 77 iSchedClass = SCHED_FIFO; 78 Param.sched_priority = MAX_RT_PRIO - 1; 95 79 break; 96 } 80 97 81 case RTTHREADTYPE_TIMER: 98 {99 sched_class = SCHED_FIFO;100 param.sched_priority = 1; /* not 0 just in case */101 } 82 iSchedClass = SCHED_FIFO; 83 Param.sched_priority = 1; /* not 0 just in case */ 84 break; 85 102 86 default: 103 87 AssertMsgFailed(("enmType=%d\n", enmType)); … … 106 90 107 91 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,11) 108 sched_setscheduler(current, sched_class, ¶m);92 sched_setscheduler(current, iSchedClass, &Param); 109 93 #endif 110 94 111 95 return VINF_SUCCESS; 112 96 } 97 113 98 114 99 int rtThreadNativeAdopt(PRTTHREADINT pThread) … … 123 108 } 124 109 110 111 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 4) 125 112 /** 126 113 * Native kernel thread wrapper function. … … 137 124 return 0; 138 125 } 126 #endif 139 127 140 128 … … 157 145 #endif 158 146 } 147
Note:
See TracChangeset
for help on using the changeset viewer.