4 >Multi-threaded Programming</TITLE
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
10 TITLE="SDL Library Documentation"
11 HREF="index.html"><LINK
14 HREF="reference.html"><LINK
17 HREF="sdlcdtrack.html"><LINK
19 TITLE="SDL_CreateThread"
20 HREF="sdlcreatethread.html"><META
22 CONTENT="threads"><META
24 CONTENT="function"></HEAD
35 SUMMARY="Header navigation table"
44 >SDL Library Documentation</TH
52 HREF="sdlcdtrack.html"
66 HREF="sdlcreatethread.html"
81 >Chapter 12. Multi-threaded Programming</H1
91 HREF="sdlcreatethread.html"
93 > -- Creates a new thread of execution that shares its parent's properties.</DT
96 HREF="sdlthreadid.html"
98 > -- Get the 32-bit thread identifier for the current thread.</DT
101 HREF="sdlgetthreadid.html"
103 > -- Get the SDL thread ID of a SDL_Thread</DT
106 HREF="sdlwaitthread.html"
108 > -- Wait for a thread to finish.</DT
111 HREF="sdlkillthread.html"
113 > -- Gracelessly terminates the thread.</DT
116 HREF="sdlcreatemutex.html"
118 > -- Create a mutex</DT
121 HREF="sdldestroymutex.html"
123 > -- Destroy a mutex</DT
126 HREF="sdlmutexp.html"
128 > -- Lock a mutex</DT
131 HREF="sdlmutexv.html"
133 > -- Unlock a mutex</DT
136 HREF="sdlcreatesemaphore.html"
137 >SDL_CreateSemaphore</A
138 > -- Creates a new semaphore and assigns an initial value to it.</DT
141 HREF="sdldestroysemaphore.html"
142 >SDL_DestroySemaphore</A
143 > -- Destroys a semaphore that was created by <A
144 HREF="sdlcreatesemaphore.html"
145 >SDL_CreateSemaphore</A
149 HREF="sdlsemwait.html"
151 > -- Lock a semaphore and suspend the thread if the semaphore value is zero.</DT
154 HREF="sdlsemtrywait.html"
156 > -- Attempt to lock a semaphore but don't suspend the thread.</DT
159 HREF="sdlsemwaittimeout.html"
160 >SDL_SemWaitTimeout</A
161 > -- Lock a semaphore, but only wait up to a specified maximum time.</DT
164 HREF="sdlsempost.html"
166 > -- Unlock a semaphore.</DT
169 HREF="sdlsemvalue.html"
171 > -- Return the current value of a semaphore.</DT
174 HREF="sdlcreatecond.html"
176 > -- Create a condition variable</DT
179 HREF="sdldestroycond.html"
181 > -- Destroy a condition variable</DT
184 HREF="sdlcondsignal.html"
186 > -- Restart a thread wait on a condition variable</DT
189 HREF="sdlcondbroadcast.html"
190 >SDL_CondBroadcast</A
191 > -- Restart all threads waiting on a condition variable</DT
194 HREF="sdlcondwait.html"
196 > -- Wait on a condition variable</DT
199 HREF="sdlcondwaittimeout.html"
200 >SDL_CondWaitTimeout</A
201 > -- Wait on a condition variable, with timeout</DT
205 >SDL provides functions for creating threads, mutexes, semphores and condition variables.</P
207 >In general, you must be very aware of concurrency and data integrity issues
208 when writing multi-threaded programs. Some good guidelines include:
214 >Don't call SDL video/event functions from separate threads</P
218 >Don't use any library functions in separate threads</P
222 >Don't perform any memory management in separate threads</P
226 >Lock global variables which may be accessed by multiple threads</P
230 >Never terminate threads, always set a flag and wait for them to quit</P
234 >Think very carefully about all possible ways your code may interact</P
245 >SDL's threading is not implemented on MacOS, due to that lack of preemptive thread support (Mac OS X dos nt suffer from this problem)</P
254 SUMMARY="Footer navigation table"
265 HREF="sdlcdtrack.html"
283 HREF="sdlcreatethread.html"
299 HREF="reference.html"
307 >SDL_CreateThread</TD