pthreads: implemented TLS, cleanup handlers, mutex_trylock