Process Schudling
POSIX, processes run with a particular scheduling policy and
associated scheduling attributes. Both the policy and the attributes
can be changed independently. POSIX defines three policies:
1. SCHED_FIFO : Preemptive, priority-based scheduling.untill process not blocked.
2. SCHED_RR : Preemptive, priority-based scheduling with quanta.
3. SCHED_OTHER : An implementation-defined scheduler.
Header file
#include <sched.h>
macro should defined _POSIX_PRIORITY_SCHEDULING
Process scheduling APIs
sched_getscheduler—Retrieve scheduling algorithm for a particular purpose.
int sched_getscheduler(pid_t pid);
if pid=0 then return scheduler of calling process.
sched_setscheduler—Set scheduling algorithm/parameters for a process.
int sched_setscheduler(pid_t pid, int policy, const struct sched_param *p);
sched_get_priority_max—Get maximum priority value for a scheduler.
int sched_get_priority_max(int alg);
sched_get_priority_min — Get minimum priority value for a scheduler.
int sched_get_priority_min(int alg);
sched_getparam—Retrieve scheduling parameters for a particular process.
int sched_getparam(pid_t pid, struct sched_param *p);
sched_setparam — Set scheduling parameters for a process.
int sched_setparam(pid_t pid, const struct sched_param *p);
sched_yield — Yield the processor.sched_yield, when called, causes the calling process to give up its processor, and move to the back of the queue for
its priority.
int sched_yield();
sched_rr_get_interval—Get the SCHED_RR interval for the named process.
int sched_rr_get_interval(pid_t pid, struct timespec *t);
No comments:
Post a Comment
would you like it. :)