Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5131 clevermous 1
2
>
3
>
4
>SDL_SemWait
5
>
6
NAME="GENERATOR"
7
CONTENT="Modular DocBook HTML Stylesheet Version 1.64
8
">
9
REL="HOME"
10
TITLE="SDL Library Documentation"
11
HREF="index.html">
12
REL="UP"
13
TITLE="Multi-threaded Programming"
14
HREF="thread.html">
15
REL="PREVIOUS"
16
TITLE="SDL_DestroySemaphore"
17
HREF="sdldestroysemaphore.html">
18
REL="NEXT"
19
TITLE="SDL_SemTryWait"
20
HREF="sdlsemtrywait.html">
21
>
22
CLASS="REFENTRY"
23
BGCOLOR="#FFF8DC"
24
TEXT="#000000"
25
LINK="#0000ee"
26
VLINK="#551a8b"
27
ALINK="#ff0000"
28
>
29
CLASS="NAVHEADER"
30
>
31
WIDTH="100%"
32
BORDER="0"
33
CELLPADDING="0"
34
CELLSPACING="0"
35
>
36
>
37
COLSPAN="3"
38
ALIGN="center"
39
>SDL Library Documentation
40
>
41
>
42
>
43
WIDTH="10%"
44
ALIGN="left"
45
VALIGN="bottom"
46
>
47
HREF="sdldestroysemaphore.html"
48
>Prev
49
>
50
>
51
WIDTH="80%"
52
ALIGN="center"
53
VALIGN="bottom"
54
>
55
>
56
WIDTH="10%"
57
ALIGN="right"
58
VALIGN="bottom"
59
>
60
HREF="sdlsemtrywait.html"
61
>Next
62
>
63
>
64
>
65
>
66
ALIGN="LEFT"
67
WIDTH="100%">
68
>
69
>
70
NAME="SDLSEMWAIT"
71
>SDL_SemWait
72
>
73
>
74
CLASS="REFNAMEDIV"
75
>
76
NAME="AEN7474"
77
>
78
>
79
>Name
80
>SDL_SemWait -- Lock a semaphore and suspend the thread if the semaphore value is zero.
81
>
82
CLASS="REFSYNOPSISDIV"
83
>
84
NAME="AEN7477"
85
>
86
>
87
>Synopsis
88
>
89
CLASS="FUNCSYNOPSIS"
90
>
91
NAME="AEN7478"
92
>
93
>
94
>
95
>
96
CLASS="FUNCSYNOPSISINFO"
97
>#include "SDL.h"
98
#include "SDL_thread.h"
99
>
100
>
101
>
102
CLASS="FUNCDEF"
103
>int 
104
CLASS="FSFUNC"
105
>SDL_SemWait
106
>
107
>(SDL_sem *sem);
108
>
109
>
110
>
111
>
112
>
113
>
114
CLASS="REFSECT1"
115
>
116
NAME="AEN7484"
117
>
118
>
119
>Description
120
>
121
>
122
CLASS="FUNCTION"
123
>SDL_SemWait()
124
> suspends the calling thread until either
125
the semaphore pointed to by 
126
CLASS="PARAMETER"
127
>
128
>sem
129
>
130
> has a positive value,
131
the call is interrupted by a signal or error. If the call is successful it
132
will atomically decrement the semaphore value.
133
>
134
>After 
135
CLASS="FUNCTION"
136
>SDL_SemWait()
137
> is successful, the semaphore
138
can be released and its count atomically incremented by a successful call to
139
140
HREF="sdlsempost.html"
141
>SDL_SemPost
142
>.
143
>
144
>
145
CLASS="REFSECT1"
146
>
147
NAME="AEN7492"
148
>
149
>
150
>Return Value
151
>
152
>Returns 
153
CLASS="RETURNVALUE"
154
>0
155
> if successful or
156
157
CLASS="RETURNVALUE"
158
>-1
159
> if there was an error (leaving the semaphore unchanged).
160
>
161
>
162
CLASS="REFSECT1"
163
>
164
NAME="AEN7497"
165
>
166
>
167
>Examples
168
>
169
>
170
CLASS="PROGRAMLISTING"
171
>if (SDL_SemWait(my_sem) == -1) {
172
        return WAIT_FAILED;
173
}
174
 
175
...
176
 
177
SDL_SemPost(my_sem);
178
>
179
>
180
>
181
CLASS="REFSECT1"
182
>
183
NAME="AEN7501"
184
>
185
>
186
>See Also
187
>
188
>
189
HREF="sdlcreatesemaphore.html"
190
>
191
CLASS="FUNCTION"
192
>SDL_CreateSemaphore
193
>
194
>,
195
196
HREF="sdldestroysemaphore.html"
197
>
198
CLASS="FUNCTION"
199
>SDL_DestroySemaphore
200
>
201
>,
202
203
HREF="sdlsemtrywait.html"
204
>
205
CLASS="FUNCTION"
206
>SDL_SemTryWait
207
>
208
>,
209
210
HREF="sdlsemwaittimeout.html"
211
>
212
CLASS="FUNCTION"
213
>SDL_SemWaitTimeout
214
>
215
>,
216
217
HREF="sdlsempost.html"
218
>
219
CLASS="FUNCTION"
220
>SDL_SemPost
221
>
222
>,
223
224
HREF="sdlsemvalue.html"
225
>
226
CLASS="FUNCTION"
227
>SDL_SemValue
228
>
229
>
230
>
231
>
232
CLASS="NAVFOOTER"
233
>
234
ALIGN="LEFT"
235
WIDTH="100%">
236
WIDTH="100%"
237
BORDER="0"
238
CELLPADDING="0"
239
CELLSPACING="0"
240
>
241
>
242
WIDTH="33%"
243
ALIGN="left"
244
VALIGN="top"
245
>
246
HREF="sdldestroysemaphore.html"
247
>Prev
248
>
249
>
250
WIDTH="34%"
251
ALIGN="center"
252
VALIGN="top"
253
>
254
HREF="index.html"
255
>Home
256
>
257
>
258
WIDTH="33%"
259
ALIGN="right"
260
VALIGN="top"
261
>
262
HREF="sdlsemtrywait.html"
263
>Next
264
>
265
>
266
>
267
>
268
WIDTH="33%"
269
ALIGN="left"
270
VALIGN="top"
271
>SDL_DestroySemaphore
272
>
273
WIDTH="34%"
274
ALIGN="center"
275
VALIGN="top"
276
>
277
HREF="thread.html"
278
>Up
279
>
280
>
281
WIDTH="33%"
282
ALIGN="right"
283
VALIGN="top"
284
>SDL_SemTryWait
285
>
286
>
287
>
288
>
289
>
290
>