Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

semaphore max value #46

Closed
kazzmir opened this issue Jul 2, 2011 · 1 comment
Closed

semaphore max value #46

kazzmir opened this issue Jul 2, 2011 · 1 comment

Comments

@kazzmir
Copy link

kazzmir commented Jul 2, 2011

In SDL/src/thread/psl1ght/SDL_syssem.c:SDL_CreateSemaphore a call is made to sysSemCreate where the 4th parameter is the initial value. The 4th parameter controls the maximum value the semaphore can have.

sysSemCreate( &sem->id, &attr, initial_value, initial_value);

The initial value should not be the limit of semaphores since SDL itself sometimes creates semaphores with an initial value of 0.
SDL/src/thread/SDL_thread.c:250 in SDL_CreateThread

args->wait = SDL_CreateSemaphore(0);

The solution is to use some large value for the maximum value. I used 99 but maybe there is some better default value.

 sysSemCreate( &sem->id, &attr, initial_value, 99);

Note that without this fix the following error occurs frequently:
sysSem[Try]Wait() failed

You can see this by using a very simple test case

int test(void * arg){
  return 0;
}

int main(){
  SDL_Init();
  SDL_CreateThread(test, NULL);
}
@zeldin
Copy link
Member

zeldin commented Jul 2, 2011

Issue opened on the wrong repository. Also, fixed. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants