SYSMON_TASKQ(9)
π SYSMON_TASKQ π
okay so bestie, welcome to sysmon_taskq β it's a page from the Kernel Developer's Manual (section 9, the kernel-functions zone, iykyk), and it's literally the general purpose system monitoring task queue. yes the name is a mouthful. no we're not changing it. let's go π
β¨ SYNOPSIS β¨
#include <dev/sysmon/sysmon_taskq.h>
void
sysmon_task_queue_preinit(void);
void
sysmon_task_queue_init(void);
void
sysmon_task_queue_fini(void);
int
sysmon_task_queue_sched(u_int pri, void (*func)(void *), void *arg);
void
sysmon_task_queue_barrier(u_int pri);
πΈ DESCRIPTION πΈ
so the sysmon_taskq is machine-independent, which is the cute way of saying it doesn't care what hardware you're on, and it gives you a simple general purpose task queue. that's the whole vibe. it's here to run callbacks that need thread context but honestly do not warrant pulling out some more fine-grained solution. like, don't over-engineer it, bestie. π
the intended usage is all about system monitoring and power management context, but ngl, other comparable functions are also totally suitable for sysmon_taskq. it's not gatekeeping. π«Ά
π¦ FUNCTIONS π¦
π the setup trio
the necessary internal data structures get initialized during system startup by sysmon_task_queue_preinit(). that's the pregame. β¨
before you can actually use it, a machine-dependent procedure should finish the initialization by calling sysmon_task_queue_init(). this is the one that creates a kernel thread, and that thread can later be halted by sysmon_task_queue_fini(). and here's the important part β all scheduled tasks are executed before the queue is halted. no yeeting pending work into the void. queen behavior honestly. π
π the actual scheduling
sysmon_task_queue_sched()β enqueuesfuncto be executed at the prioritypri. ifpriis0, the scheduled function gets placed as the last element in the queue (aka back of the line, no cutting). the single argument passed tofuncis specified byarg. one arg, that's it, that's the contract. πsysmon_task_queue_barrier()β waits for the completion of all tasks atprior lower currently queued at the time of the call. read that again: at the time of the call. it's a vibe check for the queue, not a forever-wait. β
π₯ RETURN VALUES π₯
upon successful completion, sysmon_task_queue_sched() returns 0. slay. otherwise, you get one of these little error icons:
[EINVAL]β an invalid parameter was specified. bestie, check your args. π[ENOMEM]β there was not enough memory. π
π SEE ALSO π
queue(3), kthread(9), workqueue(9)
go read those too, fr fr. iykyk. π
π AUTHORS π
Jason R. Thorpe <thorpej@NetBSD.org> β the main character who wrote this. respect the icon. π
π§ tiny reminder: this page is from the kernel dev manual, so everything here is kernel-land. no cap. don't go calling these from your little userland program, it's giving undefined behavior. π«Ά
and that's the page, bestie! this rendered all the way from the Debian edition, dated January 24, 2010 β yes she's vintage, and she still ate. π β¨π
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2010 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