Module posix.sched
Kernel Thread Scheduling Priority.
Where supported by the underlying system, functions to discover and
change the kernel thread scheduling priority. If the module loads
successfully, but there is no kernel support, then posix.sched.version
will be set, but the unsupported APIs will be nil
.
Functions
sched_getscheduler ([pid=0]) | get scheduling policy |
sched_setscheduler ([pid=0[, policy=`SCHED_OTHER`[, priority=0]]]) | set scheduling policy/priority |
Constants
posix.sched | Scheduler constants. |
Functions
- sched_getscheduler ([pid=0])
-
get scheduling policy
Parameters:
- pid
int
process to act on, or
0
for caller process (default 0)
Returns:
-
int
scheduling policy
SCHED_FIFO
,SCHED_RR
,SCHED_OTHER
, if successfulOr
- nil
- string error message
- int errnum
See also:
- pid
int
process to act on, or
- sched_setscheduler ([pid=0[, policy=`SCHED_OTHER`[, priority=0]]])
-
set scheduling policy/priority
Parameters:
- pid
int
process to act on, or
0
for caller process (default 0) - policy
int
one of
SCHED_FIFO
,SCHED_RR
orSCHED_OTHER
(default `SCHED_OTHER`) - priority
int
must be
0
forSCHED_OTHER
, or else a positive number below 100 for real-time policies (default 0)
Returns:
-
int
0
, if successfulOr
- nil
- string error message
- int errnum
See also:
- pid
int
process to act on, or
Constants
- posix.sched
-
Scheduler constants.
Any constants not available in the underlying system will be
nil
valued.Fields:
- SCHED_FIFO int first-in, first-out scheduling policy
- SCHED_RR int round-robin scheduling policy
- SCHED_OTHER int another scheduling policy
Usage:
-- Print scheduler constants supported on this host. for name, value in pairs (require "posix.sched") do if type (value) == "number" then print (name, value) end end