[SDL] What are threads allowed to do?

Stephane Marchesin stephane.marchesin at wanadoo.fr
Sat Jan 22 08:21:05 PST 2005


Albert Cahalan wrote:

>On Thu, 2005-01-20 at 19:37, Bob Ippolito wrote:
>
>>On Jan 20, 2005, at 19:08, Albert Cahalan wrote:
>>
>>>Looking here:
>>>http://sdldoc.csn.ul.ie/thread.php
>>>
>>>I find these bits of advice:
>>>
>>>1. Don't use any library functions in separate threads
>>>
>>>2. Lock global variables which may be accessed by multiple threads
>>>
>>>Cool. Taken literally, this means that a thread may
>>>only burn CPU time. It can not access global variables,
>>>because locking them would require a library function. The
>>>thread can not exit; that would require a library function..
>>>
>>>What's the real story?
>>>
>>The thread related functions required for synchronization are of course 
>>thread-safe.  Those are guidelines, not strict rules.
>>
>
>I figured as much, but...
>
>Mere guidelines alone don't make for solid software. Am I to assume
>that all other SDL functions are unsafe? The same for C library stuff
>on the various supported platforms? If this is the case, then threads
>are quite useless.
>
That's the bottom line, if you don't understand threads, they do more 
harm than good.

>
>I tried using threads, hit memory corruption problems, and...
>
Well, show us a small program demonstrating memory corruption with SDL 
threads, and we'll have a chance to find the reason for this problem.

Stephane







More information about the SDL mailing list