GET_CYCLECOUNT(9)
π GET_CYCLECOUNT π
okay bestie, welcome to section 9 of the Kernel Developer's Manual β that's the <rainbow>kernel dev</rainbow> zone, no userspace nonsense allowed β¨. This little page is all about get_cyclecount, and honestly? She's giving "tiny function, huge personality". Let's get into it π«Ά
β¨ NAME β¨
get_cyclecount β grab the CPU's fast counter register contents, like, right now π
π SYNOPSIS π
#include <sys/param.h>
#include <sys/systm.h>
#include <machine/cpu.h>
uint64_t
get_cyclecount(void);
three includes, one function, zero arguments. she's low maintenance, she's iconic πΈ
π¦ DESCRIPTION π¦
so. get_cyclecount() uses a register that most modern CPUs justβ¦ have πββοΈ and it returns a value that's monotonically increasing inside each CPU. meaning: on any given CPU, that number only ever goes up. never down. she does not do backtracking, periodt β
on SMP systems β that's symmetric multiprocessing, multiple CPUs doing their thing β there are going to be a whole bunch of separate monotonic sequences, one for each CPU that's running π. so when you call it, the value you get is selected from one of those sequences, depending on which CPU got scheduled to service your request. so it's like, whichever CPU picked up the phone π
the speed and the maximum value of each counter is CPU-dependent β no universal vibes here, every chip does its own thing π
and now the sad part π: some CPUs (looking at you, Intel 80486) simply do not have such a register. rude. so on those platforms, get_cyclecount() returns a monotonic combination of numbers represented by the structure returned by binuptime(9) instead. it's not the same register magic, but it's still monotonic, so the vibe holds π§
and for the cool kids: AMD64 and Intel 64 processors use the TSC register π₯ (TSC = timestamp counter, iykyk)
π SEE ALSO π
binuptime(9)β go read her next, she's the fallback bestie π
β HISTORY β
get_cyclecount() first appeared in FreeBSD 5.0. she's been around, she's got lore π
π AUTHORS π
This manual page was written by Mark Murray <markm@FreeBSD.org>. thank you for your service, king π«‘π
ok that's the whole page, nothing skipped, nothing summarised β every flagless, argument-less, uint64_t-returning detail is right here π
and that's a wrap on this one, bestie!! this page ships with the Debian manual set, dated March 15, 2011 β yeah she's a little vintage, but vintage is a lifestyle π β¨ bye babes!! πΈπ¦π
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2000 Mark R V Murray
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms