release(th->p_spinlock);
__pthread_unlock(th->p_lock);
static void pthread_exited(pid_t pid){  pthread_descr th;  int detached;  /* Find thread with that pid */  for (th = __pthread_main_thread->p_nextlive;       th != __pthread_main_thread;       th = th->p_nextlive) {    if (th->p_pid == pid) {      /* Remove thread from list of active threads */      th->p_nextlive->p_prevlive = th->p_prevlive;      th->p_prevlive->p_nextlive = th->p_nextlive;      /* Mark thread as exited, and if detached, free its resources */      acquire(th->p_spinlock);      th->p_exited = 1;      detached = th->p_detached;      release(th->p_spinlock);      if (detached) pthread_free(th);      break;    }  }  /* If all threads have exited and the main thread is pending on a     pthread_exit, wake up the main thread and terminate ourselves. */  if (main_thread_exiting &&      __pthread_main_thread->p_nextlive == __pthread_main_thread) {    restart(__pthread_main_thread);    _exit(0);  }}