xref: /freebsd/share/man/man3/pthread_switch_add_np.3 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
1318d8cfdSAlexey Zelkin.\" Copyright (c) 2003 Alexey Zelkin <phantom@FreeBSD.org>
2318d8cfdSAlexey Zelkin.\" All rights reserved.
3318d8cfdSAlexey Zelkin.\"
4318d8cfdSAlexey Zelkin.\" Redistribution and use in source and binary forms, with or without
5318d8cfdSAlexey Zelkin.\" modification, are permitted provided that the following conditions
6318d8cfdSAlexey Zelkin.\" are met:
7318d8cfdSAlexey Zelkin.\" 1. Redistributions of source code must retain the above copyright
8318d8cfdSAlexey Zelkin.\"    notice, this list of conditions and the following disclaimer.
9318d8cfdSAlexey Zelkin.\" 2. Redistributions in binary form must reproduce the above copyright
10318d8cfdSAlexey Zelkin.\"    notice, this list of conditions and the following disclaimer in the
11318d8cfdSAlexey Zelkin.\"    documentation and/or other materials provided with the distribution.
12318d8cfdSAlexey Zelkin.\"
13318d8cfdSAlexey Zelkin.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14318d8cfdSAlexey Zelkin.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15318d8cfdSAlexey Zelkin.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16318d8cfdSAlexey Zelkin.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17318d8cfdSAlexey Zelkin.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18318d8cfdSAlexey Zelkin.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19318d8cfdSAlexey Zelkin.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20318d8cfdSAlexey Zelkin.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21318d8cfdSAlexey Zelkin.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22318d8cfdSAlexey Zelkin.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23318d8cfdSAlexey Zelkin.\" SUCH DAMAGE.
24318d8cfdSAlexey Zelkin.\"
25*df7d7638SFelix Johnson.Dd October 12, 2021
26318d8cfdSAlexey Zelkin.Dt PTHREAD_SWITCH_ADD_NP 3
27318d8cfdSAlexey Zelkin.Os
28318d8cfdSAlexey Zelkin.Sh NAME
29318d8cfdSAlexey Zelkin.Nm pthread_switch_add_np ,
30318d8cfdSAlexey Zelkin.Nm pthread_switch_delete_np
31ace5be68SRuslan Ermilov.Nd thread context switches debugging primitives
32318d8cfdSAlexey Zelkin.Sh LIBRARY
335bb9f210SRuslan Ermilov.Lb libpthread
34318d8cfdSAlexey Zelkin.Sh SYNOPSIS
35318d8cfdSAlexey Zelkin.In pthread_np.h
36318d8cfdSAlexey Zelkin.Ft int
37318d8cfdSAlexey Zelkin.Fn pthread_switch_add_np "pthread_switch_routine_t routine"
38318d8cfdSAlexey Zelkin.Ft int
39318d8cfdSAlexey Zelkin.Fn pthread_switch_delete_np "pthread_switch_routine_t routine"
40318d8cfdSAlexey Zelkin.Sh DESCRIPTION
41ace5be68SRuslan ErmilovAn application is allowed to monitor the thread context switches inside
42ace5be68SRuslan Ermilovthe threading library.
43ace5be68SRuslan ErmilovAn application can install a routine that gets called every time a thread
44ace5be68SRuslan Ermilov(explicitly created by an application with the
45ace5be68SRuslan Ermilov.Xr pthread_create 3
46ace5be68SRuslan Ermilovfunction) gets the context switched.
47ace5be68SRuslan ErmilovThe routine is passed the thread IDs of the threads that are
48318d8cfdSAlexey Zelkinbeing switched in and out.
49ace5be68SRuslan ErmilovInstallation and removal of these hooks may be done using the
50318d8cfdSAlexey Zelkin.Fn pthread_switch_add_np
51318d8cfdSAlexey Zelkinand
52318d8cfdSAlexey Zelkin.Fn pthread_switch_delete_np
53318d8cfdSAlexey Zelkinfunctions respectively.
54318d8cfdSAlexey Zelkin.Sh RETURN VALUES
55318d8cfdSAlexey ZelkinIf successful,
56ace5be68SRuslan Ermilovthese functions return 0.
57318d8cfdSAlexey ZelkinOtherwise, an error number is returned to indicate the error.
58318d8cfdSAlexey Zelkin.Sh ERRORS
59318d8cfdSAlexey ZelkinThe
60318d8cfdSAlexey Zelkin.Fn pthread_switch_add_np
61318d8cfdSAlexey Zelkinmay fail if:
62318d8cfdSAlexey Zelkin.Bl -tag -width Er
63318d8cfdSAlexey Zelkin.It Bq Er EINVAL
64ace5be68SRuslan Ermilov.Dv NULL
65ace5be68SRuslan Ermilovpointer was passed in the
66318d8cfdSAlexey Zelkin.Fa routine
67318d8cfdSAlexey Zelkinargument.
68318d8cfdSAlexey Zelkin.El
69ace5be68SRuslan Ermilov.Pp
70318d8cfdSAlexey ZelkinThe
71318d8cfdSAlexey Zelkin.Fn pthread_switch_delete_np
72318d8cfdSAlexey Zelkinmay fail if:
73318d8cfdSAlexey Zelkin.Bl -tag -width Er
74318d8cfdSAlexey Zelkin.It Bq Er EINVAL
75ace5be68SRuslan ErmilovThe
76318d8cfdSAlexey Zelkin.Fa routine
77ace5be68SRuslan Ermilovargument is different from the argument previously passed to the
78318d8cfdSAlexey Zelkin.Fn pthread_switch_add_np
79ace5be68SRuslan Ermilovfunction.
80318d8cfdSAlexey Zelkin.El
81318d8cfdSAlexey Zelkin.Sh SEE ALSO
82*df7d7638SFelix Johnson.Xr pthread_create 3 ,
83*df7d7638SFelix Johnson.Xr pthread_np 3
84318d8cfdSAlexey Zelkin.Sh AUTHORS
85ace5be68SRuslan ErmilovThis manual page was written by
86a63d6c94SBaptiste Daroussin.An Alexey Zelkin Aq Mt phantom@FreeBSD.org .
87