---
name: "pmc_set"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/pmc_set"
---

# pmc\_set(3)

set the reload count of a sampling PMC

## NAME

**pmc\_set** – set the reload count of a sampling PMC

## LIBRARY

library “libpmc”

## SYNOPSIS

**#include \<pmc.h\>**

*int*\

**pmc\_set**(*pmc\_id\_t pmc*, *pmc\_value\_t value*);

## DESCRIPTION

Function **pmc\_set**() is used to set the reload value of sampling PMCs. Argument *pmc* specified the handle a previously allocate sampling mode PMC. Argument *value* specifies the reload count.

Sampling PMCs will interrupt the CPU after the number of hardware events specified by the reload count are seen. After the sampling interrupt is processed the underlying hardware will be reloaded with the specified count and the hardware automatically restarted by [hwpmc(4)](/hwpmc/4.md).

Function **pmc\_set**() should be called on PMC in a quiescent state.

## RETURN VALUES

The **pmc\_set()** function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error.

## ERRORS

A call to **pmc\_set**() may fail with the following errors:

- \[EINVAL\]

  The current process did not own a PMC with the specified handle.

- \[EBUSY\]

  The specified PMC was already running.

## SEE ALSO

[pmc(3)](/pmc/3.md), [hwpmc(4)](/hwpmc/4.md)
