> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/man/man9/bus_get_cpus.9.md).

# BUS\_GET\_CPUS.9

`BUS_GET_CPUS` — 请求一组设备特定的 CPU

## 名称

`BUS_GET_CPUS`, `bus_get_cpus`

## 概要

```c
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/cpuset.h>
```

```c
int
BUS_GET_CPUS(device_t dev, device_t child, enum cpu_sets op,
    size_t setsize, cpuset_t *cpuset)

int
bus_get_cpus(device_t dev, enum cpu_sets op, size_t setsize,
    cpuset_t *cpuset)
```

## 描述

`BUS_GET_CPUS` 方法向父总线设备查询一组设备特定的 CPU。`op` 参数指定要获取的 CPU 集合类型。如果成功，请求的 CPU 集合将通过 `cpuset` 返回。`setsize` 参数指定传入 `cpuset` 的集合大小（以字节为单位）。

`BUS_GET_CPUS` 通过 `op` 参数支持查询不同类型的 CPU 集合。并非所有设备都支持所有集合类型。如果某个集合类型不受支持，`BUS_GET_CPUS` 将以 `EINVAL` 失败。支持的集合类型如下：

**`LOCAL_CPUS`** 设备本地的 CPU 集合。如果设备在非一致性内存架构（NUMA）系统中更靠近某个特定内存域，则返回该内存域中的 CPU 集合。

**`INTR_CPUS`** 该设备用于设备中断的首选 CPU 集合。所有总线驱动程序都必须支持此集合类型。

`bus_get_cpus` 函数是 `BUS_GET_CPUS` 的简单封装。

## 返回值

成功时返回零，否则返回一个适当的错误。

## 参见

cpuset(2), [BUS\_BIND\_INTR(9)](/man/man9/bus_bind_intr.9.md), [device(9)](/man/man9/device.9.md)

## 历史

`BUS_GET_CPUS` 方法和 `bus_get_cpus` 函数首次出现于 FreeBSD 11.0。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/man/man9/bus_get_cpus.9.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
