编程接口指南

使用 lgrp_cpus()

lgrp_cpus(3LGRP) 函数使用表示 lgroup 分层结构快照的 cookie,并返回给定 lgroup 中的 CPU 数。

#include <sys/lgrp_user.h>

int lgrp_cpus(lgrp_cookie_t cookie, lgrp_id_t lgrp, processorid_t *cpuids,

              uint_t count, int content);

如果 cpuid[] 参数不为 NULL 并且 CPU 计数不为零,则 lgrp_cpus() 函数将使用 CPU ID 填充数组,直到填满数组或者所有 CPU ID 均在数组中为止。

content 参数可以具有以下两个值:

LGRP_CONTENT_ALL

lgrp_cpus() 函数返回此 lgroup 及其后代中的 CPU 的 ID。

LGRP_CONTENT_DIRECT

lgrp_cpus() 函数只返回此 lgroup 中的 CPU 的 ID。

如果 cookie、lgroup ID 或其中一个标志无效,则 lgrp_cpus() 函数将返回 EINVAL。如果未找到指定的 lgroup ID,则 lgrp_cpus() 函数将返回 ESRCH