pthread malloc
Nikola Vladov <[email protected]>
| Newsgroups | gmane.linux.lib.dietlibc |
|---|---|
| Message-ID | <[email protected]> |
Hi! I added pthread support for alloc.
Now all [__libc_]{malloc|realloc|calloc|free}
are thread safe. Actually I modified only malloc and free.
This make them with 20-30 bytes bigger.
My thread safe implementation is shorter than current
dietlibc (not thread save). It was difficult to test
if all works good. I wrote the program tst-pthread
to check all. Its work fine for me. It's nice if someone
reproduce my test on other ARCH.
Shortly:
make
make tests
./tst-pthread # for each operation prints one letter
See what happen in memory in "mmap_file"
I used only this for locking/unlocking:
#define alloc_LOCK() pthread_mutex_lock(&__alloc_mutex_lock)
#define alloc_UNLOCK() pthread_mutex_unlock(&__alloc_mutex_lock)
and in the source using this macro. I see in dietlibc
dietlibc/libpthread/pthread_sys_alloc.c
one uses:
__NO_ASYNC_CANCEL_BEGIN_(this);
I'm not threads expert. I'm not shure, that my locks
are safe (if theyavoids deadlock). Please chek it and
say if some problems arises.
Nikola
http://riemann.fmi.uni-sofia.bg/programs/diet/alloc.tar.gz