Introduction
Linux 2.6.x is pre-emptive kernel. It has 100 level priorities: 0 to 99. 0 is the lowest priority and 99 is the highest.There're three scheduling policies:
- SCHED_OTHER
- SCHED_FIFO
- SCHED_RR
Linux pthread library bug
There's a bug in pthread library regarding setting the schedule policy and priority. See below picture. The right side is the correct one. The setting of the policy and priority MUST come after 'pthread_create()'.
Check the thread policy and priority
With 'chrt' command, the thread schedule policy and priority can be checked from command line.The threads' id of a process can be found with command: ls /proc/<process id>/task
The first thread in the list is the main thread.
To check a thread's policy and priority:
chrt -p <thread_id>