Hi,

For fun I ported the thread library from android to uclibc.
I do the port in a way that doesn't touch uclibc code and not the main 
android thread code (pthread.c semaphore.c).

android thread library (from bionic libc) is minimalist :
- use most of the linux kernel thread features (futex, CLONE_THREAD) 
unlike old linuxpthread.
- it doesn't support thread cancellation (see CAVEATS file)
- it misses some pthread functions : for example no barrier, missing 
*timedwait variant, ...
- very basic gdb support that only work through gdbserver
- some theoric race

The arch-os depend part are very small : only atomic operations 
(__atomic_cmpxchg, __atomic_swap and __atomic_dec,__atomic_inc) and tls 
(getting and setting a thread local pointer).
So it could be easily portable on other arches.

There is a know issue in the port : the thread stacks aren't freed when 
the thread end. This is because the bionic code assume we can unmap the 
thread stack and then exit the thread. This may be done in assembler 
(that's what they did for arm), but I am lazy to do it for x86 and want 
to find a generic solution. That could be done for example by freeing 
the stack in pthread_join/pthread_create or reusing it for latter 
pthread_create.

The uClibc integration is quite ugly :
- No internal function are used (syscall vs INTERNAL_SYSCALL)
- it didn't understand the need of forward.c and did only defaction stub.
- lot's of potentials bugs : I only run uclibc testcase

At the moment it only work on x86 (size 13,5 KB), to use it on 0.9.30 :
$ rm -rf libpthread/linuxthreads.old libpthread/linuxthreads.old_db
$ tar -xzf bionic_thread.tar.gz [1]
and select the old linuxthreads thread library.


Matthieu

[1] http://castet.matthieu.free.fr/download/bionic_thread.tar.gz
_______________________________________________
uClibc mailing list
uClibc@uclibc.org
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Reply via email to