if (!(fd_table[fd]->lockcount)) { lock = &(fd_table[fd]->lock); while (SEMAPHORE_TEST_AND_SET(lock)) { pthread_yield(); } fd_basic_unlock(fd, lock_type); SEMAPHORE_RESET(lock); }
mutex = &(fd_table[fd]->mutex); pthread_mutex_lock(mutex); fd_basic_basic_unlock(fd_table[fd], lock_type); pthread_mutex_unlock(mutex);
void fd_unlock(int fd, int lock_type){	semaphore *lock;	if (!(fd_table[fd]->lockcount)) {		lock = &(fd_table[fd]->lock);		while (SEMAPHORE_TEST_AND_SET(lock)) {			pthread_yield();		}		fd_basic_unlock(fd, lock_type);		SEMAPHORE_RESET(lock);	}}