pthread_run->error = ENFILE;
SET_ERRNO(ENFILE);
int fd_allocate(){	semaphore *lock;	int i;	for (i = 0; i < dtablesize; i++) {		lock = &(fd_table[i]->lock);		while (SEMAPHORE_TEST_AND_SET(lock)) {			continue;		}		if (fd_table[i]->count || fd_table[i]->r_owner		  || fd_table[i]->w_owner) {			SEMAPHORE_RESET(lock);			continue;		}		if (fd_table[i]->type == FD_NT) {			/* Test to see if the kernel version is in use */			/* If so continue; */		}		fd_table[i]->count++;		SEMAPHORE_RESET(lock);		return(i);	}	pthread_run->error = ENFILE;	return(NOTOK);}