## Obtain a list of process scheduling policy and priority

Normally, you can read the file `/proc/`

and get the related information. But since I am using a simplified one, the **[pid]**/sched**sched** file is not presented. And I need to figure out another way to get it. I finally found there is a **C library, <sched.h>**, to do that. You can find the following declarations in the library.

struct sched_param { int sched_priority; }; /* Set scheduling parameters for a process */ int sched_setparam(pid_t pid, const struct sched_param *param); /* Retrieve scheduling parameters for a particular process */ int sched_getparam(pid_t pid, struct sched_param *param); /* Set scheduling algorithm and/or parameters for a process */ int sched_setscheduler(pid_t pid, int policy, const struct sched_param *param); /* Retrieve scheduling algorithm for a particular purpose */ int sched_getscheduler(pid_t pid);

In this case, we only need sched_getparam() to obtain scheduling priority and sched_getscheduler() to obtain scheduling policy.

(more…)