android中库bionic线程函数pthread_create的具体执行流程
int pthread_create(pthread_t *thread_out, pthread_attr_t const * attr,
void *(*start_routine)(void *), void * arg)
{
......
// Create a mutex for the thread in TLS_SLOT_SELF to wait on once it starts so we can keep
// it from doing anything until after we notify the debugger about it
start_mutex = (pthread_mutex_t *) &tls[TLS_SLOT_SELF];
pthread_mutex_init(start_mutex, NULL); // 初始化thread启动锁
pthread_mutex_lock(start_mutex); // 获取thread的启动锁,clone返回
// 之后下面的__thread_entryh函数将因为调用pthread_mutex_lock(start_mutex);而被pending
// 直到pthread_create函数退出时调用下面第10行的pthread_mutex_unlock(start_mutex);解锁
// 函数,__thread_entryh函数才能获取启动锁,进而开始执行start_routine函数
// 所以我们可以看到函数pthread_create一旦返回,线程即开始自动执行[luther.gliethttp]
tls[TLS_SLOT_THREAD_ID] = thread;
tid = __pt