KPAUSE(9)
π€ KPAUSE(9) β the kernel dev manual, bestie edition π€
okay so real talk: this is a page from the Kernel Developer's Manual (KPAUSE(9), section 9, kernel-land only, no userland girlies allowed) and it's literally just about making the calling LWP take a lil nap π΄β¨
β¨ NAME β¨
kpause β make the calling LWP sleep ππ€
πΈ SYNOPSIS πΈ
#include <sys/proc.h>
int
kpause(const char *wmesg, bool intr, int timeo, kmutex_t *mtx);
π¦ DESCRIPTION π¦
kpause() makes the calling LWP sleep. no cap, that's the whole vibe. it's similar to cv_timedwait_sig(9) but without the matching cv_signal(9) β so like, there's nobody out here sending you a wake-up text, you just gotta wake up on your own π
heads up bestie: kpause() can wake up spontaneously. so callers, please prepare to handle that. it's giving unpredictable friend who shows up unannounced π«Ά
wmesgβ a string, no more than 8 characters, describing the resource or condition this call ofkpause()is about. the kernel doesn't actually use this argument directly, it just makes it available so utilities likeps(1)can display it. it's basically the little status message in your bio, iykyk πintrβ if true, sleep interruptably. if the LWP receives a signal, or gets interrupted by another condition β like its containing process exiting β the wait ends early and an error code gets returned. so like, the nap can be cancelled πtimeoβ specify a timeout. this is an architecture and system dependent value related to the number of clock interrupts per second. seehz(9)for the tea β themstohz(9)macro can convert a timeout expressed in milliseconds into one that's actually suitable forkpause(). very slay of it.
Zero means no timeout. literally forever nap energy π
mtxβ convenience and symmetry with other synchronization operations π if it's notNULL,mtxwill be released once the LWP has prepared to sleep, and will be reacquired beforekpause()returns. so it lets go and then picks it back up. iconic mutual exclusion behaviour, no notes π
β RETURN VALUES β
kpause() returns 0 when it wakes up spontaneously. otherwise, it returns an error number. that's it, that's the contract π
π ERRORS π
[EINTR]βkpause()returned due to other reasons. typically as a result of a signal without theSA_RESTARTproperty. the nap got interrupted fr fr π[ERESTART]βkpause()returned as a result of a signal with theSA_RESTARTproperty. so it's coming right back around π[EWOULDBLOCK]β the timeout expired. time's up babe β°
π SEE ALSO π
sigaction(2), condvar(9), delay(9), errno(9), hz(9), mstohz(9)
go read those too, they're all besties with this one π«Άβ¨
and that's the whole page, bestie ππ this Debian edition was dated July 20, 2011, so like, it's been serving these facts since before some of us could even read β respect the elders ππ
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2006, 2007 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms