xref: /freebsd/share/man/man3/pthread_switch_add_np.3 (revision 62cfcf62f627e5093fb37026a6d8c98e4d2ef04c)
1.\" Copyright (c) 2003 Alexey Zelkin <phantom@FreeBSD.org>
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\"
13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23.\" SUCH DAMAGE.
24.\"
25.\" $FreeBSD$
26.\"
27.Dd February 13, 2003
28.Dt PTHREAD_SWITCH_ADD_NP 3
29.Os
30.Sh NAME
31.Nm pthread_switch_add_np ,
32.Nm pthread_switch_delete_np
33.Nd thread context switches debugging primitives
34.Sh LIBRARY
35.Lb libpthread
36.Sh SYNOPSIS
37.In pthread_np.h
38.Ft int
39.Fn pthread_switch_add_np "pthread_switch_routine_t routine"
40.Ft int
41.Fn pthread_switch_delete_np "pthread_switch_routine_t routine"
42.Sh DESCRIPTION
43An application is allowed to monitor the thread context switches inside
44the threading library.
45An application can install a routine that gets called every time a thread
46(explicitly created by an application with the
47.Xr pthread_create 3
48function) gets the context switched.
49The routine is passed the thread IDs of the threads that are
50being switched in and out.
51Installation and removal of these hooks may be done using the
52.Fn pthread_switch_add_np
53and
54.Fn pthread_switch_delete_np
55functions respectively.
56.Sh RETURN VALUES
57If successful,
58these functions return 0.
59Otherwise, an error number is returned to indicate the error.
60.Sh ERRORS
61The
62.Fn pthread_switch_add_np
63may fail if:
64.Bl -tag -width Er
65.It Bq Er EINVAL
66.Dv NULL
67pointer was passed in the
68.Fa routine
69argument.
70.El
71.Pp
72The
73.Fn pthread_switch_delete_np
74may fail if:
75.Bl -tag -width Er
76.It Bq Er EINVAL
77The
78.Fa routine
79argument is different from the argument previously passed to the
80.Fn pthread_switch_add_np
81function.
82.El
83.Sh SEE ALSO
84.Xr pthread_create 3
85.Sh AUTHORS
86This manual page was written by
87.An Alexey Zelkin Aq Mt phantom@FreeBSD.org .
88