schedctl(2) schedctl(2)
schedctl - scheduler control call
#include <limits.h>
#include <sys/types.h>
#include <sys/prctl.h>
#include <sys/schedctl.h>
int schedctl (int cmd, [ int arg1 [ , int arg2 ] ]);
This system call is used to alter scheduling parameters of either
individual processes or of the system as a whole. The following commands
are supported:
AFFINITY_ON [Toc] [Back]
This command enables cache affinity for the calling or another
process. arg1 is the process ID of the process to be modified;
if zero, it indicates the current process. The affinity status
is inherited by the process's children after a fork. By default,
affinity is on.
AFFINITY_OFF [Toc] [Back]
This command disables cache affinity for the calling or another
process. arg1 is the process ID of the process to be modified;
if zero, it indicates the current process. The affinity status
is inherited by the process's children after a fork.
AFFINITY_STATUS [Toc] [Back]
This command returns the current cache affinity status for the
calling or another process. arg1 is the process ID of the
process to be modified; if zero, it indicates the current
process. If affinity is on, it returns 0, otherwise 1.
RENICE This command allows a process to change its own or another
process's nice value. arg1 is the process ID of the process to
be modified; if zero, it indicates the current process. arg2 is
the new process nice value to use. This is different than the
value given to the nice(2) system call. nice takes a relative
value, while this command changes the absolute nice value of the
process which ranges from 0 to 39. The default absolute nice
value for a process is 20.
The process must have superuser permissions to use this command.
The previous (absolute) nice value is returned.
SLICE This command allows a process to change its own or another
process's time slice. A time slice is the period of time that a
process is allowed to run before being eligible for preemption by
another process. arg1 is the process ID of the process to be
altered; if zero, it indicates the current process. arg2 is the
new time slice value to use, expressed in terms of clock ticks.
Page 1
schedctl(2) schedctl(2)
The system software clock fires CLK_TCK times per second; hence
the duration of a clock tick in milliseconds is equal to
1000/CLK_TCK (see <limits.h>). arg2 is constrained to be greater
than 0, and less than 10 seconds.
The process must have superuser permissions to use this command.
The previous time slice value is returned.
SETHINTS [Toc] [Back]
This command sets up a communication path between the process and
the kernel, which allows the process to communicate scheduling
modes to the kernel without the overhead of a system call. The
return value is a pointer to a prda_sys structure, defined in
<sys/prctl.h>. Since the return value for schedctl is defined as
an integer, it is necessary to cast this value to a struct
prda_sys * before using it. Also, since the optimizer can remove
references to variables which have no apparent uses, it is best
to declare the variable with the volatile attribute:
volatile struct prda_sys *prda_sys;
After a SETHINTS command, the process may write scheduling modes
to the t_hint field of the prda_sys structure. These scheduling
modes will be observed by the kernel at process dispatch time.
The scheduling modes are the same as those defined for the
SCHEDMODE command.
Also, the t_cpu field may be read by user code to obtain the
identifier of the cpu where the process was recently scheduled.
The next two commands provide control over the scheduling of groups of
parallel processes on multi-cpu systems. The processes must be members
of the same sharegroup (see sproc(2) for more information about share
groups). Note that the SCHEDMODE and SETMASTER commands can only be used
after a share group has been created.
SCHEDMODE [Toc] [Back]
This command allows a member of a share group to set a scheduling
mode for the entire share group. arg1 specifies the scheduling
mode. These are SGS_FREE, which specifies that each member of
the share group is to be scheduled independently, SGS_SINGLE,
which specifies that only the master is to run (see SETMASTER for
setting the master thread), and SGS_GANG, which specifies that
all members of the share group are to be scheduled as a unit, if
possible. The default scheduling mode when a share group is
created is SGS_FREE.
The previous scheduling mode is returned.
SETMASTER [Toc] [Back]
This command sets the master process of the share group. arg1
specifies the pid of the new master process.
Page 2
schedctl(2) schedctl(2)
By default, the creator of the share group is the master process.
The master process differs from other members of the share group
only in the case of the SGS_SINGLE scheduling mode. In that
case, only the master process will run. This operation can only
be performed by the master of the share group. On success, 0 is
returned.
MPTS_FRS_CREATE [Toc] [Back]
MPTS_FRS_DEQUEUE
MPTS_FRS_DESTROY
MPTS_FRS_ENQUEUE
MPTS_FRS_GETATTR
MPTS_FRS_GETQUEUELEN
MPTS_FRS_INTR
MPTS_FRS_JOIN
MPTS_FRS_PINSERT
MPTS_FRS_PREMOVE
MPTS_FRS_READQUEUE
MPTS_FRS_RESUME
MPTS_FRS_SETATTR
MPTS_FRS_START
MPTS_FRS_STOP
MPTS_FRS_YIELD
These are all interfaces that are used to implement various
frs functions. These are all subject to change and should
not be called directly by applications.
<sys/schedctl.h>.
schedctl will fail if any of the following are true:
[EINVAL] An invalid command or new value was passed to the system.
[EINVAL] The command was SCHEDMODE, and either the process was not a
member of a share group, or arg1 did not specify a valid
scheduling mode.
[EINVAL] The command was SETMASTER, and either the process was not a
member of a share group, the process was not the current
master of the share group, or arg1 specified a process that
was not a member of the share group.
[EPERM] An attempt was made to perform privileged operations without
appropriate permissions.
[ESRCH] The named process was not found.
npri(1), nice(2), prctl(2), sched_getparam(2), sched_setparam(2),
sched_getscheduler(2), sched_yield(2), sched_get_priority_max(2),
sched_get_priority_min(2), sched_rr_get_interval(2), sproc(2), sysmp(2)
Page 3
schedctl(2) schedctl(2)
schedctl returns -1 if an error occurred. Otherwise, the return is
dependent on cmd.
PPPPaaaaggggeeee 4444 [ Back ]
|