Free time

Free time occurs when one partition isn't running. The thread scheduler then gives that partition's time to other running partitions. If the other running partitions demand enough time, they're allowed to run over budget.

If a partition opportunistically goes over budget, it must pay back the borrowed time, but only as much as the scheduler remembers (i.e. only the borrowing that occurred in the last window).

For example, suppose we have these partitions:

Because the System partition demands no time, its budgeted time becomes free time. If you're using the default scheduling policy (SCHED_APS_SCHEDPOL_DEFAULT), the thread scheduler distributes the remaining time to the highest-priority thread in the system. In this case, that's the infinite-loop thread in partition Pb. So the output of the aps show command may be:

                    +-------- CPU Time -------+-- Critical Time --
Partition name   id | Budget |  Max |    Used | Budget |      Used
--------------------+-------------------------+-------------------
System            0 |    70% | 100% |   0.11% |  200ms |   0.000ms
Pa                1 |    20% | 100% |  20.02% |    0ms |   0.000ms
Pb                2 |    10% | 100% |  79.83% |    0ms |   0.000ms
--------------------+-------------------------+-------------------
Total               |   100% |      |  99.95% |

In this example, partition Pa receives its guaranteed minimum of 20%, but all of the free time is given to partition Pb.

This is a consequence of the principle that the thread scheduler chooses between partitions strictly by priority, as long as no partition is being limited to its budget. This strategy ensures the most real time behavior.

But, there may be circumstances when you don't want partition Pb to receive all of the free time just because it has the highest-priority thread. That may occur when, say, when you choose to use Pb to encapsulate an untrusted or third-party application, particularly when you are unable control its code.

In that case, you may want to configure the thread scheduler to run a more restrictive algorithm that divides free time by the budgets of the busy partitions (rather than assigning all of it to the highest-priority thread). To do so, set the SCHED_APS_SCHEDPOL_FREETIME_BY_RATIO flag (see "Scheduling policies" in the entry for SchedCtl() in the QNX Neutrino C Library Reference), or use the aps modify -S freetime_by_ratio command (see the Utilities Reference).

In our example, freetime-by-ratio mode might cause the aps show command to display:

                    +-------- CPU Time -------+-- Critical Time --
Partition name   id | Budget |  Max |    Used | Budget |      Used
--------------------+-------------------------+-------------------
System            0 |    70% | 100% |   0.04% |  200ms |   0.000ms
Pa                1 |    20% | 100% |  65.96% |    0ms |   0.000ms
Pb                2 |    10% | 100% |  33.96% |    0ms |   0.000ms
--------------------+-------------------------+-------------------
Total               |   100% |      |  99.96% |

which indicates that in freetime-by-ratio mode, the thread scheduler divides free time between partitions Pa and Pb in roughly a 2:1 ratio, which is the ratio of their budgets.