Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

A thread (or task) will loss dynamic priority by using a lot of cpu and gain priority by using less of CPU. How exactly are these priorities computed for n threads (using normal scheduling policy SCHED_OTHER )?

share|improve this question
4  
The Completely Fair Scheduler (CFS), a.k.a. SCHED_NORMAL or SCHED_OTHER, is documented here and implemented here. –  indiv Aug 30 '14 at 1:04

1 Answer 1

Quoting from this

The Linux 2.6.8.1 scheduler rewards I/O-bound tasks and punishes CPU-bound tasks by adding or subtracting from a task’s static priority. The adjusted priority is called a task’s dynamic priority, and is accessible via the task’s prio variable (e.g. p->prio where p is a task). If a task is interactive (the scheduler’s term for I/O bound), its priority is boosted. If it is a CPU hog, it will get a penalty. In the Linux 2.6.8.1 scheduler, the maximum priority bonus is 5 and the maximum priority penalty is 5. Since the scheduler uses bonuses and penalties, adjustments to a task’s static priority are respected. A mild CPU hog with a nice value of -2 might have a dynamic priority of 0, the same as a task that is neither a CPU nor an I/O hog.

I feel this is a fair explanation. The priority is computed based on whether it is a CPU bound thread or an I/O bound one. And regarding what you mentioned in the question, that gain priority by using less of CPU is rather gain priority by being interactive(I/O bound). I hope this excerpt answers your query...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.