summaryrefslogtreecommitdiff
path: root/usr/src/man/man3c_db/td_sync_get_info.3c_db
blob: ebf5071f3321ae78f39421d73b5830cd80d424d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
'\" te
.\" Copyright (c) 2007, Sun Microsystems, Inc.  All Rights Reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH TD_SYNC_GET_INFO 3C_DB "Nov 22, 2018"
.SH NAME
td_sync_get_info, td_ta_sync_tracking_enable, td_sync_get_stats,
td_sync_setstate, td_sync_waiters \- operations on a synchronization object in
libc_db
.SH SYNOPSIS
.LP
.nf
cc [ \fIflag\fR... ] \fIfile\fR... -lc_db [ \fIlibrary\fR... ]
#include <proc_service.h>
#include <thread_db.h>

\fBtd_err_e\fR \fBtd_sync_get_info\fR(\fBconst td_synchandle_t *\fR\fIsh_p\fR, \fBtd_syncinfo_t *\fR\fIsi_p\fR);
.fi

.LP
.nf
\fBtd_err_e\fR \fBtd_ta_sync_tracking_enable\fR(\fBconst td_thragent_t *\fR\fIta_p\fR, \fBint\fR \fIon_off\fR);
.fi

.LP
.nf
\fBtd_err_e\fR \fBtd_sync_get_stats\fR(\fBconst td_synchandle_t *\fR\fIsh_p\fR, \fBtd_syncstats_t *\fR\fIss_p\fR);
.fi

.LP
.nf
\fBtd_err_e\fR \fBtd_sync_setstate\fR(\fBconst td_synchandle_t *\fR\fIsh_p\fR, \fBint\fR \fIvalue\fR);
.fi

.LP
.nf
\fBtypedef int\fR \fBtd_thr_iter_f\fR(\fBconst td_thrhandle_t *\fR\fIth_p\fR, \fBvoid *\fR\fIcb_data_p\fR);
.fi

.LP
.nf
\fBtd_err_e\fR \fBtd_sync_waiters\fR(\fBconst td_synchandle_t *\fR\fIsh_p\fR, \fBtd_thr_iter_f *\fR\fIcb\fR,
     \fBvoid *\fR\fIcb_data_p\fR);
.fi

.SH DESCRIPTION
.sp
.LP
Synchronization objects include mutexes, condition variables, semaphores, and
reader-writer locks. In the same way that thread operations use a thread handle
of type \fBtd_thrhandle_t\fR, operations on synchronization objects use a
synchronization object handle of type \fBtd_synchandle_t\fR.
.sp
.LP
The controlling process obtains synchronization object handles either by
calling the function \fBtd_ta_sync_iter()\fR to obtain handles for all
synchronization objects of the target process that are known to the
\fBlibc_db\fR library of interfaces, or by mapping the address of a
synchronization object in the address space of the target process to a handle
by calling \fBtd_ta_map_addr2sync\fR(3C_DB).
.sp
.LP
Not all synchronization objects that a process uses can be known to the
\fBlibc_db\fR library and returned by \fBtd_ta_sync_iter\fR(3C_DB). A
synchronization object is known to \fBlibc_db\fR only if it has been the target
of a synchronization primitive in the process (such as \fBmutex_lock()\fR,
described on the \fBmutex_init\fR(3C) manual page) after \fBtd_ta_new\fR(3C_DB)
has been called to attach to the process and \fBtd_ta_sync_tracking_enable()\fR
has been called to enable synchronization object tracking.
.sp
.LP
The \fBtd_ta_sync_tracking_enable()\fR function turns synchronization object
tracking on or off for the process identified by \fIta_p\fR, depending on
whether \fIon_off\fR is 0 (off) or non-zero (on).
.sp
.LP
The \fBtd_sync_get_info()\fR function fills in the \fBtd_syncinfo_t\fR
structure \fB*\fR\fIsi_p\fR with values for the synchronization object
identified by  \fBsh_p\fR. The \fBtd_syncinfo_t\fR structure contains the
following fields:
.sp
.ne 2
.na
\fB\fBtd_thragent_t *\fR\fIsi_ta_p\fR\fR
.ad
.RS 29n
The internal process handle identifying the target process through which this
synchronization object handle was obtained.  Synchronization objects may be
process-private or process-shared. In the latter case, the same synchronization
object may have multiple handles, one for each target process's "view" of the
synchronization object.
.RE

.sp
.ne 2
.na
\fB\fBpsaddr_t\fR \fIsi_sv_addr\fR\fR
.ad
.RS 29n
The address of the synchronization object in this target process's address
space.
.RE

.sp
.ne 2
.na
\fB\fBtd_sync_type_e\fR \fIsi_type\fR\fR
.ad
.RS 29n
The type of the synchronization variable: mutex, condition variable, semaphore,
or readers-writer lock.
.RE

.sp
.ne 2
.na
\fB\fBint\fR \fIsi_shared_type\fR\fR
.ad
.RS 29n
If \fIsi_shared_type\fR is non-zero, this synchronization object is
process-shared, otherwise it is process-private.
.RE

.sp
.ne 2
.na
\fB\fBtd_sync_flags_t\fR \fIsi_flags\fR\fR
.ad
.RS 29n
Flags dependent on the type of the synchronization object.
.RE

.sp
.ne 2
.na
\fB\fBint\fR \fIsi_state.sema_count\fR\fR
.ad
.RS 29n
Semaphores only.  The current value of the semaphore
.RE

