newstatus = oldstatus + 2;
sem->sem_value++; __pthread_unlock((struct _pthread_fastlock *) &sem->sem_lock); } else { th = dequeue(&sem->sem_waiting); __pthread_unlock((struct _pthread_fastlock *) &sem->sem_lock); restart(th);
int sem_post(sem_t * sem){  long oldstatus, newstatus;  do {    oldstatus = sem->sem_status;    if ((oldstatus & 1) == 0)      newstatus = 3;    else {      if (oldstatus >= SEM_VALUE_MAX) {        /* Overflow */        errno = ERANGE;        return -1;      }      newstatus = oldstatus + 2;    }  }  while (! sem_compare_and_swap(sem, oldstatus, newstatus));  if ((oldstatus & 1) == 0)    sem_restart_list((pthread_descr) oldstatus);  return 0;}