> 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/get_cyclecount.9.md).

# get\_cyclecount.9

`get_cyclecount` — 获取 CPU 的快速计数器寄存器内容

## 名称

`get_cyclecount`

## 概要

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

```c
#include <sys/systm.h>
```

```c
#include <machine/cpu.h>
```

```c
uint64_t
get_cyclecount(void)
```

## 描述

`get_cyclecount` 函数使用大多数现代 CPU 中可用的寄存器返回一个在每个 CPU 内单调递增的值。

在 SMP 系统上，会有若干独立的单调序列，每个运行的 CPU 一个。SMP 情况下的值从这些序列之一中选择，取决于哪个 CPU 被调度来服务请求。

每个计数器的速度和最大值取决于 CPU。某些 CPU（如 Intel 80486）没有这样的寄存器，因此在这些平台上 `get_cyclecount` 返回由 `binuptime(9)` 返回的结构所表示的数字的（单调）组合。

AMD64 和 Intel 64 处理器使用 `TSC` 寄存器。

## 参见

`binuptime(9)`

## 历史

`get_cyclecount` 函数首次出现于 FreeBSD 5.0。

## 作者

本手册页由 Mark Murray <markm@FreeBSD.org> 编写。


---

# 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/get_cyclecount.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.
