SDL_CreateCond etc. not available for Win32?

I’m trying to use CondWait in my program (Win32). The
compiler complains with unresolved external functions.
Then I found out that SDL_syscond.c is not included in
the win32 directory (v1.2.7). My questions:

  • Are those cond-functions not available for Win32?
  • If available, which syscond should I compile for
    Win32?
  • If not available, what function can I use to suspend
    a thread?

thanks
Phuoc Can HUA

Find local movie times and trailers on Yahoo! Movies.
http://au.movies.yahoo.com

I’m trying to use CondWait in my program (Win32). The
compiler complains with unresolved external functions.
Then I found out that SDL_syscond.c is not included in
the win32 directory (v1.2.7). My questions:

  • Are those cond-functions not available for Win32?

Huh, apparently not.

The SDL functions should be there, but apparently haven’t ever been
filled in…this can probably be accomplished with win32’s
CreateSemaphore() and WaitForSingleObject().

  • If not available, what function can I use to suspend
    a thread?

SDL_*Mutex() is useful for 99% of synchronization issues, where you want
to make sure threads touch a resource one at a time in a serialized
fashion. Condition variables are more for blocking a bunch of threads,
and telling them all at the same time to restart…but in my experience,
most algorithms that do this are doing something very wrong.

None of these will forcibly halt a different thread than the caller, if
that’s what you were looking for.

–ryan.

  • Are those cond-functions not available for Win32?

Huh, apparently not.

The SDL functions should be there, but apparently haven’t ever been
filled in…this can probably be accomplished with win32’s
CreateSemaphore() and WaitForSingleObject().

Actually, fastest fix for this is to add this line to the end of
SDL12/src/thread/win32/SDL_sysmutex.c …

#include “generic/SDL_syscond.c”

…and recompile. Then, the SDL_Cond*() APIs will be available on Windows.

That’ll use the “generic” conditional variable implementation which is
built with SDL’s mutexes and semaphores (which eventually calls down to
win32’s CreateSemaphore(), etc, but also already does the Right Thing on
PocketPC). The Linux codebase does the same #include if you disable
pthread support (i.e. - you’re on glibc 2.0).

–ryan.

I’m trying to use CondWait in my program (Win32). The
compiler complains with unresolved external functions.
Then I found out that SDL_syscond.c is not included in
the win32 directory (v1.2.7). My questions:

  • Are those cond-functions not available for Win32?

Huh, apparently not.

Say what? I use SDL_CondWait() in my net2 and fastevents libraries. I
know these have been compiled, and work, on Windows. Something is very
weird here if they compile and work in my libraries but not for other
people.

A quick look at the code shows that SDL_syscond.c either uses pthreads
or uses a version of SDL_syscond.c in the generic subdirectory. That
version SDL_syscond.c implements the condition wait operations in terms
of mutexes. There is no need for an SDL_syscond.c in the win32
directory.

	Bob PendletonOn Wed, 2005-06-01 at 04:15 -0400, Ryan C. Gordon wrote:

The SDL functions should be there, but apparently haven’t ever been
filled in…this can probably be accomplished with win32’s
CreateSemaphore() and WaitForSingleObject().

  • If not available, what function can I use to suspend
    a thread?

SDL_*Mutex() is useful for 99% of synchronization issues, where you want
to make sure threads touch a resource one at a time in a serialized
fashion. Condition variables are more for blocking a bunch of threads,
and telling them all at the same time to restart…but in my experience,
most algorithms that do this are doing something very wrong.

None of these will forcibly halt a different thread than the caller, if
that’s what you were looking for.

–ryan.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-------------------------------------+

Meanwhile I managed to compile generic/SDL_syscond.c
and now I have to try whether it’s working as I want
:slight_smile:

Phuoc Can HUA

— Bob Pendleton wrote:> On Wed, 2005-06-01 at 04:15 -0400, Ryan C. Gordon wrote:

I’m trying to use CondWait in my program
(Win32). The

compiler complains with unresolved external
functions.

Then I found out that SDL_syscond.c is not
included in

the win32 directory (v1.2.7). My questions:

  • Are those cond-functions not available for
    Win32?

Huh, apparently not.

Say what? I use SDL_CondWait() in my net2 and
fastevents libraries. I
know these have been compiled, and work, on Windows.
Something is very
weird here if they compile and work in my libraries
but not for other
people.

A quick look at the code shows that SDL_syscond.c
either uses pthreads
or uses a version of SDL_syscond.c in the generic
subdirectory. That
version SDL_syscond.c implements the condition wait
operations in terms
of mutexes. There is no need for an SDL_syscond.c in
the win32
directory.

  Bob Pendleton

The SDL functions should be there, but
apparently haven’t ever been
filled in…this can probably be accomplished with
win32’s
CreateSemaphore() and WaitForSingleObject().

  • If not available, what function can I use to
    suspend

a thread?

SDL_*Mutex() is useful for 99% of synchronization
issues, where you want
to make sure threads touch a resource one at a
time in a serialized
fashion. Condition variables are more for blocking
a bunch of threads,
and telling them all at the same time to
restart…but in my experience,
most algorithms that do this are doing something
very wrong.

None of these will forcibly halt a different
thread than the caller, if
that’s what you were looking for.

–ryan.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-------------------------------------+


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

/_/_/_/_/_/_
www.huaonline.com
My Homepage is my Castle

Send instant messages to your online friends http://au.messenger.yahoo.com

Say what? I use SDL_CondWait() in my net2 and fastevents libraries. I
know these have been compiled, and work, on Windows. Something is very
weird here if they compile and work in my libraries but not for other
people.

I noticed the generic version a little later myself…So the better
question is, why weren’t these symbols available for Phuoc? What build
environment was this? If it’s doing the right thing in Visual Studio and
not, say, Cygwin, then something needs fixing, even if we don’t need to
implement a bunch of code after all.

–ryan.

Say what? I use SDL_CondWait() in my net2 and fastevents libraries. I
know these have been compiled, and work, on Windows. Something is very
weird here if they compile and work in my libraries but not for other
people.

I noticed the generic version a little later myself…So the better
question is, why weren’t these symbols available for Phuoc? What build
environment was this? If it’s doing the right thing in Visual Studio and
not, say, Cygwin, then something needs fixing, even if we don’t need to
implement a bunch of code after all.

Well, when I went back over everything I noticed he said version 1.2.7
and I am using the latest 1.2.8 from CVS. So… I answered the wrong
question, but perhaps he should upgrade to a newer version of SDL.

	Bob PendletonOn Thu, 2005-06-02 at 05:14 -0400, Ryan C. Gordon wrote:

–ryan.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-------------------------------------+

— Bob Pendleton wrote:

Well, when I went back over everything I noticed he
said version 1.2.7
and I am using the latest 1.2.8 from CVS. So… I
answered the wrong
question, but perhaps he should upgrade to a newer
version of SDL.
Thank you for this infomation. Currently, it’s running
okay with the added generic sources. I’ll update to
newer version in a later time.

thanks
Phuoc Can HUA

/_/_/_/_/_/_
www.huaonline.com
My Homepage is my Castle

Send instant messages to your online friends http://au.messenger.yahoo.com