Problem with threads

When i do this:
SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER);
it fails with SDL_GetError() returning “Not enough resources to create
thread”.
This is kind of strange since the only resource heavy process i’m
running is X.

If i remove the SDL_INIT_TIMER everything works fine so it’s the timer
code that is the culprit.
I’ve been able to locate the exact line that causes the problem which in
the pthread version of SDL_SYS_CreateThread(SDL_Thread *thread, void
*args) in timer/SDL_systhread.c:
if ( pthread_create(&thread->handle, &type, RunThread, args) !=
0 ) {

So it’s pthread_create() that causes the whole problem. I’ve written a
small test program that uses the same code to create a thread and it
worked fine, but this particular SDL line always fails. Errno is set to
4, “Interrupted system call” after it happens.

Does anyone have any ideas of what might be the problem?

Regards,
David

EINTR… But how can that happen in that place all the time - unless
it’s (indirectly) caused by whatever syscall is returning this error?

Have you tried not initializing the other subsystems? (Audio in
particular, as that might create a thread as well.)

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------------> http://www.linuxdj.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |-------------------------------------> http://olofson.net -'On Wednesday 22 May 2002 19:03, David wrote:

When i do this:
SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER);
it fails with SDL_GetError() returning “Not enough resources to create
thread”.
This is kind of strange since the only resource heavy process i’m
running is X.

If i remove the SDL_INIT_TIMER everything works fine so it’s the timer
code that is the culprit.
I’ve been able to locate the exact line that causes the problem which
in the pthread version of SDL_SYS_CreateThread(SDL_Thread *thread, void
*args) in timer/SDL_systhread.c:
if ( pthread_create(&thread->handle, &type, RunThread, args) !=
0 ) {

So it’s pthread_create() that causes the whole problem. I’ve written a
small test program that uses the same code to create a thread and it
worked fine, but this particular SDL line always fails. Errno is set to
4, “Interrupted system call” after it happens.

David Olofson wrote:>On Wednesday 22 May 2002 19:03, David wrote:

When i do this:
SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER);
it fails with SDL_GetError() returning “Not enough resources to create
thread”.
This is kind of strange since the only resource heavy process i’m
running is X.

If i remove the SDL_INIT_TIMER everything works fine so it’s the timer
code that is the culprit.
I’ve been able to locate the exact line that causes the problem which
in the pthread version of SDL_SYS_CreateThread(SDL_Thread *thread, void
*args) in timer/SDL_systhread.c:
if ( pthread_create(&thread->handle, &type, RunThread, args) !=
0 ) {

So it’s pthread_create() that causes the whole problem. I’ve written a
small test program that uses the same code to create a thread and it
worked fine, but this particular SDL line always fails. Errno is set to
4, “Interrupted system call” after it happens.

EINTR… But how can that happen in that place all the time - unless
it’s (indirectly) caused by whatever syscall is returning this error?

Have you tried not initializing the other subsystems? (Audio in
particular, as that might create a thread as well.)

All this code is from a project called scummvm so it should work even though
it doesn’t on my box. Anyway, if i remove the SDL_INIT_TIMER from the
SDL_Init call everything works fine except scummvm requires the timer to
function properly. (I.e. no SDL errors)

EINTR… But how can that happen in that place all the time - unless
it’s (indirectly) caused by whatever syscall is returning this error?

All this code is from a project called scummvm so it should work even though
it doesn’t on my box. Anyway, if i remove the SDL_INIT_TIMER from the
SDL_Init call everything works fine except scummvm requires the timer to
function properly. (I.e. no SDL errors)

I’m not sure why you would get EINTR, unless maybe the video connection
is setting up signal polled I/O (SDL doesn’t ask for this).

In any case, you can call SDL_Init() with the timer argument after setting
up the audio and video.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Sam Lantinga wrote:

EINTR… But how can that happen in that place all the time - unless
it’s (indirectly) caused by whatever syscall is returning this error?

All this code is from a project called scummvm so it should work even though
it doesn’t on my box. Anyway, if i remove the SDL_INIT_TIMER from the
SDL_Init call everything works fine except scummvm requires the timer to
function properly. (I.e. no SDL errors)

I’m not sure why you would get EINTR, unless maybe the video connection
is setting up signal polled I/O (SDL doesn’t ask for this).

In any case, you can call SDL_Init() with the timer argument after setting
up the audio and video.

The same thing happens if i seperate the initizialtion of audio and
video, it even happnes if all i do is initialize the timer. E.g:

#include <SDL.h>
#include <stdio.h>

int main()
{
if( SDL_Init( SDL_INIT_TIMER )==-1) {
printf("%s\n", SDL_GetError() );
}
}

Will print:
Not enough resources to create thread.
Through all the little printfs i put in the sdl timer code i can tell
that it’s still failing on the same line (pthread_create() in
sdl_systimer.c) with the same errno (EINTR).