Thread clusters are identified by an integer id, not unlike threads or PIDs. Clusters rule over a group of threads, regardless of their process of origin, and allow specifiying an algorithm and a percentage over all the CPU time.
The algorithm of a cluster affects how threads inside the cluster are scheduled. The available algorithms are:
SCHED_RR
A prioritized round robin. One can specify a quantum to use when switching threads, while one can specify a priority using standard POSIX niceness. getprio/setprio.
Priorities affect inter-thread quantum following the formula:
timeout = quantum - ((quantum / 40) * niceness);
SCHED_COOP
Cooperative scheduling, the scheduler will not attempt to preempt unless explicitly requested by exiting or yielding.
Additionally, by using the SCHED_INTR
flag, a cluster can be configured
to be interruptible, which makes the kernel able to interrupt a thread and
queue another during long waits, in order to increase performance and
responsiveness. This does not affect cluster-wide scheduling guarantees.
At startup, Ironclad will have a single interruptible cluster assigned to 100%
of execution time, configured to use a flat RR with a reasonable quantum with
cluster number 1
. Software is free to modify it however it sees fit, it
is just provided in order to have some natural-ish behaviour for running
software blissfully unaware of the clusters beneath.
Syscalls used for modifying clusters and their settings are
manage_tcluster
and delete_tcluster
, create_tcluster
, and
switch_tcluster
.