Skip to content

Instantly share code, notes, and snippets.

@shichao-an
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shichao-an/b2a5b77d5841433a66d3 to your computer and use it in GitHub Desktop.
Save shichao-an/b2a5b77d5841433a66d3 to your computer and use it in GitHub Desktop.
/* https://github.com/shichao-an/linux-2.6.34.7/blob/master/kernel/sched.c#L89
*/
/*
* Convert user-nice values [ -20 ... 0 ... 19 ]
* to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ],
* and back.
*/
#define NICE_TO_PRIO(nice) (MAX_RT_PRIO + (nice) + 20)
#define PRIO_TO_NICE(prio) ((prio) - MAX_RT_PRIO - 20)
#define TASK_NICE(p) PRIO_TO_NICE((p)->static_prio)
/*
* 'User priority' is the nice value converted to something we
* can work with better when scaling various scheduler parameters,
* it's a [ 0 ... 39 ] range.
*/
#define USER_PRIO(p) ((p)-MAX_RT_PRIO)
#define TASK_USER_PRIO(p) USER_PRIO((p)->static_prio)
#define MAX_USER_PRIO (USER_PRIO(MAX_PRIO))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment