Контроль планировщика адаптивного квотирования ресурсов
#include <sys/sched_aps.h>#include <sys/neutrino.h>int SchedCtl( int cmd,void *data,int length );int SchedCtl_r( int cmd,void *data,int length );
libc
The SchedCtl() and SchedCtl_r() kernel calls control the adaptive partitioning scheduler.
This scheduler is optional and is present only if you add [module=aps]
to your OS image's buildfile.
Данные функции идентичны за исключением способа возврата ошибок.
![]() | You must initialize all of the fields—including reserved ones—in the structures you pass as the data argument, by calling (for example) memset(). You can also use the APS_INIT_DATA() macro:
|
This command fills in a sched_aps_info structure that describes the overall parameters of the adaptive partitioning scheduler.
Errors:
SchedCtl() and SchedCtl_r() indicate the following errors for the SCHED_APS_QUERY_PARMS
command:
The command sets the parameters for the overall behavior of the adaptive partitioning scheduler. The data argument must be a pointer to a sched_aps_parms structure.
Errors:
SchedCtl() and SchedCtl_r() indicate the following errors for the SCHED_APS_SET_PARMS
command:
SCHED_APS_SEC_PARTITIONS_LOCKED
is set, or SCHED_APS_SEC_ROOT0_OVERALL
is set and you aren't running as root in the System partition. For more information, see SCHED_APS_SEC_*.
This command creates a new partition which is considered to be a child of the partition that's calling SchedCtl(). The system automatically creates a partition called System (the value of APS_SYSTEM_PARTITION_NAME
) with an ID of 0
.
The data argument for this command must be a pointer to a sched_aps_create_parms structure.
Errors:
SchedCtl() and SchedCtl_r() indicate the following errors for the SCHED_APS_CREATE_PARTITION
command:
SCHED_APS_SEC_PARTITIONS_LOCKED
is set, or any of these security conditions are set and not satisfied: SCHED_APS_SEC_ROOT_MAKES_PARTITIONS
SCHED_APS_SEC_SYS_MAKES_PARTITIONS
SCHED_APS_SEC_NONZERO_BUDGETS
SCHED_APS_SEC_ROOT_MAKES_CRITICAL
SCHED_APS_SEC_SYS_MAKES_CRITICAL
APS_PARTITION_NAME_LENGTH
characters.
This command gets information about a given partition. The data argument for this command must be a pointer to a sched_aps_partition_info structure.
Errors:
SchedCtl() and SchedCtl_r() indicate the following errors for the SCHED_APS_QUERY_PARTITION
command:
This command finds the partition ID for a given partition name. The data argument for this command must be a sched_aps_lookup_parms structure.
Errors:
SchedCtl() and SchedCtl_r() indicate the following errors for the SCHED_APS_LOOKUP
command:
This command makes the thread specified by the given process and thread IDs becomes a member of the specified partition. This partition also becomes the thread's new home partition, i.e. where it returns after partition inheritance. The data argument for this command must be a pointer to a sched_aps_join_parms.
Errors:
SchedCtl() and SchedCtl_r() indicate the following errors for the SCHED_APS_JOIN_PARTITION
command:
SCHED_APS_SEC_ROOT_JOINS
SCHED_APS_SEC_SYS_JOINS
SCHED_APS_SEC_PARENT_JOINS
SCHED_APS_SEC_JOIN_SELF_ONLY
This command changes the parameters of an existing partition. If the new budget's percent value is different from the current, the difference is either taken from, or returned to, the parent partition's budget. The critical time parameter affects only the chosen partition, not its parent. To change just one of new budget or new critical time, set the other to -1
.
![]() |
|
The data argument for this command must be a pointer to a sched_aps_modify_parms structure.
Errors:
SchedCtl() and SchedCtl_r() indicate the following errors for the SCHED_APS_MODIFY_PARTITION
command:
SCHED_APS_SEC_PARENT_MODIFIES
SCHED_APS_SEC_ROOT_MAKES_PARTITIONS
SCHED_APS_SEC_SYS_MAKES_PARTITIONS
SCHED_APS_SEC_NONZERO_BUDGETS
SCHED_APS_SEC_ROOT_MAKES_CRITICAL
SCHED_APS_SEC_SYS_MAKES_CRITICAL
This command returns instantaneous values of the CPU time-accounting variables for a set of partitions. It can fill in data for more than one partition. If the length argument to SchedCtl() indicates that you've passed the function an array of sched_aps_partition_stats structures, SchedCtl() fills each element with statistics for a different partition, starting with the partition specified by the id field.
![]() | To get an accurate picture for the the whole machine it's important to read data for all partitions in one call, since sequential calls to SCHED_APS_PARTITION_STATS may come from separate averaging windows.
To determine the number of partitions, use the SCHED_APS_OVERALL_STATS command. |
The command overwrites the id field with the partition number for which data is being returned. It stores -1
into the id field of unused elements. To convert times in cycles into milliseconds, divide them by the cycles_per_ms obtained with an SCHED_APS_QUERY_PARMS command.
The data argument for this command must be a pointer to a sched_aps_partition_stats structure, or an array of these structures.
Errors:
SchedCtl() and SchedCtl_r() indicate the following errors for the SCHED_APS_PARTITION_STATS
command:
This command returns instantaneous values of overall CPU-usage variables and other dynamic scheduler states. The data argument for this command must be a pointer to a sched_aps_overall_stats structure.
Errors:
SchedCtl() and SchedCtl_r() indicate the following errors for the SCHED_APS_OVERALL_STATS
command:
This command sets one thread in your process to run as a critical thread whenever it runs. Use a thread ID of zero to set the calling thread to be critical. The data argument for this command must be a pointer to a sched_aps_mark_crit_parms structure.
![]() | In general, it's more useful to send a critical struct sigevent to a thread to make it run as a critical thread. |
Errors:
SchedCtl() and SchedCtl_r() indicate the following errors for the SCHED_APS_MARK_CRITICAL
command:
This command clears the “always run as critical” state set by the SCHED_APS_CLEAR_CRITICAL command. Then the thread will run as critical only when it inherits that state from another thread (on receipt of a message). The data argument for this command must be a pointer to a sched_aps_clear_crit_parms structure.
Errors:
SchedCtl() and SchedCtl_r() indicate the following errors for the SCHED_APS_CLEAR_CRITICAL
command:
This command determines the partition for the given thread and indicates whether or not the thread in your process is marked to run as critical. Use a thread ID of zero to indicate the calling thread. The data argument for this command must be a pointer to a sched_aps_query_thread_parms structure.
Errors:
SchedCtl() and SchedCtl_r() indicate the following errors for the SCHED_APS_QUERY_THREAD
command:
This command defines struct sigevent that the scheduler will return to the calling thread when the scheduler detects that a given partition has become bankrupt, or the whole system has become overloaded.
![]() | Overload notification isn't implemented in this release. |
Calling SCHED_APS_ATTACH_EVENTS
arms the notification once. After you receive the notification, you must call SCHED_APS_ATTACH_EVENTS
again to receive a subsequent notification. This is to ensure that the system doesn't send you notifications faster than you can handle them. The pinfo_flags field of the sched_aps_partition_stats structure structure (see the SCHED_APS_PARTITION_STATS command) indicates if these events are armed.
![]() | You can register only one pair of struct sigevent (bankruptcy and overload) per partition, and the notifications must go to the same thread. The thread notified is the calling thread. Attaching events a second time overwrites the first. Passing NULL pointers means “no changes in notification.” To turn off notification, use SIGEV_NONE_INIT() to set the appropriate struct sigevent to SIGEV_NONE . |
If you want to configure additional actions for the system to perform on bankruptcy, see SCHED_APS_BNKR_*. The data argument for this command must be a pointer to a sched_aps_events_parm structure.
Errors:
SchedCtl() and SchedCtl_r() indicate the following errors for the SCHED_APS_ATTACH_EVENTS
command:
SCHED_APS_SEC_PARENT_MODIFIES
SCHED_APS_SEC_ROOT_MAKES_PARTITIONS
SCHED_APS_SEC_SYS_MAKES_PARTITIONS
This command sets security options. A bit that's set turns the corresponding security option on. Successive calls add to the existing set of security options. Security options can only be cleared by a restart.
![]() | You must be root running in the System partition to use this command, even if all security options are off. |
The data argument for this command must be a pointer to a sched_aps_security_parms structure.
Errors:
SchedCtl() and SchedCtl_r() indicate the following errors for the SCHED_APS_ADD_SECURITY
command:
This command returns the partition of the given process. The partition of a process is billed while one of the process's threads handles a pulse. The individual threads in a process may all be in different partitions from the process. The data argument for this command must be a pointer to a sched_aps_query_process_parms structure.
Errors:
SchedCtl() and SchedCtl_r() indicate the following errors for the SCHED_APS_QUERY_PROCESS
command:
This call doesn't block.
EOK
if the call succeeds. If an error occurs, SchedCtl() returns -1
and sets errno.EOK
if the call succeeds. This function doesn't set errno. If an error occurs, SchedCtl_r() returns the negative of an error value.For a list of error codes, see the description of each command.
sched_aps_partition_info part_info;/* You need to initialize the parameter block. */APS_INIT_DATA( &part_info );/* Set the input members of the parameter block. */part_info.id = 2;/* Invoke SchedCtl to query the partition. */ret = SchedCtl( SCHED_APS_QUERY_PARTITION, &part_info, sizeof( part_info ) );if ( EOK != ret )some_kind_of_error_handler();/* Use output field */printf( "The budget is %d per cent.\n", part_info.budget_percent );
ЗОСРВ «Нейтрино»
sched_aps_info structure, sched_aps_parms structure, sched_aps_create_parms structure, sched_aps_partition_info structure, sched_aps_lookup_parms structure, sched_aps_join_parms structure, sched_aps_modify_parms structure, sched_aps_partition_stats structure, sched_aps_overall_stats structure, sched_aps_mark_crit_parms structure, sched_aps_clear_crit_parms structure, sched_aps_query_thread_parms structure, sched_aps_events_parm structure, sched_aps_security_parms structure, sched_aps_query_process_parms structure, SchedGet(), SchedInfo(), SchedSet(), SchedYield(), struct sigevent
aps в Справочнике по Утилитам
Предыдущий раздел: Описание API системной библиотеки