Hi Charles, On 08.09.2010 13:45, Charles Clerdan wrote: > Hi, > > > I have a technical question about priorities under Xenomai. > > According to my research, Xenomai use priority levels from 0 to 99. 99 > is the highest effective priority and 0 the lowest. > But Linux uses levels from 0 to 139. For current task it uses levels > 100 to 139 where 100 is highest priority than 139, and for "real time" > threads 0 to 99 where 0 is highest than 99.s > So when a task jumps in secondary modes is there a conversion of its > own priority (100 - primary_mode_priority) or does she keep the same > number. > When two tasks with two different priorities are in secondary modes, > is there a priority inversion between them or a crossed convertion of > the priorities? caution: I may be wrong, corrections welcome. If you use the command 'ps -Ac' it will show you priorities from 0-139. 139 is best. The low prio range 0-39 is for tasks scheduled with the default SCHED_OTHER scheduling policy. Linux uses CFS (completely fair scheduler) today for SCHED_OTHER. The priority of these task can be changed using the command 'renice'. 'renice 19 ' sets the priority to 0. 'renice -20 ' sets it to 39. 'renice 0 ' to 19 (default). The priority range displayed as 40-139 is for linux "real-time" taks. These are tasks handled with the SCHED_FIFO or SCHED_RR policy. To change the scheduling policy of a process, you can use the 'chrt' command. The real priority range of SCHED_FIFO or SCHED_RR is 0-99 (99 is best), but if you want to take the scheduling policy into account like 'ps -Ac' does, a offset of 40 is added for these tasks, so 40-139 is displayed. If you have a SCHED_FIFO task with the lowest prio 0 and you do a hard loop (bad idea) the SCHED_OTHER tasks don't get cputime anymore. Xenomai realtime tasks are SCHED_FIFO or SCHED_RR and have the same priority range (0-99) as the linux "real-time" tasks. A xenomai SCHED_FIFO task with prio 99 in secondary mode is handled equally as a normal linux task with SCHED_FIFO and prio 99 by the linux kernel (prio displayed as 139 with 'ps -Ac'). But a xenomai task with the lowest priority 0 in secondary mode has still better prio than all the SCHED_OTHER linux tasks. Xenomai tasks keep/have the same priority under the realtime and the linux scheduler. So the task scheduling priority is something like: 1. xenomai task in primary mode handled by the realtime scheduler 2. xenomai task in secondary mode or linux "real-time" task, both handled by the linux scheduler, they compete 3. linux SCHED_OTHER tasks handled by the linux scheduler Regards Stefan