The setrctl() and getrctl() functions provide interfaces for the modification and retrieval of resource control (rctl) values on active entities on the system, such as processes, tasks, or projects. All resource controls are unsigned 64-bit integers; however,
a collection of flags are defined that modify which rctl value is to be set or retrieved.
Resource controls are restricted to three levels: basic controls that can be modified by the owner of the calling process, privileged controls that can be modified only by privileged callers, and system controls that are fixed for the duration of the operating system instance. Setting or retrieving
each of these controls is performed by setting the privilege field of the resource control block to RCTL_BASIC, RCTL_PRIVILEGED, or RCTL_SYSTEM with rctlblk_set_privilege() (see rctlblk_set_value(3C)).
For limits on collective entities such as the task or project, the process ID of the calling process is associated with the resource control value. This ID is available by using rctlblk_get_recipient_pid() (see rctlblk_set_value(3C)). These values are visible only to that process and privileged processes within the collective.
The getrctl() function provides a mechanism for iterating through all of the established values on a resource control. The iteration is primed by calling getrctl() with old_blk set to NULL, a valid resource
control block pointer in new_blk, and specifying RCTL_FIRST in the flags argument. Once a resource control block has been obtained, repeated calls to getrctl() with RCTL_NEXT in the flags argument and the obtained control in the old_blk argument will return the next resource control block in the sequence. The iteration reports the end of the sequence by failing and setting errno to ENOENT.
The getrctl() function allows the calling process to get the current usage of a controlled resource using RCTL_USAGE as the flags value. The current value of the resource usage is placed in the value field of the resource control block
specified by new_blk. This value is obtained with rctlblk_set_value() (see rctlblk_set_value(3C)). All other
members of the returned block are undefined and might be invalid.
The setrctl() function allows the creation, modification, or deletion of action-value pairs on a given resource control. When passed RCTL_INSERT as the flag value, setrctl() expects new_blk to
contain a new action-value pair for insertion into the sequence. For RCTL_DELETE, the block indicated by new_blk is deleted from the sequence. For RCTL_REPLACE, the block matching old_blk is deleted and replaced by the
block indicated by new_blk.
The kernel maintains a history of which resource control values have triggered for a particular entity, retrievable from a resource control block with the rctlblk_get_firing_time() function (see rctlblk_set_value(3C)). The insertion or deletion of a resource control value at or below the currently enforced value might cause the currently enforced value to be reset. In the case of insertion, the newly inserted value becomes the actively
enforced value. All higher values that have previously triggered will have their firing times zeroed. In the case of deletion of the currently enforced value, the next higher value becomes the actively enforced value.
The various resource control block properties are described on the rctlblk_set_value(3C) manual page.
Resource controls are inherited from the predecessor process or task. One of the exec(2) functions can modify the resource controls of a process by resetting their histories, as noted
above for insertion or deletion operations.
|