Creating scheduler partitions

On boot up, the system creates the initial partition, number 0, called System. The System partition initially has a budget of 100%. You can create partitions and set their budgets in your buildfile, with command-line utilities, or dynamically through the API defined in sys/sched_aps.h. When you create a partition, its budget is subtracted from its parent partition's budget.

To see which partitions you've created, use the aps show command. For more information about the aps utility, see aps.

Using a buildfile

To create a partition in your buildfile, add a line like this to the startup script:

sched_aps name budget

You can also use the aps in your startup script to set security options. For example, to create a partition called Drivers with a CPU budget of 20% and then use our recommended security option, add these lines to your buildfile's startup script:

sched_aps Drivers 20
aps modify -s recommended

Using the command line

To create a partition from the command line, use the aps utility's create option. For example:

aps create -b15 DebugReserve

creates a partition named DebugReserve with a budget of 15%.

Note: When you create a partition, its budget is taken from its parent partition's budget. The parent partition is usually the system partition.

Using a program

To create a partition from a program, use the SCHED_APS_CREATE_PARTITION command to SchedCtl(). For example:

sched_aps_create_parms creation_data;

memset(&creation_data, 0, sizeof(creation_data));
creation_data.budget_percent = 15;
creation_data.critical_budget_ms = 0;
creation_data.name = "DebugReserve";

ret = SchedCtl( SCHED_APS_CREATE_PARTITION, &creation_data,
                sizeof(creation_data));
if (ret != EOK) {
   printf("Couldn't create partition \"%s\": %s (%d).\n",
            creation_data.name, strerror(errno), errno);
} else {
   printf ("The new partition's ID is %d.\n", creation_data.id);
}

Note that SchedCtl() puts the partition's ID in the sched_aps_create_parms structure.