Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check the process scheduling policy other than `ps` output

I am using an busybox version of linux and want to check the process scheduling policy. The PS output only displays PID USER VSZ STAT COMMAND irrespective of any option given with PS command. Is there any other way to check the process scheduling policy?

Thanks in advance!!

like image 911
neo Avatar asked Oct 20 '22 09:10

neo


1 Answers

You can find schedule information of a process by looking at /proc/pocess_id/sched.

For example:

awk '/policy/ {print $NF}' /proc/25/sched

would give you the policy number of process 25.

For more information on policy numbers, you can look at man sched_setscheduler:

Scheduling Policies:
    ...
   For  threads scheduled under one of the normal scheduling policies
   (SCHED_OTHER, SCHED_IDLE, SCHED_BATCH), sched_priority is not used
   in scheduling decisions (it must be specified as 0).

   Processes scheduled under one of the real-time policies
   (SCHED_FIFO, SCHED_RR) have a sched_priority value in the range 1
   (low)  to  99  (high).  (As the numbers imply, real-time threads
   always have higher priority than normal threads.)  Note well:
   POSIX.1-2001 requires an implementation to support only a minimum
   32 distinct priority levels for the real-time policies, and some
   systems supply  just  this  minimum.   Portable  programs should
   use sched_get_priority_min(2) and sched_get_priority_max(2) to
   find the range of priorities supported for a particular policy.
like image 68
John B Avatar answered Nov 01 '22 08:11

John B