These shortcomings began to significantly affect
the operation of the system
when it was operating under load conditions. Under normal circumstances,
traditional Linux scheduling worked quite effectively. Work on fixing the
shortcomings has continued. As a result,
a new implementation of the
scheduling algorithm has been integrated into the kernel of version
2.6. Consider briefly how it helps the solution ' bind previously mentioned
problems.
First of all, this algorithm supports separate queues of finishing processes
for each processor, ensuring efficient operation
under conditions of
multiprocessing. Another problem that has solutions connected with the
need to rely on the old algorithm for the dynamic priority of all ready
processes during each procedure call planning.
The decisions are as
follows: each queue of the digestion processes is an array of ready-made
process queues, where the elements are sorted by dynamic priority. As a
result, when choosing a process to execute, it is enough to look at the
highest priority queue for the first process that can be started. This
procedure does not depend on the number of ready processes with a STEM.
There are two arrays of queues of ready processes - an array of queues of
active processes and an array of queues of
processes with an exhausted
quantum. After the process has exhausted its quantum, it is transferred from
the first array to a long one. When there is no process in the active queue,
both arrays are replaced by missions, and the sequence of steps is repeated
from the beginning. As a result, the depletion of quanta processes increases
the likelihood of running those processes that have not yet been managed.
The Programming Interface Of Planning
Let's take a look at the Linux system calls that can handle the underlying
process priority (the value nice ) and thus influence their scheduling.
To change the base priority of the process, use the call set priority ():
#include
int setpriority (int which, int who, int priority);
In particular, the parameter which can be set to PRIO_PROCESS or
PRIO_USER, respectively, indicating that the parameter will be interpreted
as a process identifier or user ID. In the first case, they set a priority for a
specific process (or
for the current process, if who equals zero), in the
second - for all processes of that user.
The priority parameter sets a new priority. Priority may vary from –20 to
20, smaller values indicate higher priority. The default value is 0.
Negative priority values can only be set by users with admin privileges.
Use the getpriority () call to get information about the current base priority :
Int getpriority (int which, int who);
This call returns the priority value, the which
and who parameters for it
have the same meaning as for the setpriority () function.
Here's an example of how to use these calls:
// set a priority for the current process
setpriority ( PRIO _ PROCESS , 0.10);
// find out about
the current priority value
printf (" current priority: % d \ n ", getpriority ( PRIO _ PROCESS , 0));
You can also use the nice () system call to change the underlying priority of
the current process relatively :
# Include < unistd . h >
int nice ( int inc ); // changes the priorities of the current process to inc .