编程接口指南

使用 lgrp_resources()

lgrp_resources() 函数返回指定 lgroup 中包含的资源数。

#include <sys/lgrp_user.h>

int lgrp_resources(lgrp_cookie_t cookie, lgrp_id_t lgrp, lgrp_id_t *lgrpids,

                   uint_t count, lgrp_rsrc_t type);

lgrp_resources() 函数使用表示 lgroup 分层结构快照的 cookie。此 cookie 是从 lgrp_init() 函数中获取的。lgrp_resources() 函数返回 ID 由 lgrp 参数值指定的 lgroup 中的资源数。lgrp_resources() 函数表示直接包含 CPU 或内存资源的 lgroup 集合中的资源。lgrp_rsrc_t 参数可以具有以下两个值:

LGRP_RSRC_CPU

lgrp_resources() 函数返回 CPU 资源数。

LGRP_RSRC_MEM

lgrp_resources() 函数返回内存资源数。

如果 lgrpids[] 参数中传递的值不为空并且 count 参数不为零,则 lgrp_resources() 函数将在 lgrpids[] 数组中存储 lgroup ID。此数组中存储的 lgroup ID 数最多不能超过 count 参数的值。

如果指定的 cookie、lgroup ID 或类型无效,则 lgrp_resources() 函数将返回 EINVAL。如果 lgrp_resources() 函数未找到指定的 lgroup ID,则它将返回 ESRCH