Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Aug 1999 16:16:05 +0400 (MSD)
From:      Charlie ROOT <root@sani-c.vrn.ru>
To:        freebsd-questions@FreeBSD.ORG
Subject:   System hang when mmap() large files
Message-ID:  <Pine.BSF.4.05.9908051615030.10782-100000@sani-c.vrn.ru>

next in thread | raw e-mail | index | archive | help

My FreeBSD 3.1-STABLE hangs when this small program running:

#include <sys/types.h>
#include <sys/mman.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>

main()
{
    int fd;
    int i;
    int len=1024*1024*10;  /*ie 10Mbytes*/
    caddr_t addr;
    char ttt[80];

    for (i=0;;i++)
    {
    sprintf (ttt,"%d",i);
    fd=open(ttt,O_CREAT|O_RDWR,0666);
    if (fd<0)
    {
	printf("open error %ld\n",errno);
	exit(1);
    }
    lseek(fd,len-1,SEEK_SET);
    write(fd,"",1);
    addr=mmap(0,len,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);
    if (addr==MAP_FAILED)
    {
	printf("mmap error %ld",errno);
	exit(1);
    }
    close(fd);
    memset(addr,'x',len);
    }
}

uname -a on my machine shows:

FreeBSD oleg.sani-c.vrn.ru 3.1-STABLE FreeBSD 3.1-STABLE 
#2: Fri Apr 23 13:31:08 MSD 1999     
root@oleg.sani-c.vrn.ru:/usr/src/sys/compile/KERNEL-CURRENT  i386

Is this a unknown bug ? I'm very sorry, but I can't cvsup now, so if this
bug has been fixed already, please don't beat me, OK ? ;-)

Sorry for my bad English...




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.9908051615030.10782-100000>