xref: /netbsd-src/share/man/man9/sysmon_taskq.9 (revision b1c86f5f087524e68db12794ee9c3e3da1ab17a0)
1.\" $NetBSD: sysmon_taskq.9,v 1.6 2010/01/26 08:48:39 jruoho 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.Sh DESCRIPTION
47The machine-independent
48.Nm
49provides a simple general purpose task queue.
50It can be used to run callbacks that require thread context,
51but do not warrant the use of a more fine-grained solution.
52.Pp
53Although the intended usage is related to the context of system monitoring
54and power management, also other comparable functions are suitable for
55.Nm .
56.Sh FUNCTIONS
57The necessary internal data structures
58are initialized during system startup by
59.Fn sysmon_task_queue_preinit .
60Before actual usage, a machine-dependent
61procedure should finish the initialization
62by calling
63.Fn sysmon_task_queue_init .
64This will create a kernel thread that can be later halted by
65.Fn sysmon_task_queue_fini .
66All scheduled tasks are executed before the queue is halted.
67.Pp
68The
69.Fn sysmon_task_queue_sched
70enqueues
71.Fa func
72to be executed at the priority
73.Fa pri .
74If
75.Fa pri
76is 0, the scheduled function will be placed as the last element in the queue.
77The single argument passed to
78.Fa func
79is specified by
80.Fa arg .
81.Sh RETURN VALUES
82Upon successful completion,
83.Fn sysmon_task_queue_sched
84returns 0.
85Otherwise, the following error values are returned:
86.Bl -tag -width [EINVAL]
87.It Bq Er EINVAL
88An invalid parameter was specified.
89.It Bq Er ENOMEM
90There was not enough memory.
91.El
92.Sh SEE ALSO
93.Xr queue 3 ,
94.Xr kthread 9 ,
95.Xr workqueue 9
96.Sh AUTHORS
97.An Jason R. Thorpe Aq thorpej@NetBSD.org
98