Friday, August 07, 2009

Even more symbian woes

Symbian has pthreads support, but it sucks, yesterday i discovered it has a maximum number of threads you can create, that is

void *dumb_thread(void *)
{
pthread_exit(NULL)
}

function_somewhere_in_my_code()
{
pthread_t t;
int error = pthread_create(&t, NULL, dumb_thread, NULL);
check_error();
pthread_join(t, NULL);
call_function_somewhere_in_my_code_though_a_timer();
}

will end up returning error 35 (EAGAIN) in pthread_create after some calls, depending on the phone it can be 20000 or 60000, and yes, that's a lot of threads, but if you are using threads for fire and forget jobs it's relatively easy to hit that number, so i've been forced to implement a thread pool just to workaround yetAnotherSymbianBug.

And yes, this has nothing to do with KDE, except that the more i code in Symbian the more i appreciate the rock solid API provided by KDE and Qt

3 comments:

Martin Sandsmark said...

The bad pthread support is what's holding back the VLC port too, fwiw. So you're not alone in your woes :-P

Andreas said...

So if I understand this correctly this is not about the number of simultaneous threads - there is a maximum number of threads you can create (and destroy most of them) in sequence before it's game over?

Albert Astals Cid said...

@Andres: exactly, i can understand a limit in the number of simultaneous threads, but a number of total threads created is just bad implementation in my opinion