---
name: "prng"
section: "9"
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/prng/9"
---

# prng(9)

Kernel pseudo-random number generators

## NAME

**prng** – Kernel pseudo-random number generators

## SYNOPSIS

**#include \<sys/prng.h\>**

*uint32\_t*\

**prng32**(*void*);

*uint32\_t*\

**prng32\_bounded**(*uint32\_t bound*);

*uint64\_t*\

**prng64**(*void*);

*uint64\_t*\

**prng64\_bounded**(*uint64\_t bound*);

## DESCRIPTION

### GENERIC PRNG ROUTINES

**prng** is a family of fast, *non-cryptographic* pseudo-random number generators. Unlike [random(9)](/random/9.md), **prng32**(), **prng32\_bounded**(), **prng64**(), and **prng64\_bounded**() avoid shared global state, removing unnecessary contention on SMP systems. The routines are not explicitly tied to any specific implementation, and may produce different specific sequences on different hosts, reboots, or versions of FreeBSD. Different CPUs in SMP systems are guaranteed to produce different sequences of integers.

For *cryptographically* *secure* random numbers generated by the [random(4)](/random/4.md) kernel cryptographically secure random number generator subsystem, see [arc4random(9)](/arc4random/9.md).

- **prng32**()

  Generate a 32-bit integer uniformly distributed in \[0, 2^32-1\].

- **prng32\_bounded**(*bound*)

  Generate an integer uniformly in the range \[0, bound-1\].

- **prng64**()

  Generate a 64-bit integer uniformly distributed in \[0, 2^64-1\].

- **prng64\_bounded**(*bound*)

  Generate an integer uniformly in the range \[0, bound-1\].

These routines are not reentrant; they are not safe to use in interrupt handlers ("interrupt filters" in [bus\_setup\_intr(9)](/bus_setup_intr/9.md) terminology). They are safe to use in all other kernel contexts, including interrupt threads ("ithreads").

### REPRODUCIBLE PRNG APIS

In addition to these per-CPU helpers, the ⟨sys/prng.h⟩ header also exposes the entire API of the PCG family of PRNGs as inline functions. The PCG-C API is described in full at **https://www.pcg-random.org/using-pcg-c.html**.

## HISTORY

**prng** was introduced in FreeBSD 13.
