xref: /netbsd-src/share/man/man9/sysmon_taskq.9 (revision 88580404b3929db4e804464968897068c49c3d25)
1.\" $NetBSD: sysmon_taskq.9,v 1.9 2021/12/31 14:22:10 riastradh Exp $
2.\"
3.\" Copyright (c) 2010 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Jukka Ruohonen.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.Dd January 24, 2010
31.Dt SYSMON_TASKQ 9
32.Os
33.Sh NAME
34.Nm sysmon_taskq
35.Nd general purpose system monitoring task queue
36.Sh SYNOPSIS
37.In dev/sysmon/sysmon_taskq.h
38.Ft void
39.Fn sysmon_task_queue_preinit "void"
40.Ft void
41.Fn sysmon_task_queue_init "void"
42.Ft void
43.Fn sysmon_task_queue_fini "void"
44.Ft int
45.Fn sysmon_task_queue_sched "u_int pri" "void (*func)(void *)" "void *arg"
46.Ft void
47.Fn sysmon_task_queue_barrier "u_int pri"
48.Sh DESCRIPTION
49The machine-independent
50.Nm
51provides a simple general purpose task queue.
52It can be used to run callbacks that require thread context,
53but do not warrant the use of a more fine-grained solution.
54.Pp
55Although the intended usage is related to the context of system monitoring
56and power management, also other comparable functions are suitable for
57.Nm .
58.Sh FUNCTIONS
59The necessary internal data structures
60are initialized during system startup by
61.Fn sysmon_task_queue_preinit .
62Before actual usage, a machine-dependent
63procedure should finish the initialization
64by calling
65.Fn sysmon_task_queue_init .
66This will create a kernel thread that can be later halted by
67.Fn sysmon_task_queue_fini .
68All scheduled tasks are executed before the queue is halted.
69.Pp
70The
71.Fn sysmon_task_queue_sched
72function enqueues
73.Fa func
74to be executed at the priority
75.Fa pri .
76If
77.Fa pri
78is 0, the scheduled function will be placed as the last element in the queue.
79The single argument passed to
80.Fa func
81is specified by
82.Fa arg .
83.Pp
84The
85.Fn sysmon_task_queue_barrier
86function waits for the completion of all tasks at
87.Fa pri
88or lower currently queued at the time of the call.
89.Sh RETURN VALUES
90Upon successful completion,
91.Fn sysmon_task_queue_sched
92returns 0.
93Otherwise, the following error values are returned:
94.Bl -tag -width [EINVAL]
95.It Bq Er EINVAL
96An invalid parameter was specified.
97.It Bq Er ENOMEM
98There was not enough memory.
99.El
100.Sh SEE ALSO
101.Xr queue 3 ,
102.Xr kthread 9 ,
103.Xr workqueue 9
104.Sh AUTHORS
105.An Jason R. Thorpe Aq Mt thorpej@NetBSD.org
106