SDL 1.2.5 NetBSD problems

Hi!

I’m trying to get the timer to work on NetBSD. The problem is that it
seems that my callback function is never called. Did anyone experience
this?

I register the callback like this:

my_timer_id = SDL_AddTimer(10, my_callback_function, NULL);

Note that this does work on other systems like Linux, Win32 cygwin and
others.

best regards

STan

Hi,

At Thu, 24 Oct 2002 14:56:47 +0200 (CEST),
Standa Opichal wrote:

I’m trying to get the timer to work on NetBSD. The problem is that it
seems that my callback function is never called. Did anyone experience
this?

I register the callback like this:

my_timer_id = SDL_AddTimer(10, my_callback_function, NULL);

“never called” means

  1. my_timer_id == NULL, then never called?
  2. my_timer_id != NULL, but never called?

Have you tried SDL-1.2.5/test/testtimer?
If it works good, then

  1. have you initialized SDL with SDL_INIT_TIMER?
  2. how did you install pth?
    . if by pkgsrc, which did you use? devel/pth or devel/pth-syscall ?
    /* . if you use devel/pth, pre-defining
    _POSIX_THREAD_SYSCALL_SOFT=1 makes some progress? */
  3. what does your SDL-1.2.5/config.log say about detecting pthread/pth ?

BTW, I runned a tiny program (like following) on my NetBSD box
(NetBSD 1.6BETA1, SDL-1.2.5, pth-syscall-1.4.1nb1) and it works good.

#include <SDL.h>

Uint32 timerfunc(Uint32 interval, void* value)
{
int* counter = (int*)value;
fprintf(stderr, “%d: %d\n”, SDL_GetTicks(), *counter);
(*counter)++;

return interval;

}

int main(void)
{
int counter = 0;
SDL_TimerID timerid;
SDL_Init(SDL_INIT_TIMER);
timerid = SDL_AddTimer(10, timerfunc, (void*)&counter);
if(timerid != NULL){
fprintf(stderr, “waiting…\n”);
SDL_Delay(1000);
SDL_RemoveTimer(timerid);
return 0;
}
return 1;
}–

Tsuyoshi Iguchi (zinnia at risky-safety.org)
http://risky-safety.org/zinnia/
http://zinnia.dyndns.org/

Hi!

Have you tried SDL-1.2.5/test/testtimer?
If it works good, then

The testtimer works fine here.

  1. have you initialized SDL with SDL_INIT_TIMER?
  2. how did you install pth?

Through pkgsrc.

. if by pkgsrc, which did you use? devel/pth or devel/pth-syscall
?

It’s devel/pth-1.4.1nb2. There is no longer any package like
devel/pth-syscall. pth-1.4.1nb2 use the --enable-syscall-hard option.

/* . if you use devel/pth, pre-defining
_POSIX_THREAD_SYSCALL_SOFT=1 makes some progress? */
3. what does your SDL-1.2.5/config.log say about detecting
pthread/pth ?

SDL is configured with --disable-pthreads --enable-pth.

config.log:

configure:5760: checking for pthread-config
configure:5804: checking pth

BTW, I runned a tiny program (like following) on my NetBSD box
(NetBSD 1.6BETA1, SDL-1.2.5, pth-syscall-1.4.1nb1) and it works
good.

Yes, work here too:

gcc -o sdl-test -Wall sdl-test.c -I/usr/pkg/include/SDL -L/usr/pkg/lib
-lSDL -lpth

./sdl-test
waiting…
2: 0
12: 1
32: 2
52: 3
72: 4

I’ve investigated this issue with a friend of mine… It don’t know much
about the pth vs. pthread lib issues, but it seems that pth implements
thread emulation for possibly non-preemptive OSes. If this is true and
since NetBSD supports native preemptive threading then the NetBSD port
should be built against the pthread to support OS native preemptive
threads.

Anyway if the pth is used than the timer stuff doesn’t work under
some circumstances.

– snip –

Perhaps SDL_Delay(20*1000) right after the SDL_AddTimer() would help?
Also add a printf(“YEAH\n”) to the begining of the callback function.

I think I now the reason. As SDL is compiled with pth lib the thread model
is user space, non-preemptive. So the thread switching is only done if a
syscall is done (pth lib with syscall mapping hard) or if the pth
scheduler is explicitly called.
– end snip –

This issue is possibly related to the mail:> Date: Mon, 28 Oct 2002 20:49:51 +0100

From: Patrice Mandin
Subject: pth support/detection in configure.in

best regards

STan