.sp
.ne 2
.na
\fB\fBint\fR \fIsi_state.nreaders\fR\fR
.ad
.RS 29n
Readers-writer locks only. The number of readers currently holding the lock, or
\fB-1\fR, if a writer is currently holding the lock.
.RE

.sp
.ne 2
.na
\fB\fBint\fR \fIsi_state.mutex_locked\fR\fR
.ad
.RS 29n
For mutexes only. Non-zero if and only if the mutex is currently locked.
.RE

.sp
.ne 2
.na
\fB\fBint\fR \fIsi_size\fR\fR
.ad
.RS 29n
The size of the synchronization object.
.RE

.sp
.ne 2
.na
\fB\fBuint8_t\fR \fIsi_has_waiters\fR\fR
.ad
.RS 29n
Non-zero if and only if at least one thread is blocked on this synchronization
object.
.RE

.sp
.ne 2
.na
\fB\fBuint8_t\fR \fIsi_is_wlocked\fR\fR
.ad
.RS 29n
For reader-writer locks only. The value is non-zero if and only if this lock is
held by a writer.
.RE

.sp
.ne 2
.na
\fB\fBuint8_t\fR \fIsi_rcount\fR\fR
.ad
.RS 29n
\fBPTHREAD_MUTEX_RECURSIVE\fR mutexes only. If the mutex is held, the recursion
count.
.RE

.sp
.ne 2
.na
\fB\fBuint8_t\fR \fIsi_prioceiling\fR\fR
.ad
.RS 29n
\fBPTHREAD_PRIO_PROTECT\fR protocol mutexes only. The priority ceiling.
.RE

.sp
.ne 2
.na
\fB\fBtd_thrhandle_t\fR \fIsi_owner\fR\fR
.ad
.RS 29n
Mutexes and readers-writer locks only. This is the thread holding the mutex, or
the write lock, if this is a reader-writer lock. The value is    \fINULL\fR if
no one holds the mutex or write-lock.
.RE

.sp
.ne 2
.na
\fB\fBpid_t\fR \fIsi_ownerpid\fR\fR
.ad
.RS 29n
Mutexes only.  For a locked process-shared mutex, this is the process-ID of the
process containing the owning thread.
.RE

.sp
.LP
The \fBtd_sync_get_stats()\fR function fills in the \fBtd_syncstats_t\fR
structure *\fIss_p\fR with values for the synchronization object identified by
\fIsh_p\fR.  The \fBtd_syncstats_t\fR structure contains an embedded
\fBtd_syncinfo_t\fR structure that is filled in as described above for
\fBtd_sync_get_info()\fR.  In addition, usage statistics gathered since
\fBtd_ta_sync_tracking_enable()\fR was called to enable synchronization object
tracking are returned in the \fBss_un.mutex\fR, \fBss_un.cond\fR,
\fBss_un.rwlock\fR, or \fBss_un.sema\fR members of the \fBtd_syncstats_t\fR
structure, depending on the type of the synchronization object.
.sp
.LP
The \fBtd_sync_setstate\fR function modifies the state of synchronization
object \fIsi_p\fR, depending on the synchronization object type. For mutexes,
\fBtd_sync_setstate\fR is unlocked if the \fIvalue\fR is \fB0\fR. Otherwise it
is locked. For semaphores, the semaphore's count is set to the \fIvalue\fR. For
reader-writer locks, the reader count set to the \fIvalue\fR if \fIvalue\fR is
\fB>0\fR. The count is set to write-locked if \fIvalue\fR is \fB-1\fR\&.
It is set to unlocked if the \fIvalue\fR is \fB0\fR. Setting the state of a
synchronization object from a \fBlibc_db\fR interface may cause the
synchronization object's semantics to be violated from the point of view of
the threads in the target process. For example, if a thread holds a mutex,
and \fBtd_sync_setstate\fR is used to set the mutex to unlocked, then a
different thread  will also be able to subsequently acquire the same mutex.
.sp
.LP
The \fBtd_sync_waiters\fR function iterates over the set of thread handles of
threads blocked on \fIsh_p\fR. The callback function \fIcb\fR is called once
for each such thread handle, and is passed  the thread handle and
\fIcb_data_p\fR. If the callback function returns a non-zero value, iteration
is terminated early. See \fBtd_ta_thr_iter\fR(3C_DB).
.SH RETURN VALUES
.sp
.ne 2
.na
\fB\fBTD_OK\fR \fR
.ad
.RS 13n
The call returned successfully.
.RE

.sp
.ne 2
.na
\fB\fBTD_BADTH\fR \fR
.ad
.RS 13n
An invalid thread handle was passed in.
.RE

.sp
.ne 2
.na
\fB\fBTD_DBERR\fR \fR
.ad
.RS 13n
A call to one of the imported interface routines failed.
.RE

.sp
.ne 2
.na
\fB\fBTD_ERR\fR \fR
.ad
.RS 13n
A libc_db-internal error occurred.
.RE

.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
MT-Level	Safe
.TE

.SH SEE ALSO
.sp
.LP
\fBlibc_db\fR(3LIB), \fBmutex_init\fR(3C), \fBtd_ta_map_addr2sync\fR(3C_DB),
\fBtd_ta_sync_iter\fR(3C_DB), \fBtd_ta_thr_iter\fR(3C_DB), \fBattributes\fR(7)