open("/dev/cuaaX") is slow
    Andrew L. Neporada 
    andr at dgap.mipt.ru
       
    Fri Apr 29 04:23:29 PDT 2005
    
    
  
Hi, hackers!
It seems that reopening /dev/cuaaX devices after close() takes exactly
3 seconds on FreeBSD 4.10 (sorry, I've no 5.x systems available at the 
moment).
Here is output of attached program:
open() time: 155 us
open() time: 2995729 us
open() time: 2999811 us
open() time: 2999608 us
open() time: 2999711 us
open() time: 2999720 us
open() time: 2999713 us
open() time: 2999744 us
open() time: 2999673 us
open() time: 2999706 us
Is this 3 second delay necessary? Can I get rid of it?
				Andrew.
-------------- next part --------------
#include <sys/time.h>
#include <stdio.h>
#include <fcntl.h>
int
main(void) {
	int		fd, i;
	long		us;
	struct timeval	tv1, tv2;
	for (i = 0; i < 10; i++) {
		gettimeofday(&tv1, NULL);
		fd = open("/dev/cuaa0", O_RDWR);
		gettimeofday(&tv2, NULL);
		us = (tv2.tv_sec - tv1.tv_sec) * 1000000 +
		     (tv2.tv_usec - tv1.tv_usec);
		printf("open() time: %d us\n", us);
		if (fd == -1) {
			perror("open");
			exit(1);
		}
		close(fd);
	}
}
    
    
More information about the freebsd-hackers
mailing list