Using pthread in SDL

Hello all,

I would like to know if it is OK to use the standard functions pthread_create() and pthread_join() to create/end threads with SDL instead of using the SDL thread functions?

The reason I ask is I have a tcp library that I would like to make “generic” to work with normal applications and also with games with SDL.

Thanks in advance,
Charlie

On platforms where pthreads exists SDL’s thread, mutex and semaphore
functions are simply wrappers around the pthread calls.

You can still use the direct pthread calls within an SDL application
but I do not think you can easily convert between the opaque SDL
handles for threads or mutexes setc back to the real pthread handles.

Regards

IanOn Wednesday, April 7, 2010, CharlieB wrote:

I would like to know if it is OK to use the standard functions pthread_create() and pthread_join() to create/end threads with SDL instead of using the SDL thread functions?

The reason I ask is I have a tcp library that I would like to make “generic” to work with normal applications and also with games with SDL.

just write your code so it can use bothOn 04/07/2010 02:47 AM, CharlieB wrote:

Hello all,

I would like to know if it is OK to use the standard functions
pthread_create() and pthread_join() to create/end threads with SDL
instead of using the SDL thread functions?

The reason I ask is I have a tcp library that I would like to make
"generic" to work with normal applications and also with games with SDL.

If SDL threads do everything you need, then you could strip out the SDL
thread code (I assume it doesn’t depend much on other systems) and make a
separate SDL_threads library to link with. Otherwise, yeah, pthreads are
pretty portable, so it’s no big deal to use them if you’re comfortable.

Jonny DOn Wed, Apr 7, 2010 at 1:12 AM, Marcel Wysocki wrote:

On 04/07/2010 02:47 AM, CharlieB wrote:

Hello all,

I would like to know if it is OK to use the standard functions
pthread_create() and pthread_join() to create/end threads with SDL instead
of using the SDL thread functions?

The reason I ask is I have a tcp library that I would like to make
"generic" to work with normal applications and also with games with SDL.

just write your code so it can use both


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Windows is the only major system that lacks pthreads as a system API, but there is a library that adds pthread APIs as wrappers around Windows system functions.

so yes, go ahead and use pthreads, it doesn’t really affect the portability of your code much at all. pthread’s functionality is basically the common denominator in thread support on any modern system.------------------------
EM3 Nathaniel Fries, U.S. Navy

http://natefries.net/