Setting budgets to zero
It's possible to set the budget of a partition to zero as long as the SCHED_APS_SEC_NONZERO_BUDGETS security flag isn't set—see the SCHED_APS_ADD_SECURITY command for SchedCtl().
Threads in a zero-budget partition run only in these cases:
- You're using the default scheduling policy (SCHED_APS_SCHEDPOL_DEFAULT), and the highest-priority thread in the system belongs to the zero-budget partition.
- You're using SCHED_APS_SCHEDPOL_FREETIME_BY_RATIO, and all other nonzero-budget partitions are idle.
- The zero-budget partition has a nonzero critical budget, in which case its critical threads run.
- A thread receives a message from a partition with a nonzero budget, in which case the receiving thread runs temporarily in the sender's partition.
When is it useful to set the budget of a partition to zero?
It useful to set the budget of a partition to zero when:
- A partition is permanently empty of running threads; you can set
its budget to zero to effectively turn it off.
When a zero-budget partition is idle, it isn't considered to produce free time (see
Summary of scheduling behavior
in the Using the Thread Scheduler chapter of this guide). A partition with a nonzero budget that never runs threads puts the thread scheduler permanently in free-time mode, which may not be the desired behavior. - You want noncritical code to run only when some other partition is idle.
- The partition is populated by resource managers, or other software, that runs only in response to receiving messages. Putting them in a zero-budget partition means you don't have to separately engineer a partition budget for them. (Those resource managers automatically bill their time to the partitions of their clients.)
For example, it's hazardous to set the System partition's budget to zero.
On a loaded machine with a System partition of zero, requests to
procnto to create processes and threads may hang, for example, when
MAP_LAZY is used.
In addition, if your system uses zero-budget partitions, you should carefully test it with
all other partitions fully loaded with while(1) loops.
